import { expect, test } from "@playwright/test"; import type { Routine } from "@rakazo/contracts"; import { activeBotId, completeOnboarding, createTestRoutine, openAgentOverview, rpc, signup, } from "./helpers"; test("routines section is hidden until the Oo has one, then list toggle persists", async ({ page, }) => { const stamp = Date.now(); await signup(page, `routine-list-${stamp}@rakazo.test`, "password12", "Routine List"); await completeOnboarding(page); const botId = activeBotId(page); await openAgentOverview(page); const panel = page.getByTestId("side-panel"); await expect(panel.getByText("Routines", { exact: true })).toHaveCount(0); await expect(page.getByTestId("routine-create-button")).toHaveCount(0); await createTestRoutine(page, botId, { name: "Morning check-in" }); await page.reload(); await openAgentOverview(page); await expect(panel.getByText("Routines", { exact: true })).toBeVisible(); await expect(page.getByRole("button", { name: /Morning check-in/ })).toBeVisible(); const toggle = page.getByTestId("routine-list-active-toggle"); await expect(toggle).toHaveAttribute("aria-checked", "true"); await expect(page.getByText("Every day", { exact: false })).toBeVisible(); const updated = page.waitForResponse( (response) => response.url().includes("/rpc/routines/update") && response.ok(), ); await toggle.click(); await expect(toggle).toHaveAttribute("aria-checked", "false"); await updated; const [routine] = await rpc(page, "routines/list", { botId }); expect(routine?.active).toBe(false); await expect(page.getByText("Paused", { exact: true })).toBeVisible(); await toggle.click(); await expect(toggle).toHaveAttribute("aria-checked", "true"); const [reactivated] = await rpc(page, "routines/list", { botId }); expect(reactivated?.active).toBe(true); });