[Remove Vuetify from Studio] Convert 'Forgot password' unit tests to Vue Testing Library#5684
[Remove Vuetify from Studio] Convert 'Forgot password' unit tests to Vue Testing Library#5684AadarshM07 wants to merge 1 commit intolearningequality:unstablefrom
Conversation
|
👋 Thanks for contributing! We will assign a reviewer within the next two weeks. In the meantime, please ensure that:
We'll be in touch! 😊 |
|
Thanks @AadarshM07! Before we assign a maintainer, I will invite the community review. 📢 ✨ Community Review guidance for both authors and reviewers. |
|
Hi @AadarshM07, LGTM overall, theres no unnecessary lines, nothing redundant. However Ive left a few comments, which I thought would be good to change, you may refer them. Thanks. |
|
Hi @sharma-anushka , Thanks for your time. I am not able to see any comments on the PR right now - could you please check if they were submitted? |
| const { router } = renderComponent(); | ||
| await fireEvent.update(screen.getByLabelText('Email'), 'test@test.com'); | ||
| await fireEvent.click(screen.getByRole('button', { name: 'Submit' })); | ||
| await waitFor(() => { |
There was a problem hiding this comment.
waitFor may not be necessary here since we’re verifying on a mocked action call and thus we can simplify this.
| it('should render the forgot password form', () => { | ||
| renderComponent(); | ||
| expect(screen.getByText('Reset your password')).toBeInTheDocument(); | ||
| expect(screen.getByLabelText('Email')).toBeInTheDocument(); |
There was a problem hiding this comment.
In my opinion, a more generic selector (maybe by role) would be safer here. Relying on exact label text (Email) would be a bit risky.
|
@AadarshM07 apologies. Just submitted them. |
|
Great work @AadarshM07 on line 69 - 74It could also be useful to assert that the action is called exactly once. That way, we’d guard against accidental double-submit regressions in future refactors. |
|
Hey @sharma-anushka @vijayho1, Thank you for your reviews. I have gone through it and will make the required changes soon |
Summary
The test suite
accounts/pages/__tests__/forgotPassword.spec.jspreviously relied heavily on internal implementation details and used Vue Test Utils in a way that tightly coupled the tests to component internals. The aim of this PR is to rewrite the tests using Vue Testing Library while ensuring the coverage reflects how a user interacts with the application.The tests cover the following areas:
References
Closes #5632
Verification
Reviewer guidance
The changes have been made to the following files:
contentcuration/contentcuration/frontend/accounts/pages/__tests__/forgotPassword.spec.jscontentcuration/contentcuration/frontend/accounts/pages/resetPassword/ForgotPassword.vue