diff --git a/src/editors/data/services/cms/api.js b/src/editors/data/services/cms/api.js index b1e407ad6..8b44af45b 100644 --- a/src/editors/data/services/cms/api.js +++ b/src/editors/data/services/cms/api.js @@ -9,9 +9,12 @@ export const apiMethods = { fetchBlockById: ({ blockId, studioEndpointUrl }) => get( urls.block({ blockId, studioEndpointUrl }), ), - fetchByUnitId: ({ blockId, studioEndpointUrl }) => get( - urls.blockAncestor({ studioEndpointUrl, blockId }), - ), + fetchByUnitId: ({ blockId, studioEndpointUrl }) => { + if (blockId.includes('block-v1')) { + return get(urls.blockAncestor({ studioEndpointUrl, blockId })); + } + return ''; + }, fetchStudioView: ({ blockId, studioEndpointUrl }) => get( urls.blockStudioView({ studioEndpointUrl, blockId }), ), diff --git a/src/editors/data/services/cms/api.test.js b/src/editors/data/services/cms/api.test.js index 925f8dc05..fd16a906d 100644 --- a/src/editors/data/services/cms/api.test.js +++ b/src/editors/data/services/cms/api.test.js @@ -44,7 +44,8 @@ const { camelize } = utils; const { apiMethods } = api; -const blockId = 'coursev1:2uX@4345432'; +const blockId = 'block-v1-coursev1:2uX@4345432'; +const v2BlockId = '???-coursev2:2uX@4345432'; const learningContextId = 'demo2uX'; const studioEndpointUrl = 'hortus.coa'; const title = 'remember this needs to go into metadata to save'; @@ -66,6 +67,10 @@ describe('cms api', () => { apiMethods.fetchByUnitId({ blockId, studioEndpointUrl }); expect(get).toHaveBeenCalledWith(urls.blockAncestor({ studioEndpointUrl, blockId })); }); + it('should not call get with url.blockAncestor for v2', () => { + apiMethods.fetchByUnitId({ blockId: v2BlockId, studioEndpointUrl }); + expect(get).not.toHaveBeenCalledWith(urls.blockAncestor({ studioEndpointUrl, blockId: v2BlockId })); + }); }); describe('fetchStudioView', () => {