Skip to content

Commit e4e0686

Browse files
committed
fix playwright tests on windows
1 parent b9022d9 commit e4e0686

4 files changed

Lines changed: 45 additions & 4 deletions

File tree

src/frontend/tests/core/features/publish-flow.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,13 @@ test(
6565

6666
await page.getByTestId("shareable-playground").click();
6767
const newPage = await pagePromise;
68-
await newPage.waitForTimeout(3000);
68+
await newPage.waitForLoadState("domcontentloaded");
69+
// Wait for the chat input to actually be present before filling. The
70+
// default actionTimeout (20s) was not enough on Windows CI for the
71+
// shareable-playground page to mount the message input.
72+
await newPage
73+
.getByPlaceholder("Send a message...")
74+
.waitFor({ state: "visible", timeout: 60000 });
6975
const newUrl = newPage.url();
7076
await newPage.getByPlaceholder("Send a message...").fill("Hello");
7177
await newPage.getByTestId("button-send").last().click();

src/frontend/tests/core/features/right-click-dropdown.spec.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,17 @@ test(
1515

1616
await page.getByTestId("template-get-started-card-basic-prompting").click();
1717

18-
// Wait for the flow to load
18+
// Wait for the flow to load. 3s was not enough on slower runners
19+
// (Windows CI): the sidebar input briefly resolves as visible but the
20+
// canvas template is still mounting, and waitForSelector observes the
21+
// input being re-mounted and times out. Wait for the canvas controls
22+
// to settle (the same gate other tests use after opening a template),
23+
// then verify the sidebar input.
24+
await page.waitForSelector('[data-testid="canvas_controls_dropdown"]', {
25+
timeout: 60000,
26+
});
1927
await page.waitForSelector('[data-testid="sidebar-search-input"]', {
20-
timeout: 3000,
28+
timeout: 30000,
2129
});
2230

2331
// Test 1: Right-click on Chat Input component should open dropdown immediately (single click)

src/frontend/tests/core/features/shareable-playground-auth.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ async function setupShareablePlayground(page: any, context: any): Promise<any> {
4141
* Uses the same pattern as publish-flow.spec.ts (Stop button lifecycle).
4242
*/
4343
async function sendAndWaitForResponse(playgroundPage: any, message: string) {
44+
// Wait for the chat input to be present. The default actionTimeout (20s)
45+
// was not enough on Windows CI for the shareable-playground page to mount
46+
// the message input.
47+
await playgroundPage
48+
.getByPlaceholder("Send a message...")
49+
.waitFor({ state: "visible", timeout: 60000 });
4450
await playgroundPage.getByPlaceholder("Send a message...").fill(message);
4551
await playgroundPage.getByTestId("button-send").last().click();
4652

@@ -93,6 +99,10 @@ test(
9399

94100
const playgroundPage = await setupShareablePlayground(page, context);
95101

102+
// Wait for the chat input to be present (Windows CI is slow to mount it).
103+
await playgroundPage
104+
.getByPlaceholder("Send a message...")
105+
.waitFor({ state: "visible", timeout: 60000 });
96106
await playgroundPage
97107
.getByPlaceholder("Send a message...")
98108
.fill("Tell me a short joke");

src/frontend/tests/core/unit/fileUploadComponent.spec.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,19 @@ test(
329329
return data;
330330
}, newTxtFile);
331331

332-
// Trigger drag events
332+
// Trigger drag events. We wait for the POST /files response so that
333+
// the optimistic "temp" cache entry has been replaced with the real
334+
// server path before we close the modal. On slower runners (Windows
335+
// CI), closing the modal before the cache settles causes the new
336+
// file's server path to be missing from useGetFilesV2 when the
337+
// parent node re-renders, so the file never appears in the node.
338+
const uploadResponsePromise = page.waitForResponse(
339+
(response) =>
340+
response.url().includes("/api/v2/files") &&
341+
response.request().method() === "POST" &&
342+
response.status() === 201,
343+
{ timeout: 30000 },
344+
);
333345
await page.dispatchEvent(
334346
'[data-testid="drag-files-component"]',
335347
"dragover",
@@ -340,6 +352,7 @@ test(
340352
await page.dispatchEvent('[data-testid="drag-files-component"]', "drop", {
341353
dataTransfer,
342354
});
355+
await uploadResponsePromise;
343356
await expect(page.getByText(`${newTxtFile}.txt`).last()).toBeVisible({
344357
timeout: 10000,
345358
});
@@ -348,6 +361,10 @@ test(
348361
page.getByTestId(`checkbox-${newTxtFile}`).last(),
349362
).toHaveAttribute("data-state", "checked", { timeout: 10000 });
350363

364+
// Wait for any in-flight files refetch triggered by the upload's
365+
// onSettled invalidate before closing the modal.
366+
await page.waitForLoadState("networkidle");
367+
351368
await page.getByTestId("select-files-modal-button").click();
352369
await expect(page.getByText(`${renamedJsonFile}.txt`).first()).toBeHidden(
353370
{

0 commit comments

Comments
 (0)