Add unit and E2E tests for release channel availability and switched-notice functionality. Configure runtime mocks and implement Vue components for channel-specific handling.
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
import { mockApi, seedAuthenticatedState } from "./support/network.js";
|
||||
|
||||
const json = (body, status = 200) => ({
|
||||
status,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
const unavailableRuntime = {
|
||||
generated_at: "2026-05-19T09:00:00.000Z",
|
||||
trace_id: "trace-unavailable-channel",
|
||||
channel: {
|
||||
id: 2,
|
||||
slug: "canary",
|
||||
name: "Canary",
|
||||
description: "Early production validation before broader rollout.",
|
||||
enabled: true,
|
||||
default_channel: false,
|
||||
frontend_base_url: null,
|
||||
api_base_url: null,
|
||||
},
|
||||
versions: { frontend: null, api: null },
|
||||
frontend_base_url: null,
|
||||
api_base_url: null,
|
||||
availability: {
|
||||
configured: false,
|
||||
missing: ["frontend_base_url", "api_base_url"],
|
||||
status: "unconfigured",
|
||||
},
|
||||
capture_policy: {
|
||||
enabled: false,
|
||||
capture_level: "metadata",
|
||||
all_failure_metadata: true,
|
||||
retention_days: 14,
|
||||
},
|
||||
};
|
||||
|
||||
const availableRuntime = (frontendBaseUrl) => ({
|
||||
...unavailableRuntime,
|
||||
channel: {
|
||||
...unavailableRuntime.channel,
|
||||
frontend_base_url: frontendBaseUrl,
|
||||
api_base_url: "https://api-canary.example.test",
|
||||
},
|
||||
frontend_base_url: frontendBaseUrl,
|
||||
api_base_url: "https://api-canary.example.test",
|
||||
availability: {
|
||||
configured: true,
|
||||
missing: [],
|
||||
status: "ready",
|
||||
},
|
||||
});
|
||||
|
||||
async function boot(page, runtime = unavailableRuntime) {
|
||||
await page.addInitScript(() => {
|
||||
window.localStorage.setItem("locale", "en");
|
||||
window.localStorage.removeItem("release_channel_unavailable_ignore_until");
|
||||
});
|
||||
|
||||
await mockApi(page, {
|
||||
authenticated: true,
|
||||
permissions: ["user"],
|
||||
sessionData: {
|
||||
runtime_config: {
|
||||
release: runtime,
|
||||
},
|
||||
},
|
||||
});
|
||||
await seedAuthenticatedState(page, "release-channel-token");
|
||||
}
|
||||
|
||||
test("users assigned to an unconfigured release channel can ignore the guard temporarily", async ({ page }) => {
|
||||
await boot(page);
|
||||
await page.route("**/release/runtime", async (route) => {
|
||||
await route.fulfill(json({ data: unavailableRuntime }));
|
||||
});
|
||||
|
||||
await page.goto("/user");
|
||||
const guard = page.getByTestId("release-channel-unavailable-page");
|
||||
await expect(guard).toBeVisible();
|
||||
await expect(guard).toContainText("Release channel is not ready");
|
||||
await expect(guard).toContainText("Canary");
|
||||
await expect(page.getByTestId("release-channel-missing")).toContainText("Frontend URL");
|
||||
await expect(page.getByTestId("release-channel-missing")).toContainText("API URL");
|
||||
await expect(page.getByTestId("release-channel-next-check")).toContainText("Checking again in");
|
||||
|
||||
await page.getByTestId("release-channel-ignore").click();
|
||||
await expect(guard).toHaveCount(0);
|
||||
await page.evaluate(() => window.localStorage.removeItem("release_channel_unavailable_ignore_until"));
|
||||
});
|
||||
|
||||
test("users assigned to an unconfigured release channel can check again when it becomes ready", async ({ page }) => {
|
||||
await boot(page);
|
||||
let releaseRuntime = unavailableRuntime;
|
||||
|
||||
await page.route("**/release/runtime", async (route) => {
|
||||
await route.fulfill(json({ data: releaseRuntime }));
|
||||
});
|
||||
|
||||
await page.goto("/user");
|
||||
const guard = page.getByTestId("release-channel-unavailable-page");
|
||||
await expect(guard).toBeVisible();
|
||||
|
||||
releaseRuntime = availableRuntime(new URL(page.url()).origin);
|
||||
await page.getByTestId("release-channel-check-again").click();
|
||||
await expect(guard).toHaveCount(0);
|
||||
});
|
||||
Reference in New Issue
Block a user