Skip to content

Commit

Permalink
fix: add like-dislike request mock and ignore node_modules/edunext ex…
Browse files Browse the repository at this point in the history
…ports
  • Loading branch information
andrey-canon committed Nov 29, 2024
1 parent 2bea80c commit 44edb72
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ config.reporters = [...(config.reporters || []), ["jest-console-group-reporter",
}]];

module.exports = config;

module.exports.transformIgnorePatterns = [
'/node_modules/(?!(@edx|@edunext|@openedx))',
];
4 changes: 2 additions & 2 deletions src/courseware/course/sequence/Sequence.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('Sequence', () => {

await waitFor(() => expect(screen.queryByText('Loading locked content messaging...')).toBeInTheDocument());
// `Previous`, `Prerequisite` and `Close Tray` buttons.
expect(screen.getAllByRole('button').length).toEqual(3);
expect(screen.getAllByRole('button').length).toEqual(5); // two more buttons like and dislike
// `Next` button.
expect(screen.getAllByRole('link').length).toEqual(1);

Expand Down Expand Up @@ -159,7 +159,7 @@ describe('Sequence', () => {
render(<SidebarWrapper />, { wrapWithRouter: true });
expect(await screen.findByText('Loading learning sequence...')).toBeInTheDocument();
// `Previous`, `Prerequisite` and `Close Tray` buttons.
expect(screen.getAllByRole('button')).toHaveLength(3);
expect(screen.getAllByRole('button')).toHaveLength(5); // two more buttons like and dislike
// Renders `Next` button.
expect(screen.getAllByRole('link')).toHaveLength(1);

Expand Down
3 changes: 3 additions & 0 deletions src/setupTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ export async function initializeTestStore(options = {}, overrideStore = true) {
const proctoredExamApiUrl = `${getConfig().LMS_BASE_URL}/api/edx_proctoring/v1/proctored_exam/attempt/course_id/${courseMetadata.id}/content_id/${sequenceMetadata.item_id}?is_learning_mfe=true`;
axiosMock.onGet(proctoredExamApiUrl).reply(200, { exam: {}, active_attempt: {} });
});
// frontend essentials configuration, this will return an status 404 on every like-dislike request
const likeDislikeUrlPattern = new RegExp(`${getConfig().COURSE_EXPERIENCE_API_URL}/like/units/.*/`);
axiosMock.onGet(likeDislikeUrlPattern).reply(404, {});

logUnhandledRequests(axiosMock);

Expand Down

0 comments on commit 44edb72

Please sign in to comment.