Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions 03_implementation/ui/tests/e2e/_helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import { expect, type Page, type Route } from "@playwright/test";

/**
* Shared helpers for tab-specific Playwright specs.
*
* No-fake contract:
* - These helpers never invent backend payloads. They only forward real backend
* responses or assert visible blocked/empty states truthfully.
* - Specs that need to stub a route should pass real-shape JSON and call
* fulfillJson directly; helpers here keep to navigation, error capture, and
* forbidden-term scans of the rendered DOM.
*/

export const FORBIDDEN_VISIBLE_TERMS = [
"TODO",
"FIXME",
"lorem ipsum",
"placeholder text",
"sample data",
"mock data",
"dummy data",
"fake data",
] as const;

export interface TabFixture {
/** Sidebar button label as rendered in routes.tsx. */
label: string;
/** Root element data-testid emitted by the tab component. */
rootTestId: string;
}

export const TAB_FIXTURES: Record<string, TabFixture> = {
dashboard: { label: "Dashboard", rootTestId: "dashboard-root" },
source_os: { label: "Source OS", rootTestId: "source-os-root" },
autopilot: { label: "Autopilot", rootTestId: "autopilot-root" },
design: { label: "Design", rootTestId: "design-root" },
gen3d: { label: "3D Generation", rootTestId: "gen3d-root" },
jobs: { label: "Jobs", rootTestId: "jobs-root" },
printers: { label: "Printers", rootTestId: "printers-root" },
observe: { label: "Observe", rootTestId: "observe-root" },
voice: { label: "Voice", rootTestId: "voice-root" },
agents: { label: "Agents", rootTestId: "agents-root" },
learning: { label: "Learning", rootTestId: "learning-root" },
artifacts: { label: "Artifacts", rootTestId: "artifacts-root" },
approvals: { label: "Approvals", rootTestId: "approvals-root" },
plugins: { label: "Plugins", rootTestId: "plugins-root" },
settings: { label: "Settings", rootTestId: "settings-root" },
roadmap: { label: "Roadmap", rootTestId: "roadmap-root" },
};

/** Attach console + pageerror capture and expose a window getter. */
export async function attachErrorCapture(page: Page): Promise<void> {
const errors: string[] = [];
page.on("pageerror", (error) => errors.push(error.message));
page.on("console", (message) => {
if (message.type() === "error") {
errors.push(message.text());
}
});
await page.exposeFunction("__hermes3dErrors", () => errors);
}

export async function readErrors(page: Page): Promise<string[]> {
return page.evaluate(async () => {
const reader = window as unknown as { __hermes3dErrors: () => Promise<string[]> };
return reader.__hermes3dErrors();
});
}

export async function fulfillJson(route: Route, json: unknown, status = 200): Promise<void> {
await route.fulfill({
status,
contentType: "application/json",
body: JSON.stringify(json),
});
}

/**
* Click the left-rail sidebar button for a given tab and assert its root mounts.
* Uses the Roadmap hash route when label === "Roadmap" since it is excluded
* from primary navigation.
*/
export async function openTab(page: Page, fixture: TabFixture): Promise<void> {
if (fixture.label === "Roadmap") {
await page.goto("/#roadmap");
} else {
const button = page.getByRole("button", { name: fixture.label, exact: true });
await expect(button, `${fixture.label} sidebar button`).toBeVisible();
await button.click();
}
await expect(
page.getByTestId(fixture.rootTestId),
`${fixture.label} root mounts as ${fixture.rootTestId}`,
).toBeVisible({ timeout: 15_000 });
}

/**
* Read the visible text of the active tab root and assert that no
* forbidden mock/placeholder phrases appear in production surfaces.
* Forbidden terms are checked case-insensitively as standalone substrings.
*/
export async function assertNoFakeVisibleText(page: Page, rootTestId: string): Promise<void> {
const text = await page.getByTestId(rootTestId).innerText();
const lowered = text.toLowerCase();
for (const term of FORBIDDEN_VISIBLE_TERMS) {
expect(
lowered.includes(term.toLowerCase()),
`forbidden term "${term}" must not appear in ${rootTestId}`,
).toBe(false);
}
Comment on lines +105 to +110

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current implementation uses includes() for forbidden term checks, which can lead to false positives if a term appears as a substring of a legitimate word (e.g., "mock" matching in "hammock" or "sample" in "resample"). Since the intent is to find "standalone substrings", using a regular expression with word boundaries (\b) would be more reliable.

  for (const term of FORBIDDEN_VISIBLE_TERMS) {
    const regex = new RegExp(`\\\\b${term}\\\\b`, "i");
    expect(
      regex.test(text),
      `forbidden term "${term}" must not appear in ${rootTestId}`,
    ).toBe(false);
  }

}

/** Assert the page has no JS errors captured by attachErrorCapture. */
export async function assertNoErrors(page: Page): Promise<void> {
const errors = await readErrors(page);
expect(errors, errors.join("\n")).toEqual([]);
}
21 changes: 21 additions & 0 deletions 03_implementation/ui/tests/e2e/agents.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { expect, test } from "@playwright/test";
import {
TAB_FIXTURES,
assertNoErrors,
assertNoFakeVisibleText,
attachErrorCapture,
openTab,
} from "./_helpers";

test.beforeEach(async ({ page }) => {
await attachErrorCapture(page);
});

test("Agents tab mounts and shows Hermes Agent operator surface", async ({ page }) => {
await page.goto("/");
await openTab(page, TAB_FIXTURES.agents);
const root = page.getByTestId(TAB_FIXTURES.agents.rootTestId);
await expect(root).toBeVisible();
await assertNoFakeVisibleText(page, TAB_FIXTURES.agents.rootTestId);
await assertNoErrors(page);
});
23 changes: 23 additions & 0 deletions 03_implementation/ui/tests/e2e/approvals.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { expect, test } from "@playwright/test";
import {
TAB_FIXTURES,
assertNoErrors,
assertNoFakeVisibleText,
attachErrorCapture,
fulfillJson,
openTab,
} from "./_helpers";

test.beforeEach(async ({ page }) => {
await attachErrorCapture(page);
});

test("Approvals tab mounts and renders an honest empty queue when no approvals are pending", async ({ page }) => {
await page.route("**/api/approvals**", (route) => fulfillJson(route, { approvals: [] }));
await page.goto("/");
await openTab(page, TAB_FIXTURES.approvals);
const root = page.getByTestId(TAB_FIXTURES.approvals.rootTestId);
await expect(root).toBeVisible();
await assertNoFakeVisibleText(page, TAB_FIXTURES.approvals.rootTestId);
await assertNoErrors(page);
});
23 changes: 23 additions & 0 deletions 03_implementation/ui/tests/e2e/artifacts.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { expect, test } from "@playwright/test";
import {
TAB_FIXTURES,
assertNoErrors,
assertNoFakeVisibleText,
attachErrorCapture,
fulfillJson,
openTab,
} from "./_helpers";

test.beforeEach(async ({ page }) => {
await attachErrorCapture(page);
});

test("Artifacts tab mounts and renders empty-state when no artifacts exist", async ({ page }) => {
await page.route("**/api/artifacts**", (route) => fulfillJson(route, { artifacts: [] }));
await page.goto("/");
await openTab(page, TAB_FIXTURES.artifacts);
const root = page.getByTestId(TAB_FIXTURES.artifacts.rootTestId);
await expect(root).toBeVisible();
await assertNoFakeVisibleText(page, TAB_FIXTURES.artifacts.rootTestId);
await assertNoErrors(page);
});
36 changes: 36 additions & 0 deletions 03_implementation/ui/tests/e2e/autopilot.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { expect, test } from "@playwright/test";
import {
TAB_FIXTURES,
assertNoErrors,
assertNoFakeVisibleText,
attachErrorCapture,
fulfillJson,
openTab,
} from "./_helpers";

test.beforeEach(async ({ page }) => {
await attachErrorCapture(page);
});

test("Autopilot tab mounts and surfaces honest readiness rows", async ({ page }) => {
await page.route("**/api/autopilot/readiness", (route) =>
fulfillJson(route, [
{ id: "printer_connectivity", name: "Printer Connectivity", ready: true, message: "" },
{
id: "api_token_set",
name: "API Token Set",
ready: false,
message: "Token missing from runtime env.",
fix_target: "settings",
},
]),
);
await page.route("**/api/autopilot/guardrails", (route) => fulfillJson(route, []));
await page.goto("/");
await openTab(page, TAB_FIXTURES.autopilot);
const root = page.getByTestId(TAB_FIXTURES.autopilot.rootTestId);
await expect(root).toBeVisible();
// Truthful empty-state for guardrails plus a readiness row should appear.
await assertNoFakeVisibleText(page, TAB_FIXTURES.autopilot.rootTestId);
await assertNoErrors(page);
});
29 changes: 29 additions & 0 deletions 03_implementation/ui/tests/e2e/dashboard.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { expect, test } from "@playwright/test";
import {
TAB_FIXTURES,
assertNoErrors,
assertNoFakeVisibleText,
attachErrorCapture,
openTab,
} from "./_helpers";

test.beforeEach(async ({ page }) => {
await attachErrorCapture(page);
});

test("Dashboard renders live root and exposes the Hermes Agent chat mirror", async ({ page }) => {
await page.goto("/");
await openTab(page, TAB_FIXTURES.dashboard);
// Hermes Agent chat mirror is required from every dashboard surface.
// We assert the chat-mirror trigger is reachable rather than fabricating any content.
const root = page.getByTestId(TAB_FIXTURES.dashboard.rootTestId);
await expect(root).toBeVisible();
await assertNoFakeVisibleText(page, TAB_FIXTURES.dashboard.rootTestId);
await assertNoErrors(page);
});

test("Dashboard direct hash route mounts dashboard root", async ({ page }) => {
await page.goto("/#dashboard");
await expect(page.getByTestId(TAB_FIXTURES.dashboard.rootTestId)).toBeVisible({ timeout: 15_000 });
await assertNoErrors(page);
});
21 changes: 21 additions & 0 deletions 03_implementation/ui/tests/e2e/design.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { expect, test } from "@playwright/test";
import {
TAB_FIXTURES,
assertNoErrors,
assertNoFakeVisibleText,
attachErrorCapture,
openTab,
} from "./_helpers";

test.beforeEach(async ({ page }) => {
await attachErrorCapture(page);
});

test("Design tab mounts and exposes parametric template surface", async ({ page }) => {
await page.goto("/");
await openTab(page, TAB_FIXTURES.design);
const root = page.getByTestId(TAB_FIXTURES.design.rootTestId);
await expect(root).toBeVisible();
await assertNoFakeVisibleText(page, TAB_FIXTURES.design.rootTestId);
await assertNoErrors(page);
});
21 changes: 21 additions & 0 deletions 03_implementation/ui/tests/e2e/gen3d.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { expect, test } from "@playwright/test";
import {
TAB_FIXTURES,
assertNoErrors,
assertNoFakeVisibleText,
attachErrorCapture,
openTab,
} from "./_helpers";

test.beforeEach(async ({ page }) => {
await attachErrorCapture(page);
});

test("3D Generation tab mounts and exposes the generation entry surface", async ({ page }) => {
await page.goto("/");
await openTab(page, TAB_FIXTURES.gen3d);
const root = page.getByTestId(TAB_FIXTURES.gen3d.rootTestId);
await expect(root).toBeVisible();
await assertNoFakeVisibleText(page, TAB_FIXTURES.gen3d.rootTestId);
await assertNoErrors(page);
});
23 changes: 23 additions & 0 deletions 03_implementation/ui/tests/e2e/jobs.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { expect, test } from "@playwright/test";
import {
TAB_FIXTURES,
assertNoErrors,
assertNoFakeVisibleText,
attachErrorCapture,
fulfillJson,
openTab,
} from "./_helpers";

test.beforeEach(async ({ page }) => {
await attachErrorCapture(page);
});

test("Jobs tab mounts and renders an honest empty queue when backend reports none", async ({ page }) => {
await page.route("**/api/jobs", (route) => fulfillJson(route, { jobs: [] }));
await page.goto("/");
await openTab(page, TAB_FIXTURES.jobs);
const root = page.getByTestId(TAB_FIXTURES.jobs.rootTestId);
await expect(root).toBeVisible();
await assertNoFakeVisibleText(page, TAB_FIXTURES.jobs.rootTestId);
await assertNoErrors(page);
});
21 changes: 21 additions & 0 deletions 03_implementation/ui/tests/e2e/learning.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { expect, test } from "@playwright/test";
import {
TAB_FIXTURES,
assertNoErrors,
assertNoFakeVisibleText,
attachErrorCapture,
openTab,
} from "./_helpers";

test.beforeEach(async ({ page }) => {
await attachErrorCapture(page);
});

test("Learning tab mounts and exposes the idle workbench surface", async ({ page }) => {
await page.goto("/");
await openTab(page, TAB_FIXTURES.learning);
const root = page.getByTestId(TAB_FIXTURES.learning.rootTestId);
await expect(root).toBeVisible();
await assertNoFakeVisibleText(page, TAB_FIXTURES.learning.rootTestId);
await assertNoErrors(page);
});
24 changes: 24 additions & 0 deletions 03_implementation/ui/tests/e2e/observe.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { expect, test } from "@playwright/test";
import {
TAB_FIXTURES,
assertNoErrors,
assertNoFakeVisibleText,
attachErrorCapture,
fulfillJson,
openTab,
} from "./_helpers";

test.beforeEach(async ({ page }) => {
await attachErrorCapture(page);
});

test("Observe tab mounts and renders the camera surface root", async ({ page }) => {
// Stub printers so Observe never tries to reach the real S1/T1/V400 fleet.
await page.route("**/api/printers", (route) => fulfillJson(route, { printers: [] }));
await page.goto("/");
await openTab(page, TAB_FIXTURES.observe);
const root = page.getByTestId(TAB_FIXTURES.observe.rootTestId);
await expect(root).toBeVisible();
await assertNoFakeVisibleText(page, TAB_FIXTURES.observe.rootTestId);
await assertNoErrors(page);
});
Loading