Files
pleno-vue/tests/e2e/release-bootstrap.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

90 lines
3.0 KiB
JavaScript

import { expect, test } from "@playwright/test";
const json = (body, status = 200) => ({
status,
contentType: "application/json",
headers: {
"access-control-allow-origin": "*",
},
body: JSON.stringify(body),
});
test("non-default release frontend loads from lb.truckwash.io without redirecting", async ({ page }) => {
const releaseApiRequests = [];
const runtime = {
generated_at: "2026-05-20T10:00:00.000Z",
trace_id: "trace-release-bootstrap",
channel: {
id: 2,
slug: "canary",
name: "Canary",
default_channel: false,
},
versions: {
frontend: { version_label: "frontend-canary", deployed_url: "https://lb.truckwash.io/canary/frontend" },
api: { version_label: "api-canary", deployed_url: "https://lb.truckwash.io/canary/api" },
bundle_id: 31,
},
urls: {
frontend_base_url: "https://lb.truckwash.io/canary/frontend",
api_base_url: "https://lb.truckwash.io/canary/api",
},
availability: {
configured: true,
missing: [],
status: "ready",
},
capture_policy: {
enabled: false,
capture_level: "metadata",
all_failure_metadata: true,
retention_days: 14,
},
};
await page.route("**/release/runtime**", async (route) => {
await route.fulfill(json({ data: runtime }));
});
await page.route("https://lb.truckwash.io/canary/frontend/release-entry.json", async (route) => {
await route.fulfill(
json({
entry: "assets/release-canary.js",
css: ["assets/release-canary.css"],
})
);
});
await page.route("https://lb.truckwash.io/canary/frontend/assets/release-canary.css", async (route) => {
await route.fulfill({
status: 200,
contentType: "text/css",
headers: { "access-control-allow-origin": "*" },
body: "body::before { content: ''; }",
});
});
await page.route("https://lb.truckwash.io/canary/frontend/assets/release-canary.js", async (route) => {
await route.fulfill({
status: 200,
contentType: "application/javascript",
headers: { "access-control-allow-origin": "*" },
body: `
document.body.dataset.releaseFrontend = 'canary';
document.body.dataset.releaseOrigin = window.location.origin;
fetch('https://lb.truckwash.io/canary/api/ping').catch(() => {});
`,
});
});
await page.route("https://lb.truckwash.io/canary/api/ping", async (route) => {
releaseApiRequests.push(route.request().url());
await route.fulfill(json({ data: { ok: true } }));
});
await page.goto("/shared/passkey-safe-link", { waitUntil: "domcontentloaded" });
await expect(page.locator("body")).toHaveAttribute("data-release-frontend", "canary");
const currentOrigin = await page.evaluate(() => window.location.origin);
expect(page.url()).toContain("/shared/passkey-safe-link");
expect(page.url()).not.toContain("lb.truckwash.io");
await expect.poll(() => releaseApiRequests.length).toBe(1);
await expect(page.locator("body")).toHaveAttribute("data-release-origin", currentOrigin);
});