Skip to content

Commit c057acf

Browse files
committed
Fix playwright
1 parent 17ce780 commit c057acf

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

tests/trace-loading.spec.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1-
import { test, expect } from "@playwright/test";
1+
import { test, expect, Page } from "@playwright/test";
22
import { FIXTURES, getFixturePath } from "./utils/fixtures";
33

4+
/**
5+
* Upload a file using the file chooser dialog.
6+
* react-dropzone's hidden input doesn't respond to Playwright's setInputFiles,
7+
* so we click the "Upload file" button and use the file chooser event instead.
8+
*/
9+
async function uploadFile(page: Page, filePath: string) {
10+
const uploadButton = page.getByRole("button", { name: "Upload file" });
11+
await expect(uploadButton).toBeVisible({ timeout: 5000 });
12+
13+
const [fileChooser] = await Promise.all([page.waitForEvent("filechooser"), uploadButton.click()]);
14+
await fileChooser.setFiles(filePath);
15+
}
16+
417
test.describe("Trace file loading", () => {
518
test("should load io-trace-output.log without crashing", async ({ page }) => {
619
await page.goto("/", { waitUntil: "domcontentloaded" });
720
await page.evaluate(() => window.localStorage.clear());
821

9-
const fileInput = page.locator('input[type="file"]');
1022
const tracePath = getFixturePath(FIXTURES.IO_TRACE_OUTPUT);
11-
12-
await fileInput.setInputFiles(tracePath);
23+
await uploadFile(page, tracePath);
1324

1425
// Wait for load button to be ready instead of fixed timeout
1526
const loadButton = page.getByTestId("load-button");
@@ -44,14 +55,13 @@ test.describe("Trace file loading", () => {
4455
await page.goto("/", { waitUntil: "domcontentloaded" });
4556
await page.evaluate(() => window.localStorage.clear());
4657

47-
const fileInput = page.locator('input[type="file"]');
4858
const tracePath = getFixturePath(FIXTURES.IO_TRACE_OUTPUT);
49-
50-
await fileInput.setInputFiles(tracePath);
59+
await uploadFile(page, tracePath);
5160

5261
// Wait for load button to be ready
5362
const loadButton = page.getByTestId("load-button");
5463
await expect(loadButton).toBeVisible({ timeout: 5000 });
64+
await expect(loadButton).toBeEnabled({ timeout: 5000 });
5565
await loadButton.click();
5666

5767
// Wait for program status to appear

0 commit comments

Comments
 (0)