Skip to content

refactor TaskPanel and PinAuthenticationModal to use vue test library#14393

Open
curiouscoder-cmd wants to merge 2 commits intolearningequality:developfrom
curiouscoder-cmd:task-panel-vtl-test
Open

refactor TaskPanel and PinAuthenticationModal to use vue test library#14393
curiouscoder-cmd wants to merge 2 commits intolearningequality:developfrom
curiouscoder-cmd:task-panel-vtl-test

Conversation

@curiouscoder-cmd
Copy link
Contributor

Summary

  • Migrated the Device plugin test suites for PinAuthenticationModal and TaskPanel from @vue/test-utils to @testing-library/vue.
  • Replaced component-instance and snapshot-style assertions with DOM-based assertions that focus on user-visible behavior.
  • Updated the PIN modal tests to cover cancel, successful submit, incorrect PIN, non-numeric PIN, and empty PIN validation flows.
  • Updated the task panel tests to verify the canceled export workflows by checking the visible status/details and confirming resource totals are omitted.

Manual verification:

  • pnpm run test-jest -- kolibri/plugins/device/frontend/views/__tests__/PinAuthenticationModal.spec.js
  • pnpm run test-jest -- kolibri/plugins/device/frontend/views/ManageTasksPage/__tests__/TaskPanel.spec.js
  • pnpm run test-jest -- --testPathPattern device
  • pre-commit run --files kolibri/plugins/device/frontend/views/__tests__/PinAuthenticationModal.spec.js kolibri/plugins/device/frontend/views/ManageTasksPage/__tests__/TaskPanel.spec.js

References

Reviewer guidance

  • Review the two migrated test files only; the change is intentionally scoped to those files.
  • For PinAuthenticationModal, verify that the tests no longer reach into wrapper.vm, child component props, or @vue/test-utils, and instead assert through visible text, buttons, and emitted events.
  • For TaskPanel, verify that snapshots were replaced with explicit user-facing assertions for the canceled export cases.
  • Extra attention is worth giving to the async PIN submit flow and to the exact text matchers used for the canceled export task details.

AI usage

I used an AI tool minimally for small syntax and code-block fixes, and to help structure the PR description. I reviewed and edited the final code and wording myself, adjusted the queries to match the actual rendered DOM and verified the relevant tests locally.

@github-actions github-actions bot added APP: Device Re: Device App (content import/export, facility-syncing, user permissions, etc.) DEV: frontend SIZE: medium labels Mar 17, 2026
@learning-equality-bot
Copy link

👋 Thanks for contributing!

We will assign a reviewer within the next two weeks. In the meantime, please ensure that:

  • You ran pre-commit locally
  • All issue requirements are satisfied
  • The contribution is aligned with our Contributing guidelines. Pay extra attention to Using generative AI. Pull requests that don't follow the guidelines will be closed.

We'll be in touch! 😊

@github-actions
Copy link
Contributor

github-actions bot commented Mar 17, 2026

@curiouscoder-cmd
Copy link
Contributor Author

I notice that old tests were using toMatchSnapshot() which may generated TaskPanel.spec.js.snap file, but VTL focus on what user actually sees instead of saving big HTML files I replaced the snapshot logic with screen.getByText.
As the old snapshot file wasn't used anymore and it was causing warning so I delete it to keep the codebase clean.

I don't know if it's the preffered way , or let me know I will do as preferred. Thanks!

@learning-equality-bot
Copy link

📢✨ 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.

Copy link
Contributor

@rtibblesbot rtibblesbot left a comment

Choose a reason for hiding this comment

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

Clean migration from @vue/test-utils snapshots to @testing-library/vue behavioral assertions. CI passing.

  • praise: Snapshot removal in TaskPanel replaced with explicit, readable assertions that document actual component behavior
  • praise: PinAuthenticationModal tests use userEvent.type + screen.getByLabelText for realistic user interaction
  • suggestion: Minor — see inline comment about unused percentage field in TaskPanel fixture

@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?

Reviewed the pull request diff checking for:

  • Correctness: bugs, edge cases, undocumented behavior, resource leaks, hardcoded values
  • Design: unnecessary complexity, naming, readability, comment accuracy, redundant state
  • Architecture: duplicated concerns, minimal interfaces, composition over inheritance
  • Testing: behavior-based assertions, mocks only at hard boundaries, accurate coverage
  • Completeness: missing dependencies, unupdated usages, i18n, accessibility, security
  • Principles: DRY (same reason to change), SRP, Rule of Three (no premature abstraction)
  • Checked CI status and linked issue acceptance criteria
  • For UI changes: inspected screenshots for layout, visual completeness, and consistency

type: TaskTypes.DISKCONTENTEXPORT,
status: 'CANCELED',
clearable: true,
percentage: 1.0,
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: percentage: 1.0 was added to the fixture but isn't exercised by any assertion — the progress bar only renders when taskIsRunning (status RUNNING), so this field has no effect on the canceled-task output. Consider removing it to keep the fixture minimal, or if it's intentional, add a brief comment explaining why it's included.

expect(wrapper.emitted().submit).toEqual([[]]);
assertTextbox(wrapper, '', false);
});
it('emits submit when the user enters a valid PIN and submits', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

praise: Good pattern — using emitted() from the render return and waitFor for the async PIN validation flow is cleaner and more idiomatic than the old .then() chains with wrapper.vm access.

expect(screen.getByText(/started by 'tester'/i)).toBeInTheDocument();
expect(screen.getByRole('button', { name: /clear/i })).toBeInTheDocument();

expect(screen.getByText(/500 resources/i)).toBeInTheDocument();
Copy link
Contributor

Choose a reason for hiding this comment

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

praise: Asserting that resource totals are shown for canceled exports is more honest than the old snapshot, which had a misleading comment ("File size/resource numbers should not be shown for canceled exports") contradicted by its own snapshot output.

Copy link
Contributor

@rtibblesbot rtibblesbot left a comment

Choose a reason for hiding this comment

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

Clean test migration — prior suggestion resolved, no new issues.

Prior findings

Resolved:

  • Unused percentage field in TaskPanel fixture (suggestion) — removed in 9ed00bc16a

1/1 prior findings resolved.

CI passing. Test-only changes — Phase 3 skipped.

  • praise: See inline comment on TaskPanel assertions

@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?

Compared the current PR state against findings from a prior review:

  • Retrieved prior bot reviews deterministically via the GitHub API
  • Classified each prior finding as RESOLVED, UNADDRESSED, ACKNOWLEDGED, or CONTESTED
  • Only raised NEW findings for newly introduced code
  • Reviewed the pull request diff checking for correctness, design, architecture, testing, completeness, and adherence to DRY/SRP principles
  • Checked CI status and linked issue acceptance criteria

expect(screen.getByRole('button', { name: /clear/i })).toBeInTheDocument();

expect(screen.getByText(/500 resources/i)).toBeInTheDocument();
expect(screen.getByText(/\(5 KB\)/i)).toBeInTheDocument();
Copy link
Contributor

Choose a reason for hiding this comment

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

praise: Good verification that sizeText renders resource totals and human-readable file size for canceled exports — this correctly exercises the !taskIsCompleted template branch and catches the actual user-visible output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

APP: Device Re: Device App (content import/export, facility-syncing, user permissions, etc.) DEV: frontend SIZE: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate Device auth and task panel tests to Vue Testing Library

3 participants