canonical / react-components

A set of components based on Vanilla Framework
https://canonical.github.io/react-components
95 stars 51 forks source link

Tooltip tests occasionally fail #988

Open bartaz opened 11 months ago

bartaz commented 11 months ago

Tooltips tests fail from time to time. It's hard to reproduce as it doesn't happen in deterministic way.

The error when it happens is:

  ● Tooltip › updates the tooltip to fit on the screen

    expect(element).toHaveClass("p-tooltip--btm-left")

    Expected the element to have class:
      p-tooltip--btm-left
    Received:
      p-tooltip--right is-detached

      153 |     await userEvent.hover(screen.getByRole("button", { name: "Child" }));
      154 |
    > 155 |     expect(screen.getByTestId("tooltip-portal")).toHaveClass(
          |                                                  ^
      156 |       "p-tooltip--btm-left"
      157 |     );
      158 |     expect(screen.getByTestId("tooltip-portal")).toHaveClass("is-detached");

      at src/components/Tooltip/Tooltip.test.tsx:155:50
      at fulfilled (src/components/Tooltip/Tooltip.test.tsx:28:58)

There seems to be some bug or race condition either in the Tooltip component or its test suite.