palantir/blueprint

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

開放

#6,314 建立於 2023年8月3日

 (2 則留言) (0 個反應) (0 位負責人)TypeScript (2,167 個分叉)batch import
Domain: testingPackage: coreStatus: in discussionType: questionhelp wanted

倉庫指標

星標
 (20,263 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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: https://github.com/palantir/blueprint/pull/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?

貢獻者指南