feat: add empty state and expand overlay qa

This commit is contained in:
2026-03-19 19:00:36 +08:00
parent f318f94c9a
commit 132bb6961d
20 changed files with 1094 additions and 6 deletions
@@ -16,6 +16,24 @@ import {
} from "@ai-ui/ui";
import type { Meta, StoryObj } from "@storybook/react";
async function waitForCondition(
predicate: () => boolean,
message: string,
timeoutMs = 1500
) {
const startedAt = Date.now();
while (Date.now() - startedAt < timeoutMs) {
if (predicate()) {
return;
}
await new Promise((resolve) => window.setTimeout(resolve, 16));
}
throw new Error(message);
}
type ReleaseMenuProps = {
triggerLabel?: string;
};
@@ -80,7 +98,38 @@ export default meta;
type Story = StoryObj<typeof meta>;
export const Playground: Story = {
render: () => <ReleaseMenu />
render: () => <ReleaseMenu />,
play: async ({ canvasElement }) => {
const trigger = [...canvasElement.querySelectorAll("button")].find((element) =>
element.textContent?.includes("Open menu")
);
if (!(trigger instanceof HTMLButtonElement)) {
throw new Error("Expected the dropdown trigger to render.");
}
trigger.click();
await waitForCondition(
() => document.body.querySelector('[role="menu"]') instanceof HTMLElement,
"Expected the dropdown menu to open."
);
const item = [...document.body.querySelectorAll('[role="menuitem"]')].find((element) =>
element.textContent?.includes("Review summary")
);
if (!(item instanceof HTMLElement)) {
throw new Error("Expected the Review summary item to render.");
}
item.click();
await waitForCondition(
() => document.body.querySelector('[role="menu"]') === null,
"Expected the dropdown menu to close after selection."
);
}
};
export const States: Story = {