test: migrate ChannelTokenModal.spec.js from VTU to VTL (#14261)
Summary
Migrate ChannelTokenModal.spec.js to Vue Testing Library as part of issue #14261.
This is Part 1 of 4 of the device plugin test migration:
- ✅ ChannelTokenModal.spec.js (this PR)
- ⏳ RearrangeChannelsPage.spec.js (next)
- ⏳ AvailableChannelsPage.spec.js (hardest - router, store, filters)
- ⏳ NewChannelVersionPage.spec.js
Motivation: VTL provides better testing by querying the DOM as users interact with it, rather than relying on component internals. This improves test maintainability and aligns with best practices.
Approach:
- Converted VTU
mount()to VTLrender()with a wrapper component pattern for emitted event testing - Mocked
getRemoteChannelBundleByTokenbefore render usingjest.mock() - Replaced VTU-specific queries (
findComponent,trigger,wrapper.vm) with VTL DOM queries (getByRole,getByDisplayValue,fireEvent) - Used regex patterns for UI text matching to avoid translation string issues
- All 7 tests passing with no console warnings
References
- Fixes #14261 (Part 1: ChannelTokenModal migration - simplest file, no router/store)
- Related: PR #14563 (DeviceTransferModal migration - reference for patterns)
Reviewer guidance
Manual verification:
- ✅ All 7 tests pass locally:
pnpm run test-jest kolibri/plugins/device/frontend/views/__tests__/ChannelTokenModal.spec.js - ✅ No console warnings or deprecation notices
- ✅ Test patterns follow PR #14563 conventions
Testing approach:
- Cancel button click → emits cancel event
- Form validation → no errors on initial load, errors on empty submit/blur
- Successful token lookup → emits submit with token + channels payload
- 404 error → shows validation message "Check whether you entered token correctly"
- Network error (500) → shows ui-alert "Unable to connect to token"
Open question: None - simple migration with no complex dependencies.
AI usage
I used Claude AI as a learning tool and coding assistant during this VTL migration, but the approach, debugging, and refinement were my own work.
DISCLOSE — How I used AI:
- Discussed VTL migration strategy and patterns from PR #14563
- Got suggestions on VTL query methods (getByRole, fireEvent, waitFor)
- Debugged issues: fireEvent.change deprecated → use fireEvent.update()
ENGAGE CRITICALLY — What I verified:
- Analyzed original VTU test to ensure all test cases migrated
- Tested each batch locally (4 → 7 tests passing)
- Verified no console warnings or test failures
EDIT — Refinements I made:
- Changed wrapper component pattern after AI suggestion (more VTL-idiomatic)
- Replaced hardcoded strings with regex patterns for translation safety
- Organized commits logically (skeleton → validation → async)
PROCESS SHARING — My approach:
- Read old VTU test (understand coverage)
- Analyze source Vue component (understand behavior)
- Suggest VTL pattern to AI (get baseline)
- Debug failures myself (fireEvent.change warning)
- Test incrementally (7 tests in 3 commits)
- Follow PR #14563 conventions for consistency
This iterative approach helped me learn VTL patterns while maintaining code quality and GSoC integrity.
👋 Hi @soaebhasan12, thanks for contributing!
For the review process to begin, please verify that the following is satisfied:
-
[ ] Contribution is aligned with our contributing guidelines
-
[ ] Pull request description has correctly filled AI usage section & follows our AI guidance:
AI guidance
State explicitly whether you didn't use or used AI & how.
If you used it, ensure that the PR is aligned with Using AI as well as our DEEP framework. DEEP asks you:
- Disclose — Be open about when you've used AI for support.
- Engage critically — Question what is generated. Review code for correctness and unnecessary complexity.
- Edit — Review and refine AI output. Remove unnecessary code and verify it still works after your edits.
- Process sharing — Explain how you used the AI so others can learn.
Examples of good disclosures:
"I used Claude Code to implement the component, prompting it to follow the pattern in ComponentX. I reviewed the generated code, removed unnecessary error handling, and verified the tests pass."
"I brainstormed the approach with Gemini, then had it write failing tests for the feature. After reviewing the tests, I used Claude Code to generate the implementation. I refactored the output to reduce verbosity and ran the full test suite."
Also check that issue requirements are satisfied & you ran pre-commit locally.
Pull requests that don't follow the guidelines will be closed.
Reviewer assignment can take up to 2 weeks.
Build Artifacts
| Asset type | Download link |
|---|---|
| PEX file | kolibri-0.19.5.dev299_g1c0c2e4ab.d20260627.pex |
| Windows Installer (EXE) | kolibri-0.19.5.dev299+g1c0c2e4ab.d20260627-windows-setup-unsigned.exe |
| Debian Package | kolibri_0.19.5.dev299+g1c0c2e4ab-0ubuntu1_all.deb |
| Mac Installer (DMG) | kolibri-0.19.5.dev299+g1c0c2e4ab.d20260627.dmg |
| Android Package (APK) | kolibri-0.19.5.dev299+g1c0c2e4ab-0.2.0-debug.apk |
| Raspberry Pi Image | kolibri-pi-image-0.19.5.dev299+g1c0c2e4ab.zip |
| TAR file | kolibri-0.19.5.dev299+g1c0c2e4ab.d20260627.tar.gz |
| WHL file | kolibri-0.19.5.dev299+g1c0c2e4ab.d20260627-py3-none-any.whl |
Smoke test screenshot
👋 Hi @soaebhasan12, thanks for contributing!
For the review process to begin, please verify that the following is satisfied:
[ ] Contribution is aligned with our contributing guidelines
[ ] Pull request description has correctly filled AI usage section & follows our AI guidance:
AI guidance
State explicitly whether you didn't use or used AI & how. If you used it, ensure that the PR is aligned with Using AI as well as our DEEP framework. DEEP asks you:
- Disclose — Be open about when you've used AI for support.
- Engage critically — Question what is generated. Review code for correctness and unnecessary complexity.
- Edit — Review and refine AI output. Remove unnecessary code and verify it still works after your edits.
- Process sharing — Explain how you used the AI so others can learn.
Examples of good disclosures:
"I used Claude Code to implement the component, prompting it to follow the pattern in ComponentX. I reviewed the generated code, removed unnecessary error handling, and verified the tests pass."
"I brainstormed the approach with Gemini, then had it write failing tests for the feature. After reviewing the tests, I used Claude Code to generate the implementation. I refactored the output to reduce verbosity and ran the full test suite."
Also check that issue requirements are satisfied & you ran
pre-commitlocally.Pull requests that don't follow the guidelines will be closed.
Reviewer assignment can take up to 2 weeks.
Hey, verified everything locally:
- Followed the contributing guidelines
- Pre-commit passed all checks
- All 7 tests passing
For AI usage - I used Claude to understand VTL patterns and debug test issues. Reviewed the generated code against PR #14563, identified problems (like the linter rules), and fixed them myself. Ran tests multiple times to make sure everything works.
This completes the first file from issue #14261. Will start RearrangeChannelsPage next once this is reviewed.
📢✨ Before we assign a reviewer, we'll turn on @rtibblesbot to pre-review. Its comments are generated by an LLM, and should be evaluated accordingly.
Thanks for verifying @rtibblesbot @akolson @MisRob! All issues of ChannelTokenModal.spec.js are addressed.
Before we proceed to the next file, I wanted to clarify our approach for this issue #14261. Since we have 4 test files to migrate, we're doing this sequentially - one file per PR instead of all 4 in one large PR.
Next up is RearrangeChannelsPage.spec.js (Part 2/4), which is more complex because it involves:
- DragContainer and DragSortWidget component events (@sort, @moveUp, @moveDown)
- useUser and useSnackbar composable mocks
- Store injection
- Async operations and promise handling
We're using this sequential approach because:
- Easier to review - smaller changes are less overwhelming
- Faster feedback - if issues come up, they're isolated to one file
- Lower risk - bugs won't block all 4 files
- Better learning - each file teaches us patterns for the next one
- Stronger GSoC narrative - showing incremental progress with multiple merged PRs
This will be Part 2/4. Once this PR is approved and merged, we'll start Part 2 in a fresh branch.
LGTM, thanks a lot @soaebhasan12! For the following three files, please it'd be best if you can include all of them in the same PR. If it becomes too complex, you can also create a single commit per file so we can review commit by commit instead of multiple PRs. Also, on your new PR please mention that the first part was introduced in this PR. Thanks!
Thanks @AlexVelezLl Appreciate the approval and guidance.
I understand the feedback. For the remaining 3 files, I'll consolidate them into one PR with separate commits per file (RearrangeChannelsPage, AvailableChannelsPage, NewChannelVersionPage) so you can review commit-by-commit.
I'll mention that this is Part 2/4, continuing the work from this PR.
Should have it ready soon!
hello @AlexVelezLl @rtibblesbot
I'm migrating RearrangeChannelsPage.spec.js to VTL. Since DragContainer uses
@shopify/draggable (which doesn't work in jsdom), I mocked it with a simple stub
component that just renders its slot plus a button I can click to trigger the
sort event manually.
jest.mock('kolibri-common/components/sortable/DragContainer', () => ({
default: {
name: 'DragContainer',
props: ['items'],
template: `<div><button data-testid="trigger-sort" @click="...">...</button><slot /></div>`,
},
}));
The problem: when there are channels to show, nothing renders inside that mocked component — not even the channel names — and there's no error or warning in the console either. It just silently shows nothing. The empty-state case (no channels) works fine though.
I'm guessing it might have something to do with Draggable/DragHandle (the children inside DragContainer's slot) expecting something from the real DragContainer that my mock doesn't provide, but I'm not sure.
Any suggestions on how to approach mocking this component correctly?
Hi @AlexVelezLl,
Thank you again for all your help reviewing and merging this PR!
I have a quick, small request. I noticed that my assignee status was removed after the PR was merged. I'm currently trying to track my open-source contributions through GitHub's achievement badges (specifically the "Pull Shark" badge), and it seems GitHub might not be counting this PR towards my profile total since I am no longer listed as an assignee.
If it doesn't conflict with your repository's workflow or policies, would it be possible to add me back as an assignee here so GitHub registers the contribution?
I completely understand if that isn't possible for merged PRs—no worries at all if so. Thanks again for your time and guidance during the review process!