chore: take deployment-specific material out of the repository for the first release
- MBU parity map, cutover runbook and the tasks/ planning notes move outside the repo - tests/mbu becomes tests/fixtures with generic application names and no placement inventory - test fixtures in Rust and web use neutral names - scripts/export-public.sh checks an external list of private terms instead of naming them Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
115
tests/fixtures/browser.mjs
vendored
Normal file
115
tests/fixtures/browser.mjs
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { createRequire } from "node:module";
|
||||
|
||||
const { chromium } = createRequire(import.meta.url)(process.env.TESSERA_PLAYWRIGHT_MODULE || "playwright");
|
||||
|
||||
const [baseURL, password, captureOnly, filesystemSnapshot] = process.argv.slice(2);
|
||||
const browser = await chromium.launch({
|
||||
executablePath: process.env.TESSERA_FIXTURE_CHROME || undefined,
|
||||
});
|
||||
try {
|
||||
const context = await browser.newContext({ baseURL, viewport: { width: 1100, height: 820 } });
|
||||
const page = await context.newPage();
|
||||
const errors = [];
|
||||
page.on("pageerror", (error) => errors.push(error.message));
|
||||
await page.goto("/");
|
||||
await page.getByRole("heading", { name: "Operator sign-in" }).waitFor();
|
||||
const orbitsStatus = () => page.evaluate(async () => (await fetch("/api/v1/orbits")).status);
|
||||
assert.equal(await orbitsStatus(), 401);
|
||||
await page.getByLabel("Operator password").fill(password);
|
||||
await page.getByRole("button", { name: "Sign in", exact: true }).click();
|
||||
await page.getByRole("heading", { name: "Orbital vault" }).waitFor();
|
||||
assert.equal(await orbitsStatus(), 200);
|
||||
const pairingWithoutCsrf = await page.evaluate(async () =>
|
||||
(await fetch("/api/v1/wormhole/pairing", { method: "POST" })).status);
|
||||
assert.equal(pairingWithoutCsrf, 403);
|
||||
await page.getByRole("button", { name: "Restore", exact: true }).click();
|
||||
await page.getByRole("heading", { name: "Restore snapshot" }).waitFor();
|
||||
await page.getByRole("combobox", { name: "Snapshot", exact: true }).selectOption(captureOnly);
|
||||
await page.getByText("This application has no registered restore targets.").waitFor();
|
||||
assert.equal(await page.getByRole("button", { name: "Queue database restore" }).count(), 0);
|
||||
await page.getByRole("button", { name: "Close", exact: true }).click();
|
||||
await page.getByRole("button", { name: "Orbits", exact: true }).click();
|
||||
await page.getByRole("heading", { name: "Outpost backup jobs" }).waitFor();
|
||||
await page.getByRole("button", { name: "Add an orbit" }).click();
|
||||
await page.getByLabel("Backup source").selectOption("database");
|
||||
await page.getByLabel("Database engine").selectOption("mysql");
|
||||
assert.equal(await page.getByLabel("Database host").count(), 1);
|
||||
await page.getByLabel(/^Access/).selectOption("outpost");
|
||||
assert.equal(await page.getByLabel("Database host").count(), 0);
|
||||
await page.getByLabel("Backup source").selectOption("filesystem");
|
||||
await page.getByLabel("Name", { exact: true }).fill("Browser Outpost folder");
|
||||
const savedOrbit = page.waitForResponse((response) =>
|
||||
response.url().endsWith("/api/v1/orbits") && response.request().method() === "POST");
|
||||
await page.getByRole("button", { name: "Save orbit" }).click();
|
||||
const saved = await savedOrbit;
|
||||
assert.equal(saved.ok(), true);
|
||||
const orbit = await saved.json();
|
||||
assert.equal(orbit.source, "filesystem");
|
||||
assert.equal(orbit.access, "outpost");
|
||||
const profile = page.getByRole("heading", { name: "Register Outpost backup profile" }).locator("..");
|
||||
assert.equal(await profile.getByLabel("Database engine").count(), 0);
|
||||
const outpost = profile.getByLabel("Assigned Outpost");
|
||||
await outpost.getByRole("option", { name: /Browser fixture outpost/ }).waitFor({ state: "attached" });
|
||||
await outpost.selectOption(await outpost.getByRole("option", { name: /Browser fixture outpost/ }).getAttribute("value"));
|
||||
const registeredProfile = page.waitForResponse((response) =>
|
||||
response.url().endsWith("/api/v1/capture-profiles") && response.request().method() === "POST");
|
||||
await profile.getByRole("button", { name: "Register profile" }).click();
|
||||
const registered = await registeredProfile;
|
||||
assert.equal(registered.ok(), true);
|
||||
assert.equal((await registered.json()).format, "filesystem");
|
||||
|
||||
await page.getByRole("combobox", { name: "Application", exact: true })
|
||||
.selectOption({ label: "Browser fixture database" });
|
||||
await page.getByRole("combobox", { name: "Job status" }).selectOption("failed");
|
||||
await page.getByRole("button", { name: /Source preparation failed or timed out/ }).click();
|
||||
await page.getByText("Preparing source", { exact: true }).waitFor();
|
||||
await page.getByRole("combobox", { name: "Job status" }).selectOption("running");
|
||||
await page.getByText("No jobs match these filters.").waitFor();
|
||||
await page.getByRole("button", { name: "Back up selected application" }).click();
|
||||
await page.getByText("Backup queued.").waitFor();
|
||||
await page.getByRole("button", { name: "Open snapshot" }).click();
|
||||
await page.getByRole("heading", { name: "Snapshot detail" }).waitFor();
|
||||
const received = page.waitForEvent("download");
|
||||
await page.getByRole("link", { name: "Download snapshot" }).click();
|
||||
const download = await received;
|
||||
const stream = await download.createReadStream();
|
||||
const chunks = [];
|
||||
for await (const chunk of stream) chunks.push(chunk);
|
||||
assert.match(Buffer.concat(chunks).toString(), /INSERT INTO browser_fixture VALUES \(42\)/);
|
||||
await page.getByRole("button", { name: "Recovery options" }).click();
|
||||
const targetField = page.getByRole("combobox", { name: "Registered target" });
|
||||
const targetOption = targetField.getByRole("option", { name: /^Browser staging target/ });
|
||||
await targetOption.waitFor({ state: "attached" });
|
||||
await targetField.selectOption(await targetOption.getAttribute("value"));
|
||||
const restoreCode = await page.getByText(/^RESTORE [a-f0-9-]+ TO [a-f0-9-]+$/).textContent();
|
||||
assert.equal(await page.getByRole("button", { name: "Queue database restore" }).isDisabled(), true);
|
||||
await page.getByLabel("Restore confirmation").fill(restoreCode);
|
||||
await page.getByRole("button", { name: "Queue database restore" }).click();
|
||||
await page.getByText("Apply failed. Recovery required.", { exact: true }).waitFor();
|
||||
await page.getByRole("link", { name: /^Safety backup [a-f0-9-]+$/ }).waitFor();
|
||||
const recoveryCode = await page.getByText(/^RECONCILE [a-f0-9-]+$/).textContent();
|
||||
await page.getByLabel("Reconciliation confirmation").fill(recoveryCode);
|
||||
await page.getByRole("button", { name: "Mark target recovered" }).click();
|
||||
await page.getByText("Recovery verified by operator", { exact: true }).waitFor();
|
||||
|
||||
await page.getByRole("combobox", { name: "Snapshot", exact: true }).selectOption(filesystemSnapshot);
|
||||
await page.getByLabel("Export filename on hub").fill("filesystem.tar");
|
||||
await page.getByRole("button", { name: "Begin file export" }).click();
|
||||
await page.getByText("File export complete.", { exact: true }).waitFor();
|
||||
await page.getByRole("button", { name: "Close", exact: true }).click();
|
||||
await page.getByRole("button", { name: "Orbits", exact: true }).click();
|
||||
await page.getByRole("button", { name: /Browser fixture database Backup completed/ }).click();
|
||||
await page.getByRole("button", { name: "Open snapshot" }).click();
|
||||
await page.getByRole("button", { name: "Delete snapshot" }).click();
|
||||
await page.getByRole("button", { name: "Confirm deletion" }).click();
|
||||
await page.getByRole("heading", { name: "Snapshot detail" }).waitFor({ state: "hidden" });
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
await page.getByRole("button", { name: "Sign out" }).click();
|
||||
await page.getByRole("heading", { name: "Operator sign-in" }).waitFor();
|
||||
assert.equal(await orbitsStatus(), 401);
|
||||
assert.deepEqual(errors, []);
|
||||
console.log("Browser sign-in, backup, download, database restore/reconciliation, filesystem export, and deletion verified");
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
Reference in New Issue
Block a user