Files
pleno-vue/tests/e2e/release-channel-unavailable.spec.js
T
Jeppe Bundgaard 130cc2fc10 Add release runtime bootstrap implementation with unit and E2E tests
- Create `releaseBootstrap.js` service to handle runtime configuration and remote frontend loading.
- Integrate runtime-aware API URL resolution across components and services.
- Update i18n phrases to clarify new domains for `ssl_domain_message`.
- Enhance unit and E2E tests to validate runtime-based frontend loading and fallback behavior.
- Refactor session-related API calls and incorporate runtime-configured base URLs.
2026-05-20 11:26:21 +02:00

229 lines
7.5 KiB
JavaScript

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,
},
versions: { frontend: null, api: null, bundle_id: null },
availability: {
configured: false,
missing: ["release_bundle", "frontend_version", "api_version"],
status: "unconfigured",
},
capture_policy: {
enabled: false,
capture_level: "metadata",
all_failure_metadata: true,
retention_days: 14,
},
};
const availableRuntime = () => ({
...unavailableRuntime,
versions: {
frontend: { version_label: "frontend-canary", commit_sha: "c0ffee" },
api: { version_label: "api-canary", commit_sha: "feedface" },
bundle_id: 31,
},
availability: {
configured: true,
missing: [],
status: "ready",
},
});
const runtimeWithSelectableReleaseDetails = () => ({
...unavailableRuntime,
versions: {
frontend: null,
api: null,
bundle_id: null,
},
availability: {
configured: false,
missing: ["release_bundle"],
status: "unconfigured",
},
available_channels: [
{
channel: {
id: 1,
slug: "stable",
name: "Stable",
description: "Standard production channel.",
enabled: true,
default_channel: true,
},
versions: {
frontend: {
version_label: "frontend-stable",
commit_sha: "abc1234567890000111122223333444455556666",
deployed_at: "2026-05-18T07:45:00.000Z",
},
api: {
version_label: "api-stable",
commit_sha: "def456789abc0000111122223333444455556666",
deployed_at: "2026-05-18T07:47:00.000Z",
},
bundle_id: 31,
bundle: {
id: 31,
promoted_at: "2026-05-18T08:00:00.000Z",
},
},
availability: {
configured: true,
missing: [],
status: "ready",
},
},
{
channel: unavailableRuntime.channel,
versions: {
frontend: {
version_label: "frontend-canary",
commit_sha: "c0ffee0000001111222233334444555566667777",
deployed_at: "2026-05-19T08:15:00.000Z",
},
api: {
version_label: "api-canary",
commit_sha: "feedface00001111222233334444555566667777",
deployed_at: "2026-05-19T08:18:00.000Z",
},
bundle_id: null,
},
availability: {
configured: false,
missing: ["release_bundle"],
status: "unconfigured",
},
},
],
});
async function boot(page, runtime = unavailableRuntime, locale = "en") {
await page.addInitScript((selectedLocale) => {
window.localStorage.setItem("locale", selectedLocale);
window.localStorage.removeItem("release_channel_unavailable_ignore_until");
}, locale);
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", { waitUntil: "domcontentloaded" });
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("Release bundle");
await expect(page.getByTestId("release-channel-missing")).toContainText("Frontend version");
await expect(page.getByTestId("release-channel-missing")).toContainText("API version");
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("release channel choices show git commit and release time when available", async ({ page }) => {
const runtime = runtimeWithSelectableReleaseDetails();
await boot(page, runtime);
await page.route("**/release/runtime", async (route) => {
await route.fulfill(json({ data: runtime }));
});
await page.goto("/user", { waitUntil: "domcontentloaded" });
const guard = page.getByTestId("release-channel-unavailable-page");
await expect(guard).toBeVisible();
const canary = page.getByTestId("release-channel-option-canary");
await expect(canary).toBeVisible();
await expect(canary).toContainText("Release bundle");
await expect(page.getByTestId("release-channel-option-canary-frontend-release")).toContainText("c0ffee000000");
await expect(page.getByTestId("release-channel-option-canary-frontend-release")).toContainText(
/May 19, 2026|19 May 2026/
);
await expect(page.getByTestId("release-channel-option-canary-api-release")).toContainText("feedface0000");
await expect(page.getByTestId("release-channel-option-canary-api-release")).toContainText(/May 19, 2026|19 May 2026/);
await expect(page.getByTestId("release-channel-option-stable-bundle-release")).toContainText("#31");
await expect(page.getByTestId("release-channel-option-stable-bundle-release")).toContainText(
/May 18, 2026|18 May 2026/
);
});
test("predefined release channel text is localized on the guard page", async ({ page }) => {
const internalRuntime = {
...unavailableRuntime,
channel: {
...unavailableRuntime.channel,
slug: "internal",
name: "Internal",
description: "Internal staff and superuser validation channel.",
},
};
await boot(page, internalRuntime, "da");
await page.route("**/release/runtime", async (route) => {
await route.fulfill(json({ data: internalRuntime }));
});
await page.goto("/user", { waitUntil: "domcontentloaded" });
const guard = page.getByTestId("release-channel-unavailable-page");
await expect(guard).toBeVisible();
await expect(guard).toContainText("Release-kanalen er ikke klar");
await expect(guard).toContainText("Intern");
await expect(guard).toContainText("Intern kanal til medarbejdere");
await expect(guard).not.toContainText("Internal staff");
await expect(guard).not.toContainText(/\binternal\b/);
await expect(guard).not.toContainText(/\p{L}\?\p{L}|\?\p{L}/u);
});
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", { waitUntil: "domcontentloaded" });
const guard = page.getByTestId("release-channel-unavailable-page");
await expect(guard).toBeVisible();
const currentUrl = page.url();
releaseRuntime = availableRuntime();
await page.getByTestId("release-channel-check-again").click();
await expect(guard).toHaveCount(0);
await expect(page).toHaveURL(currentUrl);
});