diff --git a/src/custom.d.ts b/src/custom.d.ts index cdb2b1a9a2..2b94311838 100644 --- a/src/custom.d.ts +++ b/src/custom.d.ts @@ -2,3 +2,8 @@ declare module '*.svg' { const content: string; export default content; } + +declare module '*.json' { + const value: any; + export default value; +} diff --git a/src/search-modal/SearchUI.test.jsx b/src/search-modal/SearchUI.test.jsx index ce1c9170c0..a4964ead3e 100644 --- a/src/search-modal/SearchUI.test.jsx +++ b/src/search-modal/SearchUI.test.jsx @@ -17,15 +17,10 @@ import { import fetchMock from 'fetch-mock-jest'; import initializeStore from '../store'; -// @ts-ignore import mockResult from './__mocks__/search-result.json'; -// @ts-ignore import mockEmptyResult from './__mocks__/empty-search-result.json'; -// @ts-ignore import mockTagsFacetResult from './__mocks__/facet-search.json'; -// @ts-ignore import mockTagsFacetResultLevel0 from './__mocks__/facet-search-level0.json'; -// @ts-ignore import mockTagsFacetResultLevel1 from './__mocks__/facet-search-level1.json'; import SearchUI from './SearchUI'; import { getContentSearchConfigUrl } from './data/api'; @@ -164,14 +159,18 @@ describe('', () => { window.open = jest.fn(); fireEvent.click(within(resultItem).getByRole('button', { name: 'Open in new window' })); expect(window.open).toHaveBeenCalledWith( - '/course/course-v1:edx+TestCourse+24?show=block-v1%3Aedx%2BTestCourse%2B24%2Btype%40html%2Bblock%40test_html', + '/course/course-v1:edx+TestCourse+24/container/block-v1:edx+TestCourse+24+type@vertical+block@vertical_3_1' + + '?show=block-v1%3Aedx%2BTestCourse%2B24%2Btype%40html%2Bblock%40test_html', '_blank', ); window.open = open; // Clicking in the result should navigate to the result's URL: fireEvent.click(resultItem); - expect(mockNavigate).toHaveBeenCalledWith('/course/course-v1:edx+TestCourse+24?show=block-v1%3Aedx%2BTestCourse%2B24%2Btype%40html%2Bblock%40test_html'); + expect(mockNavigate).toHaveBeenCalledWith( + '/course/course-v1:edx+TestCourse+24/container/block-v1:edx+TestCourse+24+type@vertical+block@vertical_3_1' + + '?show=block-v1%3Aedx%2BTestCourse%2B24%2Btype%40html%2Bblock%40test_html', + ); }); it('defaults to searching "This Course" if used in a course', async () => { diff --git a/src/search-modal/__mocks__/search-result.json b/src/search-modal/__mocks__/search-result.json index ff4397a406..3983209724 100644 --- a/src/search-modal/__mocks__/search-result.json +++ b/src/search-modal/__mocks__/search-result.json @@ -17,10 +17,16 @@ "context_key": "course-v1:edx+TestCourse+24", "org": "edx", "breadcrumbs": [ - { "display_name": "TheCourse" }, - { "display_name": "Section 2" }, - { "display_name": "Subsection 3" }, - { "display_name": "The Little Unit That Could" } + { "display_name": "TheCourse", "usage_key": "course-v1:edx+TestCourse+24" }, + { "display_name": "Section 2", "usage_key": "block-v1:edx+TestCourse+24+type@chapter+block@chapter_2" }, + { + "display_name": "Subsection 3", + "usage_key": "block-v1:edx+TestCourse+24+type@sequential+block@sequential_3" + }, + { + "display_name": "The Little Unit That Could", + "usage_key": "block-v1:edx+TestCourse+24+type@vertical+block@vertical_3_1" + } ], "tags": { "taxonomy": [ @@ -64,7 +70,8 @@ "org": "edx", "breadcrumbs": [ { - "display_name": "libafter2" + "display_name": "libafter2", + "usage_key": "lib:org1:libafter1" } ], "type": "library_block"