Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install Xpert chatbot from frontend-lib-learning-assistant. #1166

Merged

Conversation

MichaelRoytman
Copy link
Contributor

Description

This commit installs the Xpert chatbot feature from the frontend-lib-learning-assistant repository into the frontend-lib-learning application.

This component is rendered by the Course component. The component is only rendered when a few conditions are satisfied.

JIRA: MST-2034 (private)

Demo

NOTE: Please ignore the line over the video camera icon. This was fixed in edx/frontend-lib-learning-assistant#12.

MST-2034-Xpert-Demo.mov

@MichaelRoytman MichaelRoytman force-pushed the michaelroytman/MST-2034-install-learning-assistant-lib branch from 1cbe62e to d4333a3 Compare August 22, 2023 19:12
@@ -93,10 +93,10 @@ const Course = ({
/>
{shouldDisplayTriggers && (
<>
<ChatTrigger
<Chat
enabled={course.learningAssistantEnabled}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to read these values from the Redux store, but it'll make testing more difficult because I'll have to set up that part of the Redux store, so I've chosen to use props here in the interest of getting this out more quickly.

enrollmentMode: null,
};

export default injectIntl(Chat);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is really necessary, since there's no text to internationalize right now.


const courseId = 'course-v1:edX+DemoX+Demo_Course';
let testCases = [];
let enabledTestCases = [];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to refactor the test to generate the test cases instead of declaring them outright. This is because the conditions under which the Xpert chatbot should appear have grown more complex, so it's easier to generate the objects. Let me know if this makes it more confusing to read.

{ store },
);

// This is rather brittle and depends on the implementation of the Xpert component, but there
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any other ideas here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an ID that we can query by instead? I'm hesitant to query by button name because that could change

Copy link
Contributor Author

@MichaelRoytman MichaelRoytman Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add a data-testid property to the button that we could query for. I'm a little torn, because I think we should be querying by roles like button, because it's a more representative and accessible way of testing. And I wonder if these tests should break if we change the text of the button. But, on the other hand, these tests aren't meant to test how the toggle button looks and behaves.

Actually, now that I think of it, since I'm only rendering the Xpert in the test, there should only be a single button in the DOM, so I could get away with this.

const chat = screen.queryByRole('button');

What do you think of that? I feel like it's more reasonable to assume there is a button in the DOM than a button with a particular "name". If you prefer the test ID, I can work on adding that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's only rendering the Xpert Component in the test, I like the idea of querying by the button role alone, as opposed to a button with a particular name. That seems like an appropriate solution to me that is definitely less brittle.

@@ -116,6 +117,7 @@ export async function initializeTestStore(options = {}, overrideStore = true) {
models: modelsReducer,
courseware: coursewareReducer,
courseHome: courseHomeReducer,
learningAssistant: learningAssistantReducer,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused why the learningAssistantReducer is necessary, but the tours or recommendations reducers aren't. Without the learningAssistantReducer, other tests were breaking, so I added it.

@MichaelRoytman MichaelRoytman changed the title Install Xpert chatbot from frontend-lib-learning-assistant Install Xpert chatbot from frontend-lib-learning-assistant. Aug 22, 2023
@MichaelRoytman MichaelRoytman force-pushed the michaelroytman/MST-2034-install-learning-assistant-lib branch from d4333a3 to c88cd44 Compare August 22, 2023 19:27

return (
<>
{/* Use a portal to ensure that component overlay does not compete with learning MFE styles. */}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you adding this comment!

{ store },
);

// This is rather brittle and depends on the implementation of the Xpert component, but there
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an ID that we can query by instead? I'm hesitant to query by button name because that could change

This commit installs the Xpert chatbot feature from the frontend-lib-learning-assistant repository into the frontend-lib-learning application.

This component is rendered by the Course component. The component is only rendered when a few conditions are satisfied.
@MichaelRoytman MichaelRoytman force-pushed the michaelroytman/MST-2034-install-learning-assistant-lib branch from c88cd44 to 4ba1cde Compare August 22, 2023 21:02
@codecov
Copy link

codecov bot commented Aug 22, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.03% ⚠️

Comparison is base (2e90e21) 87.87% compared to head (4ba1cde) 87.85%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1166      +/-   ##
==========================================
- Coverage   87.87%   87.85%   -0.03%     
==========================================
  Files         264      263       -1     
  Lines        4480     4470      -10     
  Branches     1124     1122       -2     
==========================================
- Hits         3937     3927      -10     
  Misses        529      529              
  Partials       14       14              
Files Changed Coverage Δ
src/courseware/course/Course.jsx 88.88% <ø> (ø)
...eware/data/__factories__/courseMetadata.factory.js 100.00% <ø> (ø)
src/courseware/data/api.js 84.61% <ø> (ø)
src/store.js 100.00% <ø> (ø)
src/courseware/course/chat/Chat.jsx 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MichaelRoytman
Copy link
Contributor Author

@alangsto I addressed your feedback. Let me know what you think!

Copy link
Contributor

@alangsto alangsto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@MichaelRoytman MichaelRoytman merged commit 2d29827 into master Aug 23, 2023
@MichaelRoytman MichaelRoytman deleted the michaelroytman/MST-2034-install-learning-assistant-lib branch August 23, 2023 13:14
@arbrandes
Copy link

Hey there! This just came to my attention. Is there an OEP, ADR, or other documentation (including any community discussions) that describe the intention behind this new functionality?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants