diff --git a/src/editors/data/redux/thunkActions/app.js b/src/editors/data/redux/thunkActions/app.js index 0bd1a070af..2e210bb80d 100644 --- a/src/editors/data/redux/thunkActions/app.js +++ b/src/editors/data/redux/thunkActions/app.js @@ -89,7 +89,7 @@ export const initialize = (data) => (dispatch) => { const editorType = data.blockType; dispatch(actions.app.initialize(data)); dispatch(module.fetchBlock()); - if (data.blockId.startsWith('block-v1:')) { + if (data.blockId?.startsWith('block-v1:')) { dispatch(module.fetchUnit()); } switch (editorType) { @@ -102,7 +102,7 @@ export const initialize = (data) => (dispatch) => { dispatch(module.fetchCourseDetails()); break; case 'html': - if (data.learningContextId.startsWith('lib:')) { + if (data.learningContextId?.startsWith('lib:')) { // eslint-disable-next-line no-console console.log('Not fetching image assets - not implemented yet for content libraries.'); } else { diff --git a/src/editors/data/redux/thunkActions/app.test.js b/src/editors/data/redux/thunkActions/app.test.js index 2c962b2853..5cf52f7941 100644 --- a/src/editors/data/redux/thunkActions/app.test.js +++ b/src/editors/data/redux/thunkActions/app.test.js @@ -187,7 +187,6 @@ describe('app thunkActions', () => { expect(dispatch.mock.calls).toEqual([ [actions.app.initialize(testValue)], [thunkActions.fetchBlock()], - [thunkActions.fetchUnit()], ]); thunkActions.fetchBlock = fetchBlock; thunkActions.fetchUnit = fetchUnit; @@ -216,6 +215,8 @@ describe('app thunkActions', () => { const data = { ...testValue, blockType: 'html', + blockId: 'block-v1:UniversityX+PHYS+1+type@problem+block@123', + learningContextId: 'course-v1:UniversityX+PHYS+1', }; thunkActions.initialize(data)(dispatch); expect(dispatch.mock.calls).toEqual([ @@ -251,6 +252,8 @@ describe('app thunkActions', () => { const data = { ...testValue, blockType: 'problem', + blockId: 'block-v1:UniversityX+PHYS+1+type@problem+block@123', + learningContextId: 'course-v1:UniversityX+PHYS+1', }; thunkActions.initialize(data)(dispatch); expect(dispatch.mock.calls).toEqual([ @@ -286,6 +289,8 @@ describe('app thunkActions', () => { const data = { ...testValue, blockType: 'video', + blockId: 'block-v1:UniversityX+PHYS+1+type@problem+block@123', + learningContextId: 'course-v1:UniversityX+PHYS+1', }; thunkActions.initialize(data)(dispatch); expect(dispatch.mock.calls).toEqual([