• 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
..
anchoring Loading commit data...
components Loading commit data...
config Loading commit data...
integrations Loading commit data...
test Loading commit data...
util Loading commit data...
.eslintrc.cjs Loading commit data...
adder.tsx Loading commit data...
annotation-counts.ts Loading commit data...
bucket-bar-client.ts Loading commit data...
bucket-bar.tsx Loading commit data...
events.ts Loading commit data...
features.ts Loading commit data...
frame-observer.ts Loading commit data...
guest.ts Loading commit data...
highlight-clusters.tsx Loading commit data...
highlighter.ts Loading commit data...
hypothesis-injector.ts Loading commit data...
index.ts Loading commit data...
notebook.tsx Loading commit data...
outside-assignment-notice.tsx Loading commit data...
profile.tsx Loading commit data...
range-util.ts Loading commit data...
selection-observer.ts Loading commit data...
sidebar-trigger.ts Loading commit data...
sidebar.tsx Loading commit data...
toolbar.tsx Loading commit data...