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
5 changes: 2 additions & 3 deletions e2e/console/activity.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
expect,
type RunningDaemon,
signIn,
signInWithKeyboard,
startDaemon,
startFleet,
settled,
Expand Down Expand Up @@ -742,9 +743,7 @@ test.describe("the Activity page", () => {

async function keyboardOnly(page: Page, host: RunningDaemon, tab: string): Promise<void> {
await page.goto(host.url);
await page.keyboard.press(tab);
await page.keyboard.type(host.tokens.operator);
await page.keyboard.press("Enter");
await signInWithKeyboard(page, host.tokens.operator, tab);
await expect(page.getByRole("navigation").first()).toBeVisible();

const nav = page.getByRole("link", { name: "Activity", exact: true });
Expand Down
13 changes: 13 additions & 0 deletions e2e/console/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,19 @@ export async function signIn(page: Page, token: string): Promise<void> {
await page.getByRole("button", { name: "Sign in" }).click();
}

// why: while the first identity check runs the page shows "Signing in…" with nothing focusable, so a Tab
// and the typing sent before the form shows are lost; wait for the form and the focus first.
/** Signs in with the keyboard alone: tabs to the token field, types the token and presses Enter. */
export async function signInWithKeyboard(page: Page, token: string, tab: string): Promise<void> {
const field = page.getByLabel("Operator token");
await expect(field).toBeVisible();
await expect(field).toBeEnabled();
await page.keyboard.press(tab);
await expect(field).toBeFocused();
await page.keyboard.type(token);
await page.keyboard.press("Enter");
}

export const NAV = [
{ label: "Overview", path: "/" },
{ label: "Inbox", path: "/inbox" },
Expand Down
5 changes: 2 additions & 3 deletions e2e/console/inbox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
NAV_LABELS,
type RunningDaemon,
signIn,
signInWithKeyboard,
startDaemon,
startFleet,
test,
Expand Down Expand Up @@ -747,9 +748,7 @@ test.describe("the Inbox view", () => {
await page.keyboard.press("Enter");
};
await page.goto(gateway.url);
await page.keyboard.press(tab);
await page.keyboard.type(gateway.tokens.operator);
await page.keyboard.press("Enter");
await signInWithKeyboard(page, gateway.tokens.operator, tab);
await expect(page.getByRole("heading", { level: 1, name: "Overview" })).toBeVisible();

await follow(
Expand Down
15 changes: 12 additions & 3 deletions e2e/console/leases.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
expect,
type RunningDaemon,
signIn,
signInWithKeyboard,
startDaemon,
startFleet,
test,
Expand Down Expand Up @@ -666,10 +667,18 @@ test.describe("the leases page", () => {
await expect(link).toBeFocused();
await page.keyboard.press("Enter");
};
// why: a loaded runner answers the first identity check late; holding it for a second keeps the
// "Signing in…" screen up, so a keyboard sign-in that does not wait for the form loses here every run.
await page.route(
(url) => url.pathname === "/v1/identity",
async (route) => {
await new Promise((resolve) => setTimeout(resolve, 1_000));
await route.continue();
},
{ times: 1 },
);
await page.goto(host.url);
await page.keyboard.press(tab);
await page.keyboard.type(host.tokens.operator);
await page.keyboard.press("Enter");
await signInWithKeyboard(page, host.tokens.operator, tab);
await expect(page.getByRole("heading", { level: 1, name: "Overview" })).toBeVisible();

await follow(
Expand Down
5 changes: 2 additions & 3 deletions e2e/console/long-lists.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
type RunningDaemon,
settled,
signIn,
signInWithKeyboard,
startDaemon,
test as base,
} from "./fixtures.js";
Expand Down Expand Up @@ -700,9 +701,7 @@ test.describe("a single host with 300 leases and 5,000 events", () => {
const back = browserName === "webkit" ? "Alt+Shift+Tab" : "Shift+Tab";
const { host } = seeded;
await page.goto(host.url);
await page.keyboard.press(tab);
await page.keyboard.type(host.tokens.operator);
await page.keyboard.press("Enter");
await signInWithKeyboard(page, host.tokens.operator, tab);
await expect(page.getByRole("heading", { level: 1, name: "Overview" })).toBeVisible();
await tabTo(page, page.getByRole("link", { name: "Leases", exact: true }), tab);
await page.keyboard.press("Enter");
Expand Down
14 changes: 10 additions & 4 deletions e2e/console/queue.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import type { Locator, Page } from "@playwright/test";

import { waitFor } from "../helpers/wait.js";
import { expect, type RunningDaemon, settled, signIn, startDaemon, test } from "./fixtures.js";
import {
expect,
type RunningDaemon,
settled,
signIn,
signInWithKeyboard,
startDaemon,
test,
} from "./fixtures.js";

interface WaitingRequest {
readonly id: string;
Expand Down Expand Up @@ -265,9 +273,7 @@ test.describe("the Queue page", () => {
await page.keyboard.press("Enter");
};
await page.goto(new URL("/queue", host.url).toString());
await page.keyboard.press(tab);
await page.keyboard.type(host.tokens.operator);
await page.keyboard.press("Enter");
await signInWithKeyboard(page, host.tokens.operator, tab);
await expect(page.getByRole("heading", { level: 1, name: "Queue" })).toBeVisible();

await follow(row(page, "agent-b").getByRole("link"));
Expand Down
5 changes: 2 additions & 3 deletions e2e/console/workers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
OLD_PROTOCOL,
type RunningDaemon,
signIn,
signInWithKeyboard,
startDaemon,
startFleet,
test,
Expand Down Expand Up @@ -1268,9 +1269,7 @@ test.describe("the workers page", () => {
await page.keyboard.press("Enter");
};
await page.goto("/");
await page.keyboard.press(tab);
await page.keyboard.type(daemon.tokens.operator);
await page.keyboard.press("Enter");
await signInWithKeyboard(page, daemon.tokens.operator, tab);
await follow(page.getByRole("link", { name: "Fleet", exact: true }));
await expect(page.getByRole("heading", { level: 1, name: "Fleet" })).toBeVisible();

Expand Down
Loading