2026-04-11 00:02:26 -03:00
|
|
|
import { expect, test } from "../../../frontend/node_modules/@playwright/test/index.mjs";
|
|
|
|
|
|
|
|
|
|
test.beforeEach(async ({ page }) => {
|
2026-04-21 19:17:20 -03:00
|
|
|
await page.addInitScript(() => {
|
|
|
|
|
const originalFetch = window.fetch.bind(window);
|
2026-06-29 13:23:07 -03:00
|
|
|
const jsonResponse = (body, status = 200) =>
|
2026-04-21 19:17:20 -03:00
|
|
|
new Response(JSON.stringify(body), {
|
2026-06-29 13:23:07 -03:00
|
|
|
status,
|
2026-04-21 19:17:20 -03:00
|
|
|
headers: { "content-type": "application/json" },
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
window.fetch = (resource, options) => {
|
|
|
|
|
const requestUrl = typeof resource === "string" ? resource : resource?.url || "";
|
|
|
|
|
const url = new URL(requestUrl, window.location.origin);
|
|
|
|
|
if (url.pathname === "/api/auth/config") {
|
2026-06-29 13:23:07 -03:00
|
|
|
return Promise.resolve(jsonResponse({ enabled: true, reset_url: "https://sso.example.dev/reset" }));
|
2026-04-21 19:17:20 -03:00
|
|
|
}
|
|
|
|
|
if (url.pathname === "/api/lab/status") {
|
2026-06-29 13:23:07 -03:00
|
|
|
if (window.__LAB_STATUS_FAIL__) {
|
|
|
|
|
return Promise.resolve(jsonResponse({ error: "status 503" }, 503));
|
|
|
|
|
}
|
2026-04-21 19:17:20 -03:00
|
|
|
return Promise.resolve(
|
|
|
|
|
jsonResponse({
|
|
|
|
|
connected: true,
|
2026-06-29 13:23:07 -03:00
|
|
|
atlas: { up: true, known: true },
|
|
|
|
|
active_service: { known: true, label: "Nextcloud", url: "https://cloud.bstein.dev", window: "15m" },
|
|
|
|
|
dedicated_hosts: {
|
|
|
|
|
known: true,
|
|
|
|
|
up: true,
|
|
|
|
|
up_count: 2,
|
|
|
|
|
total: 2,
|
|
|
|
|
hosts: [
|
|
|
|
|
{ label: "Database node", known: true, up: true },
|
|
|
|
|
{ label: "Jumphost", known: true, up: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
checked_at: 1000,
|
2026-04-21 19:17:20 -03:00
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return originalFetch(resource, options);
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-11 00:02:26 -03:00
|
|
|
await page.route("**/api/auth/config", async (route) => {
|
|
|
|
|
await route.fulfill({
|
|
|
|
|
status: 200,
|
|
|
|
|
contentType: "application/json",
|
2026-06-29 13:23:07 -03:00
|
|
|
body: JSON.stringify({ enabled: true, reset_url: "https://sso.example.dev/reset" }),
|
2026-04-11 00:02:26 -03:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
await page.route("**/api/lab/status", async (route) => {
|
|
|
|
|
await route.fulfill({
|
|
|
|
|
status: 200,
|
|
|
|
|
contentType: "application/json",
|
|
|
|
|
body: JSON.stringify({
|
|
|
|
|
connected: true,
|
2026-06-29 13:23:07 -03:00
|
|
|
atlas: { up: true, known: true },
|
|
|
|
|
active_service: { known: true, label: "Nextcloud", url: "https://cloud.bstein.dev", window: "15m" },
|
|
|
|
|
dedicated_hosts: {
|
|
|
|
|
known: true,
|
|
|
|
|
up: true,
|
|
|
|
|
up_count: 2,
|
|
|
|
|
total: 2,
|
|
|
|
|
hosts: [
|
|
|
|
|
{ label: "Database node", known: true, up: true },
|
|
|
|
|
{ label: "Jumphost", known: true, up: true },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
checked_at: 1000,
|
2026-04-11 00:02:26 -03:00
|
|
|
}),
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2026-06-29 13:23:07 -03:00
|
|
|
test("shows Brad's professional homepage and opens the platform diagram overlay", async ({ page }) => {
|
2026-04-11 00:02:26 -03:00
|
|
|
await page.goto("/", { waitUntil: "domcontentloaded" });
|
|
|
|
|
|
2026-06-29 13:23:07 -03:00
|
|
|
await expect(page.getByRole("heading", { name: "Brad Stein" })).toBeVisible();
|
|
|
|
|
await expect(page.getByRole("heading", { name: "DevOps Automation Engineer / Senior SDET" })).toBeVisible();
|
|
|
|
|
await expect(page.getByRole("link", { name: "Discuss a Project" })).toBeVisible();
|
|
|
|
|
await expect(page.getByRole("link", { name: "View Résumé" })).toBeVisible();
|
|
|
|
|
await expect(page.getByRole("link", { name: "Explore the Live Platform" })).toBeVisible();
|
|
|
|
|
await expect(page.getByRole("button", { name: "Login" })).toBeVisible();
|
|
|
|
|
await expect(page.getByRole("link", { name: "Register" })).toBeVisible();
|
|
|
|
|
await expect(page.getByRole("heading", { name: "From 0 to 100" })).toBeVisible();
|
|
|
|
|
await expect(page.getByRole("link", { name: "Nextcloud", exact: true })).toBeVisible();
|
|
|
|
|
await expect(page.getByText("2 of 2 responding")).toBeVisible();
|
|
|
|
|
|
|
|
|
|
await page.getByRole("link", { name: "Explore the Live Platform" }).click();
|
|
|
|
|
await expect(page.getByRole("heading", { name: "Titan Lab: Live Platform" })).toBeVisible();
|
|
|
|
|
await expect(page.getByRole("link", { name: "IaC source" })).toBeVisible();
|
2026-04-11 00:02:26 -03:00
|
|
|
await expect(page.getByText("Live data connected")).toBeVisible();
|
|
|
|
|
await expect(page.locator(".service-grid .service").filter({ hasText: "Nextcloud" }).first()).toBeVisible();
|
|
|
|
|
|
2026-06-29 13:23:07 -03:00
|
|
|
await page.locator("details.source-diagrams summary").click();
|
|
|
|
|
const firstCard = page.locator("details.source-diagrams .mermaid-card").first();
|
2026-04-21 18:18:01 -03:00
|
|
|
await expect(firstCard).toBeVisible();
|
2026-05-21 16:49:12 -03:00
|
|
|
await firstCard.locator(".diagram").click();
|
2026-04-11 00:02:26 -03:00
|
|
|
await expect(page.locator(".overlay")).toBeVisible();
|
|
|
|
|
await page.keyboard.press("Escape");
|
|
|
|
|
await expect(page.locator(".overlay")).toHaveCount(0);
|
|
|
|
|
});
|
2026-06-29 13:23:07 -03:00
|
|
|
|
|
|
|
|
test("keeps the homepage usable when public status fails", async ({ page }) => {
|
|
|
|
|
await page.addInitScript(() => {
|
|
|
|
|
window.__LAB_STATUS_FAIL__ = true;
|
|
|
|
|
});
|
|
|
|
|
await page.route("**/api/lab/status", async (route) => {
|
|
|
|
|
await route.fulfill({
|
|
|
|
|
status: 503,
|
|
|
|
|
contentType: "application/json",
|
|
|
|
|
body: JSON.stringify({ error: "status 503" }),
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await page.goto("/", { waitUntil: "domcontentloaded" });
|
|
|
|
|
|
|
|
|
|
await expect(page.getByRole("heading", { name: "Brad Stein" })).toBeVisible();
|
|
|
|
|
await expect(page.getByText("Live status is temporarily unavailable").first()).toBeVisible();
|
|
|
|
|
await expect(page.getByText("status 503")).toHaveCount(0);
|
|
|
|
|
});
|