-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The ProfileModal tests would sometimes fail with this error: ``` FAILED TESTS: ✖ "after each" hook for "shows modal on "openProfile" event" Chrome Headless 129.0.0.0 (Linux x86_64) Error: Failed to execute 'showModal' on 'HTMLDialogElement': The element is not in a Document. ``` The `HTMLDialogElement.showModal` call happens in an effect when the `ModalDialog` component is rendered with the `isClosed` prop set to false. In the ProfileModal tests, the component was rendered in a disconnected DOM node, so this error should have happened on every run. However the `emitter.publish("openProfile")` call which triggered this render was not wrapped in `act` and so the effect which calls `showModal` was scheduled, but often did not actually run before the component was unmounted in the `afterEach` hook. Fix the issue by: - Wrapping all `emitter.publish("openProfile")` calls in `act`, so they synchronously execute the effect. - Rendering the `ProfileModal` component in a connected DOM container which is removed after the test runs - For consistency, update the `NotebookModal` tests to work in the same way as the ProfileModal tests, with a single container element which is removed at the end of the test
- Loading branch information
1 parent
25b6147
commit 0340a9f
Showing
2 changed files
with
30 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters