|
| 1 | +import { expect, test } from "@playwright/test"; |
| 2 | +import path from "node:path"; |
| 3 | + |
| 4 | +test("uploads a PDF to a new workspace and completes extraction", async ({ |
| 5 | + page, |
| 6 | +}) => { |
| 7 | + test.setTimeout(240_000); |
| 8 | + const workspaceName = `Toast sandwich ${Date.now()}`; |
| 9 | + const filename = "toast_sandwich_en_wiki.pdf"; |
| 10 | + |
| 11 | + await page.goto("/workspaces"); |
| 12 | + await page.getByPlaceholder("Username", { exact: true }).fill("genesis-e2e"); |
| 13 | + await page |
| 14 | + .getByPlaceholder("Password", { exact: true }) |
| 15 | + .fill("Genesis-e2e-password"); |
| 16 | + await page.getByRole("button", { name: "Login", exact: true }).click(); |
| 17 | + |
| 18 | + await page |
| 19 | + .getByRole("button", { name: "New Workspace", exact: true }) |
| 20 | + .click(); |
| 21 | + await page.getByPlaceholder("Name", { exact: true }).fill(workspaceName); |
| 22 | + await page.getByRole("button", { name: "Create", exact: true }).click(); |
| 23 | + await expect( |
| 24 | + page.getByRole("heading", { name: workspaceName }), |
| 25 | + ).toBeVisible(); |
| 26 | + |
| 27 | + await page |
| 28 | + .getByRole("button", { name: "Upload to workspace", exact: true }) |
| 29 | + .click(); |
| 30 | + const fileChooser = page.waitForEvent("filechooser"); |
| 31 | + await page.getByRole("button", { name: "Add Files", exact: true }).click(); |
| 32 | + await (await fileChooser).setFiles(path.join(__dirname, filename)); |
| 33 | + await page.getByRole("button", { name: "Upload", exact: true }).click(); |
| 34 | + // Use the upload form's completion button, not the modal's corner dismiss. |
| 35 | + await page |
| 36 | + .locator("form") |
| 37 | + .getByRole("button", { name: "Close", exact: true }) |
| 38 | + .click(); |
| 39 | + |
| 40 | + const fileRow = page.getByRole("row").filter({ |
| 41 | + has: page.getByText(filename, { exact: true }), |
| 42 | + }); |
| 43 | + await expect(fileRow).toBeVisible(); |
| 44 | + |
| 45 | + // A vanished spinner alone is insufficient: wait for either terminal icon, |
| 46 | + // then require the document icon so an extraction error cannot count as success. |
| 47 | + // The selectors correspond to Workspaces.renderIcon's processed/failed cases. |
| 48 | + await expect( |
| 49 | + fileRow.locator( |
| 50 | + "svg.file-browser__icon, i.exclamation.triangle.file-browser__icon", |
| 51 | + ), |
| 52 | + ).toBeVisible({ timeout: 180_000 }); |
| 53 | + await expect(fileRow.locator("svg.file-browser__icon")).toBeVisible(); |
| 54 | + await expect(fileRow.locator(".loader.file-browser__icon")).toHaveCount(0); |
| 55 | + await expect(fileRow.getByText("processed", { exact: true })).toBeVisible(); |
| 56 | +}); |
0 commit comments