Skip to content

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

Closed
@Parkreiner

Description

@Parkreiner

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

Metadata

Metadata

Assignees

Labels

siteArea: frontend dashboard

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions