evOo-local/apps/web/e2e/routine-execution.spec.ts
cynarAI a2c7182ed6
Side panel Routinen: list toggles, hide when empty (#180)
* feat(web): routine list toggles and hide empty Routinen section

Show Routinen in the Oo side panel only when the bot has routines; remove
the panel create control. Each list row gets an active switch with optimistic
updates via routines.update. E2E covers visibility, toggle persistence, and
updates existing routine specs to create via RPC like chat.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): sync lingui catalogs after routine panel UI change

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): refresh routine list optimistically after save

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* test(e2e): wait for routine list after RPC create in golden path

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* style: format golden e2e after routine list wait

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): show sign-up while session lookup is pending

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>
2026-10-07 23:41:11 +02:00

157 lines
5.7 KiB
TypeScript

import { expect, test } from "@playwright/test";
import type { Routine } from "@rakazo/contracts";
import {
activeBotId,
captureScreenshot,
completeOnboarding,
createTestRoutine,
openAgentComputerPanel,
rpc,
signup,
} from "./helpers";
test("Slack message trigger uses the mounted messaging provider and persists", async ({
page,
}, testInfo) => {
await page.route("**/rpc/messaging/status", (route) =>
route.fulfill({
contentType: "application/json",
body: JSON.stringify({
json: { enabled: true, providers: ["slack"], openSignup: false, identities: [] },
}),
}),
);
const stamp = Date.now();
await signup(page, `routine-slack-${stamp}@rakazo.test`, "password12", "Slack Routine");
await completeOnboarding(page);
const botId = activeBotId(page);
await rpc<Routine>(page, "routines/create", {
botId,
name: "Triage Slack updates",
prompt: "Review the verified message event",
crons: [],
timezone: "UTC",
active: true,
notify: true,
webhookEnabled: false,
githubEnabled: false,
messageProvider: "slack",
});
await openAgentComputerPanel(page);
const panel = page.getByTestId("side-panel");
await expect(panel.getByText("Slack message", { exact: true })).toBeVisible();
const [routine] = await rpc<Routine[]>(page, "routines/list", { botId });
expect(routine).toMatchObject({
name: "Triage Slack updates",
crons: [],
webhookEnabled: false,
githubEnabled: false,
messageProvider: "slack",
});
await captureScreenshot(page, testInfo, "routine-slack-message");
});
test("GitHub event trigger exposes signed delivery settings and persists", async ({
page,
}, testInfo) => {
const stamp = Date.now();
await signup(page, `routine-github-${stamp}@rakazo.test`, "password12", "GitHub Routine");
await completeOnboarding(page);
const botId = activeBotId(page);
await rpc<Routine>(page, "routines/create", {
botId,
name: "Review repository events",
prompt: "Inspect the signed GitHub event",
crons: [],
timezone: "UTC",
active: true,
notify: true,
webhookEnabled: false,
githubEnabled: true,
messageProvider: null,
});
await openAgentComputerPanel(page);
await page.getByRole("button", { name: /Review repository events/ }).click();
await expect(
page.getByTestId("side-panel").getByText("Git event", { exact: true }),
).toBeVisible();
await expect(page.getByText(new RegExp(`/api/v1/bots/${botId}/github$`))).toBeVisible();
await expect(page.getByText("X-Hub-Signature-256: sha256=…", { exact: true })).toBeVisible();
const [routine] = await rpc<Routine[]>(page, "routines/list", { botId });
expect(routine).toMatchObject({
name: "Review repository events",
crons: [],
webhookEnabled: false,
githubEnabled: true,
});
await captureScreenshot(page, testInfo, "routine-github-event");
});
test("Korean webhook routine keeps technical field labels in English", async ({
page,
}, testInfo) => {
const stamp = Date.now();
const userName = `Korean Routine ${stamp}`;
await signup(page, `routine-ko-${stamp}@rakazo.test`, "password12", userName);
await completeOnboarding(page);
await page.getByRole("button", { name: new RegExp(userName) }).click();
await page.getByRole("button", { name: "Settings" }).click();
const settings = page.getByTestId("user-settings");
await settings.getByTestId("ui-locale-select").click();
await settings.getByRole("option", { name: "한국어", exact: true }).click();
await page.getByRole("button", { name: "계정 설정 닫기" }).click();
const botId = activeBotId(page);
await createTestRoutine(page, botId, {
name: "한국어 웹훅 확인",
prompt: "웹훅을 확인합니다.",
crons: [],
webhookEnabled: true,
});
await page.getByTitle("Agent 컴퓨터").click();
await page.getByRole("button", { name: /한국어 웹훅 확인/ }).click();
await expect(page.getByText("웹훅이 실행될 때", { exact: true })).toBeVisible();
await expect(page.getByText("POST 대상")).toBeVisible();
await expect(page.getByText("key", { exact: true })).toBeVisible();
await expect(page.getByText("header")).toBeVisible();
await captureScreenshot(page, testInfo, "routine-webhook-ko");
});
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);
const botId = activeBotId(page);
await openAgentComputerPanel(page);
await expect(page.getByRole("button", { name: "Test run" })).toHaveCount(0);
await createTestRoutine(page, botId, {
name: "Daily verification",
prompt: "write routine-run-now-ok into the durable task result",
crons: ["0 9 * * 1-5"],
});
await page.reload();
await openAgentComputerPanel(page);
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("combobox", { name: "Message" })).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");
});