Skip to content

Commit 37eb9bd

Browse files
Agentsclaude
authored andcommitted
test(web): add E2E for Fleet route nav + per-instance row render
Two focused Playwright tests, mirroring the existing sidebar.spec pattern (no backend dependency — instances point at unreachable ports and we only assert on rendered names + row count, not health): - Fleet link in the sidebar navigates to /fleet - /fleet renders one row per configured instance under the table role Also adds a Fleet link assertion to the existing sidebar.spec so the nav entry is covered on the dashboard route alongside the other top links. Both new tests run under the existing `pnpm test:e2e` (not gated in CI by design — matches the current Compare/Dashboard E2E posture). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e90d208 commit 37eb9bd

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

‎packages/web/e2e/fleet.spec.ts‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { expect, test } from "@playwright/test";
2+
3+
const STORE_KEY = "openconcho:instances";
4+
5+
// Two unreachable instances — the rows still render with their configured
6+
// names; only the health column flips to "unreachable" once the workspaces
7+
// query errors. We only assert on the rendered names + row count, so the
8+
// test doesn't depend on a live backend.
9+
const FLEET_STORE = JSON.stringify({
10+
instances: [
11+
{ id: "a", name: "Neo", baseUrl: "http://localhost:9001", token: "" },
12+
{ id: "b", name: "Iris", baseUrl: "http://localhost:9002", token: "" },
13+
{ id: "c", name: "Lexi", baseUrl: "http://localhost:9003", token: "" },
14+
],
15+
activeId: "a",
16+
});
17+
18+
test.describe("Fleet route", () => {
19+
test.beforeEach(async ({ context }) => {
20+
await context.addInitScript(
21+
([key, value]) => {
22+
window.localStorage.setItem(key, value);
23+
},
24+
[STORE_KEY, FLEET_STORE],
25+
);
26+
});
27+
28+
test("renders one row per configured instance and the Fleet heading", async ({ page }) => {
29+
await page.goto("/fleet");
30+
31+
// Page header
32+
await expect(page.getByRole("heading", { name: /^Fleet$/ })).toBeVisible();
33+
34+
// One row per instance, asserted via the table not the sidebar (the
35+
// active instance's name also appears in the sidebar switcher).
36+
const table = page.getByRole("table");
37+
await expect(table.getByText("Neo", { exact: true })).toBeVisible();
38+
await expect(table.getByText("Iris", { exact: true })).toBeVisible();
39+
await expect(table.getByText("Lexi", { exact: true })).toBeVisible();
40+
41+
// 1 header row + 3 instance rows
42+
await expect(table.getByRole("row")).toHaveCount(4);
43+
});
44+
45+
test("Fleet link in the sidebar navigates to /fleet", async ({ page }) => {
46+
await page.goto("/");
47+
await page.getByRole("link", { name: /fleet/i }).click();
48+
await expect(page).toHaveURL(/\/fleet$/);
49+
await expect(page.getByRole("heading", { name: /^Fleet$/ })).toBeVisible();
50+
});
51+
});

‎packages/web/e2e/sidebar.spec.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ test.describe("Sidebar", () => {
1717
await page.goto("/");
1818
await expect(page.getByRole("complementary")).toBeVisible();
1919
await expect(page.getByRole("link", { name: /dashboard/i })).toBeVisible();
20+
await expect(page.getByRole("link", { name: /fleet/i })).toBeVisible();
2021
await expect(page.getByRole("link", { name: /workspaces/i })).toBeVisible();
2122
await expect(page.getByRole("link", { name: /settings/i })).toBeVisible();
2223
});

0 commit comments

Comments
 (0)