feat: add blockId to return url (#442)

This commit is contained in:
Kristin Aoki
2024-01-05 09:30:35 -05:00
committed by GitHub
parent 8833f7bfca
commit 13f039ae4c
2 changed files with 8 additions and 8 deletions

View File

@@ -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 '';
};

View File

@@ -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', () => {