Fix flakey ProfileModal tests
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
Showing
Please register or sign in to comment