feat: add blockId to return url (#442)
This commit is contained in:
@@ -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 '';
|
||||
};
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user