feat: v2 xblocks should use v2 url. TNL-10742
This commit is contained in:
6
package-lock.json
generated
6
package-lock.json
generated
@@ -9986,9 +9986,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/fast-xml-parser": {
|
||||
"version": "4.2.2",
|
||||
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.2.2.tgz",
|
||||
"integrity": "sha512-DLzIPtQqmvmdq3VUKR7T6omPK/VCRNqgFlGtbESfyhcH2R4I8EzK1/K6E8PkRCK2EabWrUHK32NjYRbEFnnz0Q==",
|
||||
"version": "4.2.4",
|
||||
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.2.4.tgz",
|
||||
"integrity": "sha512-fbfMDvgBNIdDJLdLOwacjFAPYt67tr31H9ZhWSm45CDAxvd0I6WTlSOUo7K2P/K5sA5JgMKG64PI3DMcaFdWpQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "paypal",
|
||||
|
||||
@@ -16,7 +16,9 @@ export const returnUrl = ({ studioEndpointUrl, unitUrl, learningContextId }) =>
|
||||
};
|
||||
|
||||
export const block = ({ studioEndpointUrl, blockId }) => (
|
||||
`${studioEndpointUrl}/xblock/${blockId}`
|
||||
blockId.includes('block-v1')
|
||||
? `${studioEndpointUrl}/xblock/${blockId}`
|
||||
: `${studioEndpointUrl}/api/xblock/v2/xblocks/${blockId}`
|
||||
);
|
||||
|
||||
export const blockAncestor = ({ studioEndpointUrl, blockId }) => (
|
||||
|
||||
@@ -21,7 +21,8 @@ import {
|
||||
|
||||
describe('cms url methods', () => {
|
||||
const studioEndpointUrl = 'urLgoeStOstudiO';
|
||||
const blockId = 'blOckIDTeST123';
|
||||
const blockId = 'block-v1-blOckIDTeST123';
|
||||
const v2BlockId = 'blOckIDTeST123';
|
||||
const learningContextId = 'lEarnIngCOntextId123';
|
||||
const courseId = 'course-v1:courseId123';
|
||||
const libraryV1Id = 'library-v1:libaryId123';
|
||||
@@ -62,10 +63,14 @@ describe('cms url methods', () => {
|
||||
});
|
||||
});
|
||||
describe('block', () => {
|
||||
it('returns url with studioEndpointUrl and blockId', () => {
|
||||
it('returns v1 url with studioEndpointUrl and blockId', () => {
|
||||
expect(block({ studioEndpointUrl, blockId }))
|
||||
.toEqual(`${studioEndpointUrl}/xblock/${blockId}`);
|
||||
});
|
||||
it('returns v2 url with studioEndpointUrl and v2BlockId', () => {
|
||||
expect(block({ studioEndpointUrl, blockId: v2BlockId }))
|
||||
.toEqual(`${studioEndpointUrl}/api/xblock/v2/xblocks/${v2BlockId}`);
|
||||
});
|
||||
});
|
||||
describe('blockAncestor', () => {
|
||||
it('returns url with studioEndpointUrl, blockId and ancestor query', () => {
|
||||
|
||||
Reference in New Issue
Block a user