forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshared-state-read.spec.ts
More file actions
63 lines (57 loc) · 2.04 KB
/
Copy pathshared-state-read.spec.ts
File metadata and controls
63 lines (57 loc) · 2.04 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { test, expect } from "@playwright/test";
// Shared State (Reading) — Recipe Editor demo. The page publishes
// `agent.state.recipe` via `agent.setState`; the agent reads (but does
// not mutate) that recipe on every turn. Spec mirrors the QA contract
// in qa/shared-state-read.md and the testids exposed by recipe-card.tsx.
test.describe("Shared State (Reading)", () => {
test.beforeEach(async ({ page }) => {
await page.goto("/demos/shared-state-read");
});
test("recipe card loads with default ingredients and the sidebar mounts", async ({
page,
}) => {
await expect(page.locator('[data-testid="recipe-card"]')).toBeVisible({
timeout: 15000,
});
await expect(page.getByText("AI Recipe Assistant")).toBeVisible({
timeout: 10000,
});
await expect(
page.locator('[data-testid="ingredients-container"]'),
).toBeVisible();
await expect(
page.locator('[data-testid="instructions-container"]'),
).toBeVisible();
});
test("starter suggestions render", async ({ page }) => {
for (const title of [
"Create Italian recipe",
"Make it healthier",
"Suggest variations",
]) {
await expect(page.getByRole("button", { name: title })).toBeVisible({
timeout: 15000,
});
}
});
test("clicking 'Add Ingredient' appends a new ingredient-card row", async ({
page,
}) => {
const ingredientCards = page.locator('[data-testid="ingredient-card"]');
const initialCount = await ingredientCards.count();
await page.locator('[data-testid="add-ingredient-button"]').click();
await expect(ingredientCards).toHaveCount(initialCount + 1, {
timeout: 5000,
});
});
test("sending a sidebar message returns an assistant response", async ({
page,
}) => {
const input = page.getByPlaceholder("Type a message");
await input.fill("What recipe am I making?");
await input.press("Enter");
await expect(
page.locator('[data-testid="copilot-assistant-message"]').first(),
).toBeVisible({ timeout: 30000 });
});
});