BangSo/apps/web/e2e/routine-execution.spec.ts

47 lines
2.3 KiB
TypeScript

import { expect, test } from "@playwright/test";
import { captureScreenshot, completeOnboarding, signup } from "./helpers";
test("routine test-run completes and survives reload", async ({ page }, testInfo) => {
const stamp = Date.now();
await signup(page, `routine-${stamp}@rakazo.test`, "password12", "Routine");
await completeOnboarding(page);
await page.getByTitle("Agent computer").click();
await expect(page.getByRole("button", { name: "Test run" })).toHaveCount(0);
await page.getByRole("button", { name: "New routine" }).click();
await page.locator("label:has-text('Name') input").fill("Daily verification");
await page
.locator("label:has-text('Instruction') textarea")
.fill("write routine-run-now-ok into the durable task result");
await page.getByRole("button", { name: "Add trigger" }).click();
await page.getByRole("menuitem", { name: "On a schedule" }).hover();
await page.getByRole("menuitem", { name: "Weekdays", exact: true }).click();
await expect(page.getByLabel("How often")).toHaveValue("Weekdays");
await captureScreenshot(page, testInfo, "32-routine-configured");
const saved = page.waitForResponse(
(response) => response.url().includes("/rpc/routines/create") && response.ok(),
);
await page.getByRole("button", { name: "Save" }).click();
await saved;
await expect(page.getByRole("button", { name: "Save" })).toBeEnabled();
await page.getByRole("button", { name: "Back" }).click();
const routine = page.getByRole("button", { name: /Daily verification/ });
await expect(routine).toContainText("Weekdays at 9:00 AM");
await captureScreenshot(page, testInfo, "33-routine-scheduled");
await routine.click();
await page.getByRole("button", { name: "Test run" }).click();
await expect(page.getByText(/routine-run-now-ok/i).first()).toBeVisible({ timeout: 30_000 });
await expect(page.getByRole("button", { name: "Send" })).toBeVisible({ timeout: 30_000 });
await captureScreenshot(page, testInfo, "34-routine-run-completed");
await page.reload();
await expect(page.getByText(/routine-run-now-ok/i).first()).toBeVisible();
await page.getByTitle("Agent computer").click();
await expect(page.getByRole("button", { name: /Daily verification/ })).toContainText(
"Weekdays at 9:00 AM",
);
await captureScreenshot(page, testInfo, "35-routine-run-persisted");
});