From 174de4bc1b4bbf8409472fe4e2752dc9ce978af6 Mon Sep 17 00:00:00 2001 From: Michael Roytman Date: Wed, 7 Feb 2024 15:39:23 -0500 Subject: [PATCH] feat: update version of frontend-lib-learning-assistant to 1.21.0 (#1285) This commit installs version 1.21.0 of @edx/frontend-lib-learning-assistant. This commit also refactors the Chat tests to assert on whether the Xpert component is rendered by the Chat component, not whether Xpert actually renders. This is because Xpert now has its own logic to determine whether to render. This release uses a new GET endpoint published on the Learning Assistant backend to determine whether the Learning Assistant feature is enabled. If the features is not enabled, the Learning Assistant is not rendered, and vice-versa. --- package-lock.json | 8 +++---- package.json | 2 +- src/courseware/course/chat/Chat.test.jsx | 27 +++++++++++++++++++----- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6bcec81394..f1e3bd8be2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "@edx/brand": "npm:@openedx/brand-openedx@^1.2.2", "@edx/frontend-component-footer": "12.2.1", "@edx/frontend-component-header": "4.6.0", - "@edx/frontend-lib-learning-assistant": "^1.20.1", + "@edx/frontend-lib-learning-assistant": "^1.21.0", "@edx/frontend-lib-special-exams": "2.27.0", "@edx/frontend-platform": "5.5.2", "@edx/openedx-atlas": "^0.6.0", @@ -3461,9 +3461,9 @@ } }, "node_modules/@edx/frontend-lib-learning-assistant": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/@edx/frontend-lib-learning-assistant/-/frontend-lib-learning-assistant-1.20.1.tgz", - "integrity": "sha512-/JUSfs4CZwZj2Bg0BqlMGIC6BrDu4PufUSFnrgusL4ZD/N8DR3UyX/AQZml7S9O/ci4OY3YU7V4VDM8X00+6Lg==", + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/@edx/frontend-lib-learning-assistant/-/frontend-lib-learning-assistant-1.21.0.tgz", + "integrity": "sha512-KHmKBKtDxNVWCLOvvuoe1Sboc5BqI0mQP1UX0mhF9USI7ebZ5tPB1oxy6XK7ZhMBQPXMUBoWVh2Krf7P4NhWeg==", "dependencies": { "@edx/brand": "npm:@edx/brand-openedx@1.2.0", "@fortawesome/fontawesome-svg-core": "1.2.36", diff --git a/package.json b/package.json index 9e8bec2e45..5598b91f92 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "@edx/frontend-component-footer": "12.2.1", "@edx/frontend-component-header": "4.6.0", "@edx/frontend-lib-special-exams": "2.27.0", - "@edx/frontend-lib-learning-assistant": "^1.20.1", + "@edx/frontend-lib-learning-assistant": "^1.21.0", "@edx/frontend-platform": "5.5.2", "@edx/openedx-atlas": "^0.6.0", "@edx/paragon": "20.46.0", diff --git a/src/courseware/course/chat/Chat.test.jsx b/src/courseware/course/chat/Chat.test.jsx index 31085c54df..581948037f 100644 --- a/src/courseware/course/chat/Chat.test.jsx +++ b/src/courseware/course/chat/Chat.test.jsx @@ -8,6 +8,23 @@ import { initializeMockApp, render, screen } from '../../../setupTest'; import Chat from './Chat'; +// We do a partial mock to avoid mocking out other exported values (e.g. the reducer). +// We mock out the Xpert component, because the Xpert component has its own rules for whether it renders +// or not, and this includes the results of API calls it makes. We don't want to test those rules here, just +// whether the Xpert is rendered by the Chat component in certain conditions. Instead of actually rendering +// Xpert, we render and assert on a mocked component. +const mockXpertTestId = 'xpert'; + +jest.mock('@edx/frontend-lib-learning-assistant', () => { + const originalModule = jest.requireActual('@edx/frontend-lib-learning-assistant'); + + return { + __esModule: true, + ...originalModule, + Xpert: () => (
mocked Xpert
), + }; +}); + initializeMockApp(); const courseId = 'course-v1:edX+DemoX+Demo_Course'; @@ -51,7 +68,7 @@ describe('Chat', () => { { store }, ); - const chat = screen.queryByTestId('toggle-button'); + const chat = screen.queryByTestId(mockXpertTestId); if (test.isVisible) { expect(chat).toBeInTheDocument(); } else { @@ -85,7 +102,7 @@ describe('Chat', () => { { store }, ); - const chat = screen.queryByTestId('toggle-button'); + const chat = screen.queryByTestId(mockXpertTestId); if (test.isVisible) { expect(chat).toBeInTheDocument(); } else { @@ -147,7 +164,7 @@ describe('Chat', () => { { store }, ); - const chat = screen.queryByTestId('toggle-button'); + const chat = screen.queryByTestId(mockXpertTestId); if (test.isVisible) { expect(chat).toBeInTheDocument(); } else { @@ -178,7 +195,7 @@ describe('Chat', () => { { store }, ); - const chat = screen.queryByTestId('toggle-button'); + const chat = screen.queryByTestId(mockXpertTestId); expect(chat).not.toBeInTheDocument(); }); @@ -203,7 +220,7 @@ describe('Chat', () => { { store }, ); - const chat = screen.queryByTestId('toggle-button'); + const chat = screen.queryByTestId(mockXpertTestId); expect(chat).toBeInTheDocument(); }); });