fix: revert to blank-url version of error handling, for now
This commit is contained in:
@@ -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 }),
|
||||
),
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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 }) => (
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user