Skip to content

Commit

Permalink
Fix play tests
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic committed Feb 3, 2023
1 parent 2ef671e commit 2c2740e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
23 changes: 14 additions & 9 deletions code/ui/components/src/tabs/tabs.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect } from '@storybook/jest';
import type { Key } from 'react';
import React, { Fragment } from 'react';
import { action } from '@storybook/addon-actions';
Expand Down Expand Up @@ -199,15 +200,19 @@ export const StatefulDynamicWithOpenTooltip = {
},
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
await new Promise((res) =>
// The timeout is necessary to wait for Storybook to adjust the viewport
setTimeout(async () => {
const addonsTab = canvas.getByText('Addons');
fireEvent(addonsTab, new MouseEvent('mouseenter', { bubbles: true }));
await waitFor(() => screen.getByTestId('tooltip'));
res(undefined);
}, 500)
);

await waitFor(async () => {
await expect(canvas.getAllByRole('tab')).toHaveLength(3);
await expect(canvas.getByRole('tab', { name: /Addons/ })).toBeInTheDocument();
});

const addonsTab = await canvas.findByRole('tab', { name: /Addons/ });

await waitFor(async () => {
await fireEvent(addonsTab, new MouseEvent('mouseenter', { bubbles: true }));
const tooltip = await screen.getByTestId('tooltip');
await expect(tooltip).toBeInTheDocument();
});
},
render: (args) => (
<TabsState initial="test1" {...args}>
Expand Down
2 changes: 1 addition & 1 deletion code/ui/components/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"types": ["react-syntax-highlighter", "jest"]
"types": ["react-syntax-highlighter", "jest", "testing-library__jest-dom"]
},
"include": ["src/**/*"]
}

0 comments on commit 2c2740e

Please sign in to comment.