From 13f039ae4c893a9548ca656dd74ebf5edbb7ae4a Mon Sep 17 00:00:00 2001 From: Kristin Aoki <42981026+KristinAoki@users.noreply.github.com> Date: Fri, 5 Jan 2024 09:30:35 -0500 Subject: [PATCH] feat: add blockId to return url (#442) --- src/editors/data/services/cms/urls.js | 6 +++--- src/editors/data/services/cms/urls.test.js | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/editors/data/services/cms/urls.js b/src/editors/data/services/cms/urls.js index 2d8943019..14b7ff338 100644 --- a/src/editors/data/services/cms/urls.js +++ b/src/editors/data/services/cms/urls.js @@ -2,8 +2,8 @@ export const libraryV1 = ({ studioEndpointUrl, learningContextId }) => ( `${studioEndpointUrl}/library/${learningContextId}` ); -export const unit = ({ studioEndpointUrl, unitUrl }) => ( - `${studioEndpointUrl}/container/${unitUrl.data.ancestors[0]?.id}` +export const unit = ({ studioEndpointUrl, unitUrl, blockId }) => ( + `${studioEndpointUrl}/container/${unitUrl.data.ancestors[0]?.id}#${blockId}` ); export const returnUrl = ({ @@ -23,7 +23,7 @@ export const returnUrl = ({ // when the learning context is a course, return to the unit page // only do this for v1 blocks if (unitUrl && blockId.includes('block-v1')) { - return unit({ studioEndpointUrl, unitUrl }); + return unit({ studioEndpointUrl, unitUrl, blockId }); } return ''; }; diff --git a/src/editors/data/services/cms/urls.test.js b/src/editors/data/services/cms/urls.test.js index 04c2fa25e..e9bbed2f0 100644 --- a/src/editors/data/services/cms/urls.test.js +++ b/src/editors/data/services/cms/urls.test.js @@ -55,11 +55,11 @@ describe('cms url methods', () => { expect(returnUrl({ studioEndpointUrl, unitUrl, learningContextId: libraryV2Id })) .toEqual(''); }); - it('returns url with studioEndpointUrl and unitUrl', () => { + it('returnUrl function should return url with studioEndpointUrl, unitUrl, and blockId', () => { expect(returnUrl({ studioEndpointUrl, unitUrl, learningContextId: courseId, blockId, })) - .toEqual(`${studioEndpointUrl}/container/${unitUrl.data.ancestors[0].id}`); + .toEqual(`${studioEndpointUrl}/container/${unitUrl.data.ancestors[0].id}#${blockId}`); }); it('returns blank url for v2 block', () => { expect(returnUrl({ @@ -75,9 +75,9 @@ describe('cms url methods', () => { expect(libraryV1({ studioEndpointUrl, learningContextId: libraryV1Id })) .toEqual(`${studioEndpointUrl}/library/${libraryV1Id}`); }); - it('returns url with studioEndpointUrl and unitUrl', () => { - expect(unit({ studioEndpointUrl, unitUrl })) - .toEqual(`${studioEndpointUrl}/container/${unitUrl.data.ancestors[0].id}`); + it('unit function should return url with studioEndpointUrl, unitUrl, and blockId', () => { + expect(unit({ studioEndpointUrl, unitUrl, blockId })) + .toEqual(`${studioEndpointUrl}/container/${unitUrl.data.ancestors[0].id}#${blockId}`); }); }); describe('block', () => {