• Robert Knight's avatar
    Fix flakey ProfileModal tests · 0340a9f1
    Robert Knight authored
    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
    0340a9f1
Name
Last commit
Last update
.github Loading commit data...
.yarn Loading commit data...
bin Loading commit data...
dev-server Loading commit data...
docs Loading commit data...
embedding-examples Loading commit data...
images Loading commit data...
requirements Loading commit data...
scripts Loading commit data...
src Loading commit data...
.babelrc Loading commit data...
.eslintignore Loading commit data...
.eslintrc Loading commit data...
.gitignore Loading commit data...
.npmignore Loading commit data...
.prettierignore Loading commit data...
.python-version Loading commit data...
.readthedocs.yaml Loading commit data...
.yarnrc.yml Loading commit data...
HACKING.md Loading commit data...
LICENSE Loading commit data...
Makefile Loading commit data...
README.md Loading commit data...
codecov.yml Loading commit data...
gulpfile.js Loading commit data...
package.json Loading commit data...
rollup-boot.config.js Loading commit data...
rollup-tests.config.js Loading commit data...
rollup.config.js Loading commit data...
tailwind-annotator.config.js Loading commit data...
tailwind-sidebar.config.js Loading commit data...
tailwind.config.js Loading commit data...
tox.ini Loading commit data...
tsconfig.json Loading commit data...
yarn.lock Loading commit data...