Ctrl K
ComunidadGuías…

e2e/zzzzz-workflow-polish.spec.ts

Rama main · réplica de lectura del repositorio original.

Archivo original ↗Preguntar a KiBot
import { openPartFilters, openPartStockMatch, clickProjectAction, openProjectSection, navigateWorkspace } from "./workspace-controls";
import { expect, test, type Page } from "@playwright/test";
async function login(page: Page) { await page.goto("/"); await page.getByLabel("Workspace password").fill("demo-password-please-change"); await page.getByRole("button", { name: "Sign in", exact: true }).click(); await expect(page.getByRole("heading", { name: "Projects", exact: true })).toBeVisible(); }
const nav = navigateWorkspace;
async function findProject(page: Page, query: string) {
  await page.getByLabel("Find a project").fill(query);
}
async function create(page: Page, name: string) { await clickProjectAction(page, "New project"); await page.getByLabel("Project name", { exact: true }).fill(name); await page.getByLabel("Project goal", { exact: true }).fill("Synthetic workflow acceptance."); await page.getByRole("button", { name: "Create project", exact: true }).click(); await expect(page.getByRole("heading", { name, exact: true })).toBeVisible(); }
for (const width of [1440, 1024, 320]) test(`home supports finding, pinning and resuming projects at ${width}px`, async ({ page }) => {
  await page.setViewportSize({ width, height: 900 }); await login(page);
  const name = `Polish sensor ${width}`; await create(page, name); await nav(page, "Projects");
  await findProject(page, name); await expect(page.locator(".home-project-row")).toHaveCount(1);
  await page.getByRole("button", { name: "Filters and view options", exact: true }).click();
  await page.getByRole("button", { name: `Pin project ${name}`, exact: true }).click(); await page.reload();
  await page.getByRole("button", { name: "Filters and view options", exact: true }).click();
  await page.getByLabel("Filter projects", { exact: true }).selectOption("pinned"); await expect(page.locator(".home-project-row")).toHaveCount(1);
  await page.getByRole("button", { name: `Open project ${name}`, exact: true }).click(); await expect(page.getByRole("heading", { name, exact: true })).toBeVisible();
  await nav(page, "Projects"); await expect(page.getByRole("region", { name: "Resume recent project" })).toContainText(name);
  await page.getByRole("button", { name: "Resume project", exact: true }).click(); await expect(page.getByRole("heading", { name, exact: true })).toBeVisible();
  await nav(page, "Projects"); await findProject(page, "not-a-project"); await expect(page.getByText("No projects match this view", { exact: true })).toBeVisible();
  await page.getByRole("button", { name: "Clear filters", exact: true }).click(); expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true);
});
test("home attention opens the selected stock check and leaves archive view", async ({ page }) => {
  await login(page);
  const csrf = (await page.context().cookies()).find((cookie) => cookie.name === "forge_csrf")?.value;
  expect(csrf).toBeTruthy();
  const seeded = await page.request.post("/api/v1/inventory", { headers: { "X-CSRF-Token": csrf! }, data: { name: "Polish uncertain connector", kind: "electronic", quantity: 1, unit: "each", tags: [], links: [], evidence: { state: "delivered_uncounted" } } });
  expect(seeded.status()).toBe(201); await page.reload(); await create(page, "Polish check pointer");
  await openProjectSection(page, "Parts");
  await page.locator(".bom-section").getByRole("button", { name: "Add first part", exact: true }).click();
  await page.getByLabel("Part name", { exact: true }).fill("Check connector");
  await openPartStockMatch(page); await page.getByRole("button", { name: "Find a different owned item" }).click();
  await page.getByLabel("Search matching inventory").fill("Polish uncertain connector");
  await page.getByRole("button", { name: "Choose owned item Polish uncertain connector", exact: true }).click();
  await page.getByRole("button", { name: "Add part", exact: true }).click();
  await nav(page, "Projects"); await page.getByRole("button", { name: "Archived", exact: true }).click();
  await page.getByRole("button", { name: "All next actions", exact: true }).click();
  const queue = page.getByRole("region", { name: "Workspace attention queue" }); await queue.getByLabel("Filter attention queue").selectOption("check");
  await queue.getByRole("button", { name: "Check stock: Polish check pointer", exact: true }).click();
  await expect(page.getByRole("heading", { name: "Polish check pointer", exact: true })).toBeVisible();
  await openPartFilters(page);
  await expect(page.getByLabel("Filter project requirements")).toHaveValue("check");
  await expect(page.locator(".bom-row")).toHaveCount(1); await expect(page.locator(".bom-row")).toContainText("Check connector");
});
test("build planning is a direct route and import opens an isolated dialog", async ({ page }) => {
  await login(page); await create(page, "Polish build route");
  await page.getByRole("tab", { name: "Build", exact: true }).click(); await expect(page).toHaveURL(/\/build$/u);
  await expect(page.getByRole("heading", { name: "Build plan", exact: true })).toBeVisible(); await expect(page.getByRole("button", { name: "Task groups and progress", exact: true })).toHaveAttribute("aria-expanded", "false"); await expect(page.getByRole("button", { name: /Parts and print plates/u })).toHaveAttribute("aria-expanded", "false"); await page.reload();
  await expect(page.getByRole("tab", { name: "Build", exact: true })).toHaveAttribute("aria-selected", "true");
  await page.getByRole("tab", { name: /^Parts/u }).click(); await page.getByRole("button", { name: "Import parts list", exact: true }).click();
  await expect(page.getByRole("dialog", { name: "Import requirements from CSV", exact: true })).toBeVisible(); await expect(page.locator(".app-background")).toHaveAttribute("aria-hidden", "true"); await expect(page.locator(".skip-link")).toHaveAttribute("inert", ""); await expect(page.getByLabel("Requirements CSV text", { exact: true })).toBeFocused();
  await page.keyboard.press("Escape"); await expect(page.getByRole("dialog")).toHaveCount(0);
  await nav(page, "Projects"); await page.getByRole("button", { name: "Workspace tools", exact: true }).click(); await page.getByRole("button", { name: "Import requirements", exact: true }).click(); await expect(page.getByRole("dialog", { name: "Guided project setup", exact: true })).toBeVisible();
});
test("supplier quote entry is visible before legacy offers", async ({ page }) => {
  await login(page); await create(page, "Polish supplier entry");
  await openProjectSection(page, "Parts");
  await page.getByRole("button", { name: "Add first part", exact: true }).click(); await page.getByLabel("Part name", { exact: true }).fill("Polish bracket"); await page.getByRole("button", { name: "Add part", exact: true }).click();
  await openProjectSection(page, "To source");
  await expect(page.getByRole("heading", { name: "Supplier quotes for this project", exact: true })).toBeVisible();
  await page.getByRole("button", { name: "Record quote for Polish bracket", exact: true }).click();
  await expect(page.getByLabel("Supplier", { exact: true })).toBeVisible();
  await expect(page.getByRole("group", { name: "Sourcing view" }).getByRole("button", { name: "All requirements", exact: true })).toBeDisabled();
  await page.getByRole("button", { name: "Cancel quote", exact: true }).click();
  await expect(page.locator(".historical-offers")).not.toHaveAttribute("open", "");
});
test("a dropped file needs explicit upload and the file list remains searchable", async ({ page }) => {
  await login(page); await create(page, "Polish file staging"); await page.getByRole("tab", { name: /^Files/u }).click();
  let uploads = 0; page.on("request", (request) => { if (request.method() === "POST" && request.url().includes("/artifacts")) uploads += 1; });
  const chooseFiles = page.waitForEvent("filechooser");
  await page.getByRole("button", { name: "Add files", exact: true }).click();
  await (await chooseFiles).setFiles([]);
  const transfer = await page.evaluateHandle(() => { const data = new DataTransfer(); data.items.add(new File(["synthetic fixture"], "café-fixture.txt", { type: "text/plain" })); return data; });
  await page.getByRole("group", { name: "File drop area" }).dispatchEvent("drop", { dataTransfer: transfer });
  expect(uploads).toBe(0); await page.getByRole("button", { name: "Add 1 file", exact: true }).click(); await expect(page.getByRole("button", { name: "Details for café-fixture.txt", exact: true })).toBeVisible();
  await page.getByLabel("Search project files").fill("missing"); await expect(page.getByText("No matching files", { exact: true })).toBeVisible();
  await page.getByRole("button", { name: "Clear file search", exact: true }).click(); await expect(page.getByRole("button", { name: "Details for café-fixture.txt", exact: true })).toBeVisible(); await transfer.dispose();
});