Skip to content

[Remove Vuetify from Studio] Convert supplementary item unit tests to Vue Testing Library#5937

Open
sharma-anushka wants to merge 2 commits into
learningequality:unstablefrom
sharma-anushka:refactor/supplementary-item-vtl
Open

[Remove Vuetify from Studio] Convert supplementary item unit tests to Vue Testing Library#5937
sharma-anushka wants to merge 2 commits into
learningequality:unstablefrom
sharma-anushka:refactor/supplementary-item-vtl

Conversation

@sharma-anushka
Copy link
Copy Markdown
Contributor

Summary

Refactor channelEdit/views/files/tests/supplementaryItem.spec.js test suite to use Vue Testing Library (VTL)

Important note

Removed: uploadingHandler test - was implementation-detail focused and doesn't translate to VTL's user-behavior model. Covered by 'uploading should be true if progress < 1' test instead.

References

closes #5791

Reviewer guidance

Ran pnpm test channelEdit/views/files/__tests__/supplementaryItem.spec.js

image

AI usage

I used AI to migrate tests, however all changes were carefully reviewed.

@learning-equality-bot
Copy link
Copy Markdown

👋 Hi @sharma-anushka, 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.

@akolson akolson requested a review from rtibblesbot May 25, 2026 11:16
@learning-equality-bot
Copy link
Copy Markdown

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

Migration is mostly clean, but the uploadCompleteHandler test needs to be removed before merge.

CI failures are at the "Use Node.js" infrastructure step and are not caused by this PR. No UI files changed — Phase 3 skipped.

  • blocking: uploadCompleteHandler test is a tautology — see inline
  • suggestion: document.querySelector on lines 58 and 69 — see inline
  • praise: Clean VTL migration — see inline

@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

await wrapper.setProps({ uploadCompleteHandler });
wrapper.findComponent(Uploader).vm.uploadCompleteHandler({ id: 'file1' });
renderComponent({ uploadCompleteHandler });
uploadCompleteHandler({ id: 'file1' });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

blocking: This test is a tautology — it calls the mock directly (uploadCompleteHandler({ id: 'file1' })) and then asserts the mock was called. The component is not involved at all: removing :uploadCompleteHandler="uploadCompleteHandler" from SupplementaryItem.vue would not cause this test to fail.

Like the uploadingHandler test that was correctly removed, this test cannot be meaningfully migrated to VTL's user-behavior model (there's no user gesture that triggers upload completion). Remove it rather than keep dead coverage.

expect(testwrapper.findComponent('[data-test="uploading"]').exists()).toBe(true);
it('uploading should be true if progress < 1', () => {
renderComponent({ progress: 0.5 });
expect(document.querySelector('[data-test="uploading"]')).toBeInTheDocument();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion: Use screen.queryByTestId('uploading') instead of document.querySelector('[data-test="uploading"]'). The acceptance criteria require screen queries, and screen methods give better failure messages (they report what was in the DOM when the element wasn't found). Same pattern applies on line 69 — use screen.getByTestId('remove') as the click target.

const wrapper = makeWrapper({ id: 'test-remove' });
await wrapper.findComponent('[data-test="remove"]').trigger('click');
expect(wrapper.emitted('remove')[0][0]).toBe('test-remove');
const user = userEvent.setup();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

praise: Using userEvent.setup() + user.click() here is correct VTL practice — it dispatches real pointer and keyboard events rather than a synthetic trigger, giving more realistic interaction coverage.

@learning-equality-bot
Copy link
Copy Markdown

👋 Hi @sharma-anushka, 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.

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.

Convert supplementary item unit tests to Vue Testing Library

2 participants