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

Closing controlled Popover by clicking on target fails in tests because event.isTrusted is false #6314

Open
snps-halkoaho opened this issue Aug 3, 2023 · 2 comments

Comments

@snps-halkoaho
Copy link

Hello, and thank you for the excellent library! I've found a problem that affects our tests. It's appeared recently and seems pretty straightforward.

Environment

  • Package version(s):
    "@blueprintjs/core": "^5.2.0",
    "@blueprintjs/datetime": "^5.0.8",
    "@blueprintjs/icons": "^5.1.5",
    "@blueprintjs/popover2": "^2.0.8",
  • Operating System: MacOS Ventura
  • Browser name and version: node

Steps to reproduce

  1. Write a test that tries to assert a controlled Popover closing on target click.

Actual behavior

Popover doesn't close.

Expected behavior

Popover closes and asserting that its contents disappeard passes.

Possible solution

I think the reason is this fix: #6092 .

e.isTrusted is false in tests (we are using Jest). This makes this.isSimulatedButtonClick(e); true, which makes Popover ignore the click when trying to close it. Maybe your own test runner makes "real" clicks?

@adidahiya
Copy link
Contributor

Maybe your own test runner makes "real" clicks?

Our testing suite uses both simulated and real click events. Is it possible to set the isTrusted property via Jest APIs?

@snps-halkoaho
Copy link
Author

snps-halkoaho commented Aug 28, 2023

@adidahiya As far as I understand, it's not possible to set isTrusted to be true in Jest.

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

No branches or pull requests

2 participants