|
1 | 1 | import { expect, test } from "../../../../fixtures/fixtures"; |
2 | | -import { adjustScreenView } from "../../../../helpers/ui/adjust-screen-view"; |
3 | | -import { awaitBootstrapTest } from "../../../../helpers/other/await-bootstrap-test"; |
4 | | -import { zoomOut } from "../../../../helpers/ui/zoom-out"; |
5 | | - |
6 | | -async function setupMockedChatFlow(page: any) { |
7 | | - await awaitBootstrapTest(page); |
8 | | - await page.waitForSelector('[data-testid="blank-flow"]', { timeout: 30000 }); |
9 | | - await page.getByTestId("blank-flow").click(); |
10 | | - |
11 | | - // Add ChatOutput |
12 | | - await page.getByTestId("sidebar-search-input").fill("chat output"); |
13 | | - await page.waitForSelector('[data-testid="input_outputChat Output"]', { |
14 | | - timeout: 30000, |
15 | | - }); |
16 | | - await page |
17 | | - .getByTestId("input_outputChat Output") |
18 | | - .hover() |
19 | | - .then(async () => { |
20 | | - await page.getByTestId("add-component-button-chat-output").click(); |
21 | | - }); |
22 | | - |
23 | | - await zoomOut(page, 2); |
24 | | - |
25 | | - // Add ChatInput via drag |
26 | | - await page.getByTestId("sidebar-search-input").fill("chat input"); |
27 | | - await page.waitForSelector('[data-testid="input_outputChat Input"]', { |
28 | | - timeout: 30000, |
29 | | - }); |
30 | | - await page |
31 | | - .getByTestId("input_outputChat Input") |
32 | | - .dragTo(page.locator('//*[@id="react-flow-id"]'), { |
33 | | - targetPosition: { x: 100, y: 100 }, |
34 | | - }); |
35 | | - |
36 | | - await adjustScreenView(page); |
37 | | - |
38 | | - await expect(page.locator(".react-flow__node")).toHaveCount(2, { |
39 | | - timeout: 10000, |
40 | | - }); |
41 | | - |
42 | | - // Connect ChatInput → ChatOutput |
43 | | - await page |
44 | | - .getByTestId("handle-chatinput-noshownode-chat message-source") |
45 | | - .click(); |
46 | | - await page |
47 | | - .getByTestId("handle-chatoutput-noshownode-inputs-target") |
48 | | - .click(); |
49 | | - |
50 | | - await expect(page.locator(".react-flow__edge")).toHaveCount(1, { |
51 | | - timeout: 8000, |
52 | | - }); |
53 | | - |
54 | | - // Mock the run endpoint so no real LLM call is made |
55 | | - await page.route("**/api/v1/run/**", async (route: import("@playwright/test").Route) => { |
56 | | - await route.fulfill({ |
57 | | - status: 200, |
58 | | - contentType: "application/json", |
59 | | - body: JSON.stringify({ |
60 | | - outputs: [ |
61 | | - { |
62 | | - outputs: [ |
63 | | - { results: { message: { text: "Mocked response" } } }, |
64 | | - ], |
65 | | - }, |
66 | | - ], |
67 | | - session_id: "mocked-session", |
68 | | - }), |
69 | | - }); |
| 2 | +import { setupPlayground } from "../../../../helpers/flows/setup-playground"; |
| 3 | + |
| 4 | +test.describe("Playground — Session ID input", () => { |
| 5 | + test.describe.configure({ mode: "serial" }); |
| 6 | + |
| 7 | + let createdFlowId: string | null = null; |
| 8 | + |
| 9 | + test.afterEach(async ({ page }) => { |
| 10 | + if (createdFlowId) { |
| 11 | + // Navigate to home before deleting to stop background browser requests |
| 12 | + // for the current flow; without this, pending polling GETs complete |
| 13 | + // after the DELETE and trigger spurious 404 fixture errors. |
| 14 | + await page.goto("/"); |
| 15 | + await page.request.delete(`/api/v1/flows/${createdFlowId}`); |
| 16 | + createdFlowId = null; |
| 17 | + } |
70 | 18 | }); |
71 | | -} |
72 | | - |
73 | | -test( |
74 | | - "playground opens with a chat input field after connecting ChatInput and ChatOutput", |
75 | | - { tag: ["@release", "@workspace", "@regression", "@playground"] }, |
76 | | - async ({ page }) => { |
77 | | - await setupMockedChatFlow(page); |
78 | | - |
79 | | - await page.getByTestId("playground-btn-flow-io").click(); |
80 | | - await page.waitForSelector('[data-testid="input-chat-playground"]', { |
81 | | - timeout: 15000, |
82 | | - }); |
83 | | - |
84 | | - const inputField = page.getByTestId("input-chat-playground").last(); |
85 | | - await expect(inputField).toBeVisible({ timeout: 5000 }); |
86 | | - await expect(inputField).toBeEnabled({ timeout: 3000 }); |
87 | | - }, |
88 | | -); |
89 | | - |
90 | | -test( |
91 | | - "playground session ID input accepts a custom session value", |
92 | | - { tag: ["@release", "@workspace", "@regression", "@playground"] }, |
93 | | - async ({ page }) => { |
94 | | - await setupMockedChatFlow(page); |
95 | | - |
96 | | - await page.getByTestId("playground-btn-flow-io").click(); |
97 | | - await page.waitForSelector('[data-testid="input-chat-playground"]', { |
98 | | - timeout: 15000, |
99 | | - }); |
100 | | - |
101 | | - const customSession = `session-${Date.now()}`; |
102 | | - |
103 | | - await page.getByTestId("popover-anchor-input-session_id").clear(); |
104 | | - await page.getByTestId("popover-anchor-input-session_id").fill(customSession); |
105 | | - await expect(page.getByTestId("popover-anchor-input-session_id")).toHaveValue(customSession); |
106 | | - }, |
107 | | -); |
108 | | - |
109 | | -test( |
110 | | - "changing session ID in playground resets the conversation history display", |
111 | | - { tag: ["@release", "@workspace", "@regression", "@playground"] }, |
112 | | - async ({ page }) => { |
113 | | - await setupMockedChatFlow(page); |
114 | | - |
115 | | - await page.getByTestId("playground-btn-flow-io").click(); |
116 | | - await page.waitForSelector('[data-testid="input-chat-playground"]', { |
117 | | - timeout: 15000, |
118 | | - }); |
119 | | - |
120 | | - await expect(page.getByTestId("input-chat-playground").last()).toBeVisible({ timeout: 5000 }); |
121 | | - |
122 | | - const sessionA = `session-a-${Date.now()}`; |
123 | | - await page.getByTestId("popover-anchor-input-session_id").clear(); |
124 | | - await page.getByTestId("popover-anchor-input-session_id").fill(sessionA); |
125 | | - await expect(page.getByTestId("popover-anchor-input-session_id")).toHaveValue(sessionA); |
126 | 19 |
|
127 | | - const sessionB = `session-b-${Date.now()}`; |
128 | | - await page.getByTestId("popover-anchor-input-session_id").clear(); |
129 | | - await page.getByTestId("popover-anchor-input-session_id").fill(sessionB); |
130 | | - await expect(page.getByTestId("popover-anchor-input-session_id")).toHaveValue(sessionB); |
131 | | - }, |
132 | | -); |
| 20 | + test( |
| 21 | + "session ID input accepts a custom value", |
| 22 | + { tag: ["@stable", "@release", "@regression", "@playground"] }, |
| 23 | + async ({ page }) => { |
| 24 | + await test.step("set up ChatInput → ChatOutput flow", async () => { |
| 25 | + createdFlowId = await setupPlayground(page); |
| 26 | + }); |
| 27 | + |
| 28 | + await test.step("open playground and wait for chat input", async () => { |
| 29 | + await page.getByTestId("playground-btn-flow-io").click(); |
| 30 | + await expect( |
| 31 | + page.getByTestId("input-chat-playground").last(), |
| 32 | + ).toBeVisible({ timeout: 15000 }); |
| 33 | + }); |
| 34 | + |
| 35 | + await test.step("fill session ID and confirm value persists", async () => { |
| 36 | + const customSession = `session-${Date.now()}`; |
| 37 | + const sessionInput = page.getByTestId( |
| 38 | + "popover-anchor-input-session_id", |
| 39 | + ); |
| 40 | + |
| 41 | + await sessionInput.clear(); |
| 42 | + await sessionInput.fill(customSession); |
| 43 | + await expect(sessionInput).toHaveValue(customSession); |
| 44 | + }); |
| 45 | + }, |
| 46 | + ); |
| 47 | +}); |
0 commit comments