- Implement components for `ReleaseChannelSelector`, including panel and sidebar variants. - Add `ReleaseAssignmentSubjectAutocomplete` for user, subuser, and customer search functionality. - Update i18n phrases for channel selector and subject assignment. - Enhance unit and E2E tests for release channel availability, switching, and runtime configuration. - Modify modules for channel-related state handling and runtime refresh mechanics.
133 lines
4.5 KiB
JavaScript
133 lines
4.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",
|
|
},
|
|
});
|
|
|
|
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("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);
|
|
});
|