76 lines
2.5 KiB
JavaScript
76 lines
2.5 KiB
JavaScript
import { expect, test } from "@playwright/test";
|
|
import { mockApi, seedAuthenticatedState } from "./support/network.js";
|
|
|
|
const baseUrl = process.env.PLAYWRIGHT_BASE_URL || "http://127.0.0.1:5173";
|
|
|
|
const availableRuntime = (frontendBaseUrl) => ({
|
|
generated_at: "2026-05-19T09:30:00.000Z",
|
|
trace_id: "trace-switched-channel",
|
|
channel: {
|
|
id: 2,
|
|
slug: "canary",
|
|
name: "Canary",
|
|
description: "Early production validation before broader rollout.",
|
|
enabled: true,
|
|
default_channel: false,
|
|
frontend_base_url: frontendBaseUrl,
|
|
api_base_url: "https://api-canary.example.test",
|
|
},
|
|
versions: {
|
|
frontend: { version_label: "frontend-canary", commit_sha: "c0ffee" },
|
|
api: { version_label: "api-canary", commit_sha: "feedface" },
|
|
},
|
|
frontend_base_url: frontendBaseUrl,
|
|
api_base_url: "https://api-canary.example.test",
|
|
availability: {
|
|
configured: true,
|
|
missing: [],
|
|
status: "ready",
|
|
},
|
|
capture_policy: {
|
|
enabled: false,
|
|
capture_level: "metadata",
|
|
all_failure_metadata: true,
|
|
retention_days: 14,
|
|
},
|
|
});
|
|
|
|
async function boot(page) {
|
|
await page.addInitScript(() => {
|
|
window.localStorage.setItem("locale", "en");
|
|
window.localStorage.removeItem("release_channel_unavailable_ignore_until");
|
|
window.localStorage.removeItem("release_channel_switch_notice_seen");
|
|
});
|
|
|
|
await mockApi(page, {
|
|
authenticated: true,
|
|
permissions: ["user"],
|
|
sessionData: {
|
|
id: 77,
|
|
customer_number: 990077,
|
|
runtime_config: {
|
|
release: availableRuntime(baseUrl),
|
|
},
|
|
},
|
|
});
|
|
await seedAuthenticatedState(page, "release-channel-switched-token");
|
|
}
|
|
|
|
test("users assigned to a configured release channel see the switched notice once on the device", async ({ page }) => {
|
|
await boot(page);
|
|
|
|
await page.goto("/user", { waitUntil: "domcontentloaded" });
|
|
const notice = page.getByTestId("release-channel-switched-page");
|
|
await expect(notice).toBeVisible();
|
|
await expect(notice).toContainText("You are now on Canary");
|
|
await expect(notice).toContainText("Early production validation");
|
|
await expect(page.getByTestId("release-channel-switched-details")).toContainText("frontend-canary");
|
|
await expect(page.getByTestId("release-channel-switched-details")).toContainText("api-canary");
|
|
|
|
await page.getByTestId("release-channel-switched-continue").click();
|
|
await expect(notice).toHaveCount(0);
|
|
|
|
await page.goto("/user", { waitUntil: "domcontentloaded" });
|
|
await expect(page.getByTestId("release-channel-switched-page")).toHaveCount(0);
|
|
});
|