Skip to content

Commit

Permalink
feat: update version of frontend-lib-learning-assistant to 1.21.0 (op…
Browse files Browse the repository at this point in the history
…enedx#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.
  • Loading branch information
MichaelRoytman authored Feb 7, 2024
1 parent 55e2332 commit 174de4b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
27 changes: 22 additions & 5 deletions src/courseware/course/chat/Chat.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => (<div data-testid={mockXpertTestId}>mocked Xpert</div>),
};
});

initializeMockApp();

const courseId = 'course-v1:edX+DemoX+Demo_Course';
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -178,7 +195,7 @@ describe('Chat', () => {
{ store },
);

const chat = screen.queryByTestId('toggle-button');
const chat = screen.queryByTestId(mockXpertTestId);
expect(chat).not.toBeInTheDocument();
});

Expand All @@ -203,7 +220,7 @@ describe('Chat', () => {
{ store },
);

const chat = screen.queryByTestId('toggle-button');
const chat = screen.queryByTestId(mockXpertTestId);
expect(chat).toBeInTheDocument();
});
});

0 comments on commit 174de4b

Please sign in to comment.