-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.ts
More file actions
31 lines (27 loc) · 892 Bytes
/
utils.ts
File metadata and controls
31 lines (27 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { Page } from "@playwright/test";
import { StoryObj } from "@storybook/react";
export const filterStories = (stories: StoryObj[]): StoryObj[] =>
stories.filter((story) => story?.tags?.includes("visual:check"));
export function getStoryUrl(storybookUrl: string, id: string): string {
const params = new URLSearchParams({
id,
viewMode: "story",
nav: "0",
});
return `${storybookUrl}/iframe.html?${params.toString()}`;
}
export async function navigate(
page: Page,
storybookUrl: string,
id: string
): Promise<void> {
try {
const url = getStoryUrl(storybookUrl, id);
await page.goto(url);
await page.waitForLoadState("networkidle");
await page.waitForSelector("#storybook-root", { timeout: 5000 });
} catch (error) {
console.log(error);
// Handle error here in cases where the above times out due to 404's and other factors.
}
}