diff --git a/src/editors/data/services/cms/api.js b/src/editors/data/services/cms/api.js index 8b44af45b..b1e407ad6 100644 --- a/src/editors/data/services/cms/api.js +++ b/src/editors/data/services/cms/api.js @@ -9,12 +9,9 @@ export const apiMethods = { fetchBlockById: ({ blockId, studioEndpointUrl }) => get( urls.block({ blockId, studioEndpointUrl }), ), - fetchByUnitId: ({ blockId, studioEndpointUrl }) => { - if (blockId.includes('block-v1')) { - return get(urls.blockAncestor({ studioEndpointUrl, blockId })); - } - return ''; - }, + fetchByUnitId: ({ blockId, studioEndpointUrl }) => get( + urls.blockAncestor({ studioEndpointUrl, blockId }), + ), 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 fd16a906d..289ec8ed9 100644 --- a/src/editors/data/services/cms/api.test.js +++ b/src/editors/data/services/cms/api.test.js @@ -45,7 +45,6 @@ const { camelize } = utils; const { apiMethods } = api; 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'; @@ -67,10 +66,6 @@ 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', () => { diff --git a/src/editors/data/services/cms/urls.js b/src/editors/data/services/cms/urls.js index 08518a843..ad402b60d 100644 --- a/src/editors/data/services/cms/urls.js +++ b/src/editors/data/services/cms/urls.js @@ -13,7 +13,10 @@ export const returnUrl = ({ studioEndpointUrl, unitUrl, learningContextId }) => } if (learningContextId && learningContextId.startsWith('lib')) { // when it's a v2 library, there will be no return url (instead a closed popup) - throw new Error('Return url not available (or needed) for V2 libraries'); + // (temporary) don't throw error, just return empty url. it will fail it's network connection but otherwise + // the app will run + // throw new Error('Return url not available (or needed) for V2 libraries'); + return ''; } // when the learning context is a course, return to the unit page if (unitUrl) { @@ -33,7 +36,10 @@ export const blockAncestor = ({ studioEndpointUrl, blockId }) => { return `${block({ studioEndpointUrl, blockId })}?fields=ancestorInfo`; } // this url only need to get info to build the return url, which isn't used by V2 blocks - throw new Error('Block ancestor not available (and not needed) for V2 blocks'); + // (temporary) don't throw error, just return empty url. it will fail it's network connection but otherwise + // the app will run + // throw new Error('Block ancestor not available (and not needed) for V2 blocks'); + return ''; }; export const blockStudioView = ({ studioEndpointUrl, blockId }) => ( diff --git a/src/editors/data/services/cms/urls.test.js b/src/editors/data/services/cms/urls.test.js index 6834fd8b4..b1aacc287 100644 --- a/src/editors/data/services/cms/urls.test.js +++ b/src/editors/data/services/cms/urls.test.js @@ -47,9 +47,13 @@ describe('cms url methods', () => { expect(returnUrl({ studioEndpointUrl, unitUrl, learningContextId: libraryLearningContextId })) .toEqual(`${studioEndpointUrl}/library/${libraryLearningContextId}`); }); - it('throws error when given the v2 library', () => { - expect(() => { returnUrl({ studioEndpointUrl, unitUrl, learningContextId: libraryV2Id }); }) - .toThrow('Return url not available (or needed) for V2 libraries'); + // it('throws error when given the v2 library', () => { + // expect(() => { returnUrl({ studioEndpointUrl, unitUrl, learningContextId: libraryV2Id }); }) + // .toThrow('Return url not available (or needed) for V2 libraries'); + // }); + it('returns empty url when given the v2 library', () => { + expect(returnUrl({ studioEndpointUrl, unitUrl, learningContextId: libraryV2Id })) + .toEqual(''); }); it('returns url with studioEndpointUrl and unitUrl', () => { expect(returnUrl({ studioEndpointUrl, unitUrl, learningContextId: courseId })) @@ -83,9 +87,14 @@ describe('cms url methods', () => { expect(blockAncestor({ studioEndpointUrl, blockId })) .toEqual(`${block({ studioEndpointUrl, blockId })}?fields=ancestorInfo`); }); - it('throws error with studioEndpointUrl, v2 blockId and ancestor query', () => { - expect(() => { blockAncestor({ studioEndpointUrl, blockId: v2BlockId }); }) - .toThrow('Block ancestor not available (and not needed) for V2 blocks'); + // This test will probably be used in the future + // it('throws error with studioEndpointUrl, v2 blockId and ancestor query', () => { + // expect(() => { blockAncestor({ studioEndpointUrl, blockId: v2BlockId }); }) + // .toThrow('Block ancestor not available (and not needed) for V2 blocks'); + // }); + it('returns blank url with studioEndpointUrl, v2 blockId and ancestor query', () => { + expect(blockAncestor({ studioEndpointUrl, blockId: v2BlockId })) + .toEqual(''); }); }); describe('blockStudioView', () => {