-
Notifications
You must be signed in to change notification settings - Fork 269
[Remove Vuetify from Studio] Convert Content Library unit tests to Vue Testing Library #5536
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
base: unstable
Are you sure you want to change the base?
[Remove Vuetify from Studio] Convert Content Library unit tests to Vue Testing Library #5536
Conversation
|
Thank you @vtushar06, within next two weeks, we will assign a reviewer. |
|
Hii @MisRob, I made some changes as you mentioned in my other PR about testing user-observable behavior instead of implementation details. |
...entcuration/contentcuration/frontend/channelList/views/Channel/__tests__/catalogList.spec.js
Show resolved
Hide resolved
...entcuration/contentcuration/frontend/channelList/views/Channel/__tests__/catalogList.spec.js
Show resolved
Hide resolved
|
@MisRob ,I applied the approach from Issue #5474 and systematically removed stubs that weren't needed.
Tests now focus on user-visible behavior, Now PR is ready for review. |
…n from unstable The contributor's StudioChip implementation is identical to ours. We'll use their version from unstable and focus on test refactoring following Issue learningequality#5536 patterns (data-present vs data-absent scenarios). Following maintainer guidance from PR learningequality#5540 review.
Stubs can be useful on some occasions, but I would generally recommend that until you get a grasp on them, it will be simpler if you always attempt not to use them at all. Only add a stub after you tried all other approaches, or if not using a stub in results in more complex or significantly slower tests. In majority of cases, you won't need them. |
|
Hi @MisRob, |
|
Hii @MisRob, This PR is now ready for review, please assign someone to review this and let me know If any more changes required. |
marcellamaki
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @vtushar06 - thanks for your work on this! You've made a good start (and I can see that you've already applied some feedback from Misha regarding simplification and removing stubs) on a challenging task, and much of the work here is looking good :)
I know that in some other conversations with Misha, you've discussed the value of using getByText to confirm the rendering something in the DOM, and that can be a really useful approach. Here, however, you've added a mock for the translations, which I think adds unnecessary complexity, and potentially also brittleness. I added one particular inline comment just for more detail.
Could you try an approach that uses either strings without having to mock them, or another simple check to confirm rendering? That will help keep the test suite as simple as possible.
Two ideas for how to think about it, and you may want to apply these differently to different scenarios:
- Is the string specifically what needs to be tested that it's rendered? If so, is there a way to do so without a mock?
- If the string is a "proxy" of some type of display or changed state in the UX, is there another way to confirm that a particular (div, button, etc.) is rendered in a way that wouldn't require mocking a string? (this might require for example adding a test id on a component, and then checking that instead).
Misha and I will both be away starting next week for end of year holidays, but I will be happy to re-review or answer any more questions in January. Happy new year!
...entcuration/contentcuration/frontend/channelList/views/Channel/__tests__/catalogList.spec.js
Outdated
Show resolved
Hide resolved
…test cases for selection mode and loading states
…improved flexibility
71af890 to
b3c1b9c
Compare
|
Hi @marcellamaki, Thank you for the detailed feedback I've updated the tests to remove the translation mocks entirely. Now the tests use regex patterns to match the actual rendered text from the component's Changes I made Removed all Ready for re-review when you're back in January. Happy holidays! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR converts the Content Library (CatalogList) unit tests from Vue Test Utils to Vue Testing Library, shifting from implementation-detail testing to user-observable behavior testing. The migration simplifies the test setup by using a real Vuex store and consolidates duplicate tests.
Key Changes:
- Replaced Vue Test Utils
mount()with Vue Testing Libraryrender()and semantic queries - Consolidated duplicate tests from 15 to 10 focused tests
- Removed unused mock functions (
downloadChannelsCSV,downloadChannelsPDF)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...entcuration/contentcuration/frontend/channelList/views/Channel/__tests__/catalogList.spec.js
Show resolved
Hide resolved
...entcuration/contentcuration/frontend/channelList/views/Channel/__tests__/catalogList.spec.js
Show resolved
Hide resolved
...entcuration/contentcuration/frontend/channelList/views/Channel/__tests__/catalogList.spec.js
Show resolved
Hide resolved
...entcuration/contentcuration/frontend/channelList/views/Channel/__tests__/catalogList.spec.js
Show resolved
Hide resolved
...entcuration/contentcuration/frontend/channelList/views/Channel/__tests__/catalogList.spec.js
Show resolved
Hide resolved
...entcuration/contentcuration/frontend/channelList/views/Channel/__tests__/catalogList.spec.js
Show resolved
Hide resolved
|
Hii @marcellamaki, can we continue resolving this one, once you are free, please let me know. Thanks |
|
Hi @vtushar06 -- thank you for the updates here. This has removed a lot of the complexity! I am still a bit confused about why you've removed all of the
we use It isn't that it's wrong, I just think if there are ways to continue to simplify a bit more, that would be ideal. Thank you! And please ask follow up questions if I am not being clear :) |
|
Hi @marcellamaki,
This allows me to use stable queries like screen.getByTestId('select') for interactions, while keeping the component code clean. I've updated the PR with these changes too, |
|
I don't know if it was the best decision, but I guide people to simply use VTL's default In long-term, it'd be best to choose just one and configure it globally for all tests - but I don't think that's in the scope of this work. If you'd be interested in it @vtushar06, you can do it, but it'd be a follow-up and before that I would need to check in with the team about which of the two we want. |
|
^ this concerns only naming choice Please still resolve Marcella's suggestion. |
|
Thanks for guidance, @MisRob, That makes sense — keeping the approach consistent across files now definitely help in figuring things later. Absolutely! I'm interested in the follow-up work. I'll wait for you to check in with the team about the preferred approach, and then I can get started on the global configuration. Thanks for the opportunity! Also, I'll get Marcella's suggestion resolved right now. |
|
And I do not know why linting is not getting fixed even though I ran lint command twice, can you help me with this. |
Summary
Converted Content Library (CatalogList) unit tests from Vue Test Utils to Vue Testing Library, focusing on user-observable behavior and removing implementation detail testing.
Key Changes:
mount()withrender()and Vue Testing Library semantic queriesmockDownloadChannelsCSV,mockDownloadChannelsPDF)mapActions/mapGetters)Test Coverage (10 tests):
Verification:
Ran npm test -- catalogList.spec.js
It passed all 15 tests
…
References
Closes: #5527
…
Reviewer guidance
Tests focus on rendered content + business logic (VTL pattern)
No internal state access (removed tests on excluded array, component methods)