Skip to content
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

Test flake: Tests for useClipboard don't consistently flush state changes #13240

Closed
Parkreiner opened this issue May 10, 2024 · 0 comments · Fixed by #13250
Closed

Test flake: Tests for useClipboard don't consistently flush state changes #13240

Parkreiner opened this issue May 10, 2024 · 0 comments · Fixed by #13250
Assignees
Labels
flake Flaky tests site Area: frontend dashboard

Comments

@Parkreiner
Copy link
Contributor

Parkreiner commented May 10, 2024

Issue

Notes

  • Inclined to believe that the issue is with the test, rather than the functionality, because while the test is new, the functionality has mostly been unchanged since it was first created over a year ago
  • Testing clipboard functionality is weird in general, so depending on what's found after digging, it might be better to make some E2E tests instead
    • Though obviously it'd be better to have a single test for the clipboard, rather than needing to have ad-hoc tests for everything that just happens to use the clipboard
    • The main issue is that React Testing Library will inject a clipboard mock the moment you try to set up any kind of user session with user.setup. This is great most of the time, but the problem is that the clipboard always succeeds, and there's no way to remove the mock. Once there's a single setup, the entire test is basically "tainted" with false positives
    • Because the tests actually need to verify that the fallback functionality works when a clipboard isn't available on HTTP-only connection, we can't use user.setup at all
@Parkreiner Parkreiner self-assigned this May 10, 2024
@coder-labeler coder-labeler bot added flake Flaky tests site Area: frontend dashboard labels May 10, 2024
@Parkreiner Parkreiner changed the title Test flake: useClipboard doesn't consistently apply state changes Test flake: Tests for useClipboard don't consistently flush state changes May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flake Flaky tests site Area: frontend dashboard
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant