Skip to content

Refactored the tests on fileUpoadItem.spec.js to Vue Testing Library …#6010

Open
harrisonoakess wants to merge 2 commits into
learningequality:unstablefrom
harrisonoakess:5811-fileuploaditem-vtl-tests
Open

Refactored the tests on fileUpoadItem.spec.js to Vue Testing Library …#6010
harrisonoakess wants to merge 2 commits into
learningequality:unstablefrom
harrisonoakess:5811-fileuploaditem-vtl-tests

Conversation

@harrisonoakess

Copy link
Copy Markdown

Summary

Refactored channelEdit/views/files/tests/fileUploadItem.spec.js to use Vue Testing Library (VTL). Tests are rewritten to reflect how a user interacts with the file upload feature rather than testing implementation details.

References

Closes #5811
Sub-issue of #5789

Reviewer guidance

Ran the docker instance and verified the upload process.
Ran 'pnpm test fileUploadItem' and passed 1/1 test suites and 9/9 tests in 2.5 s
Code changes should not affect UI, these changes are only tests
The tests make sure the upload files section works correctly. channels --> my channels --> click on the channel card or create a new channel) --> Add --> Upload files

AI usage

I used Claude Code for some code generation and final review. For the code I wrote, I had Claude Code review. For the code that Claude wrote, I reviewed the code, made edits, and removed excessive lines.

I am new to open-source contribution, so let me know if you have any suggestions.

@learning-equality-bot

Copy link
Copy Markdown

👋 Hi @harrisonoakess, 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 June 30, 2026 15:30
@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.

@rtibblesbot rtibblesbot left a comment

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.

Good VTL migration — correct imports, screen queries, jest-dom matchers, and userEvent throughout. One acceptance criterion is unmet (blocking), and the $trs pattern used elsewhere in the test suite isn't followed here.

Note: a pre-commit.ci lite auto-fix commit (8626be27) was pushed after the review passes ran and was not reviewed.

CI was pending at review time.

Findings:

  • blocking: PR description is missing a screenshot or screen recording (acceptance criterion #2 from #5811). The note "Ran the docker instance and verified the upload process" describes intent but doesn't satisfy the criterion — add an image or recording of the Files section in action.
  • important: Hard-coded English strings in getByText(…) calls — use FileUploadItem.$trs.key instead (see inline comments).
  • suggestion: getByRole('button') at line 105 has no name constraint — see inline comment.
  • suggestion: getByTestId('list-item') at line 195 — prefer an accessible query.
  • praise: The UploaderStub approach (lines 111–152) correctly exercises the uploadCompleteHandler guard via slot props rather than calling the handler directly — this catches a bug path the old test missed.

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

How was this generated?

Ran a phased review pipeline over the pull request diff:

  • Classified the diff to select review passes (core, frontend, backend) and whether manual QA was required
  • Core review pass checked correctness, design, architecture, testing, completeness, and DRY/SRP/Rule-of-Three principles
  • Specialized frontend/backend review passes applied framework-specific lenses where those files changed
  • For UI changes: manual QA and an accessibility audit against a live dev server, when available
  • Checked CI status and linked issue acceptance criteria
  • Synthesized one review from those passes and chose the verdict from the findings, CI status, and QA evidence

original_filename: 'file',
},
});
expect(screen.getByText('Unknown filename')).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.

important: The established repo pattern (see HintsEditor.spec.js) is to reference ComponentName.$trs.key in text queries rather than hard-coding English strings. FileUploadItem exposes these keys in its $trs object:

// instead of:
expect(screen.getByText('Unknown filename')).toBeInTheDocument();

// use:
expect(screen.getByText(FileUploadItem.$trs.unknownFile)).toBeInTheDocument();

Same applies to 'Upload failed' (line 82), 'Select file' (line 89), 'Replace file' / 'Download' / 'Remove' (lines 106–108). This way tests survive wording changes without breaking.

url: 'file-url',
},
});
await user.click(screen.getByRole('button'));

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: getByRole('button') without a { name: … } constraint will throw if the component or any child ever adds a second button in this state. Add an accessible name (or aria-label on the icon button in the component source):

await user.click(screen.getByRole('button', { name: /options/i }));

},
});

await user.click(screen.getByTestId('list-item'));

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: getByTestId is a last resort in VTL. In this render state the component shows a 'Select file' action (line 89 uses the same text) — prefer the visible element:

await user.click(screen.getByText(FileUploadItem.$trs.uploadButton));

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 file upload item unit tests to Vue Testing Library

3 participants