Skip to content

Commit

Permalink
feat: add blockId to return url (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristinAoki authored Jan 5, 2024
1 parent 8833f7b commit 13f039a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/editors/data/services/cms/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ({
Expand All @@ -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 '';
};
Expand Down
10 changes: 5 additions & 5 deletions src/editors/data/services/cms/urls.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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', () => {
Expand Down

0 comments on commit 13f039a

Please sign in to comment.