Merge pull request #377 from openedx/kenclary/supplimental

fix: don't even bother fetching block ancestor in v2.
This commit is contained in:
kenclary
2023-08-17 17:37:31 -04:00
committed by GitHub
2 changed files with 12 additions and 4 deletions

View File

@@ -9,9 +9,12 @@ export const apiMethods = {
fetchBlockById: ({ blockId, studioEndpointUrl }) => get(
urls.block({ blockId, studioEndpointUrl }),
),
fetchByUnitId: ({ blockId, studioEndpointUrl }) => get(
urls.blockAncestor({ studioEndpointUrl, blockId }),
),
fetchByUnitId: ({ blockId, studioEndpointUrl }) => {
if (blockId.includes('block-v1')) {
return get(urls.blockAncestor({ studioEndpointUrl, blockId }));
}
return '';
},
fetchStudioView: ({ blockId, studioEndpointUrl }) => get(
urls.blockStudioView({ studioEndpointUrl, blockId }),
),

View File

@@ -44,7 +44,8 @@ const { camelize } = utils;
const { apiMethods } = api;
const blockId = 'coursev1:2uX@4345432';
const blockId = 'block-v1-coursev1:2uX@4345432';
const v2BlockId = '???-coursev2:2uX@4345432';
const learningContextId = 'demo2uX';
const studioEndpointUrl = 'hortus.coa';
const title = 'remember this needs to go into metadata to save';
@@ -66,6 +67,10 @@ describe('cms api', () => {
apiMethods.fetchByUnitId({ blockId, studioEndpointUrl });
expect(get).toHaveBeenCalledWith(urls.blockAncestor({ studioEndpointUrl, blockId }));
});
it('should not call get with url.blockAncestor for v2', () => {
apiMethods.fetchByUnitId({ blockId: v2BlockId, studioEndpointUrl });
expect(get).not.toHaveBeenCalledWith(urls.blockAncestor({ studioEndpointUrl, blockId: v2BlockId }));
});
});
describe('fetchStudioView', () => {