import { expect, test } from "@playwright/test"; import type { Routine } from "@rakazo/contracts"; import { activeBotId, captureScreenshot, completeOnboarding, createTestRoutine, openAgentOverview, 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(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 openAgentOverview(page); const panel = page.getByTestId("side-panel"); await expect(panel.getByText("Slack message", { exact: true })).toBeVisible(); const [routine] = await rpc(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(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 openAgentOverview(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(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 openAgentOverview(page, "Agent 컴퓨터"); 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 openAgentOverview(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 openAgentOverview(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 openAgentOverview(page); await expect(page.getByRole("button", { name: /Daily verification/ })).toContainText( "Weekdays at 9:00 AM", ); await captureScreenshot(page, testInfo, "35-routine-run-persisted"); });