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
3 changes: 2 additions & 1 deletion apps/smart-ssh-community/frontend/e2e/support/connecting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ export function snapshotStep(
status: ConnectStepSnapshot["status"],
detail: ConnectStepSnapshot["detail"] = null,
errorCode: string | null = null,
durationMs: number | null = null,
): ConnectStepSnapshot {
return { kind, hopIndex: 0, hop: "deploy@h.example.test:22", status, errorCode, detail };
return { kind, hopIndex: 0, hop: "deploy@h.example.test:22", status, errorCode, detail, durationMs };
}

/** The attempt id of the latest `connect` call, once it was made. */
Expand Down
22 changes: 22 additions & 0 deletions apps/smart-ssh-community/frontend/e2e/tests/accessibility.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,28 @@ const SCREENS: Record<string, (app: AppDriver) => Promise<void>> = {
await app.page.getByRole("button", { name: /^alpha\b/ }).click();
await expect(app.page.getByRole("alertdialog")).toBeVisible();
},
"auth prompt": async (app) => {
await app.launch({ settings: { ...ACKNOWLEDGED }, servers: [server({ id: "s-1", name: "alpha" })] });
await app.emit("auth-prompt-needed", {
promptId: "p1",
connectId: "c1",
hop: "root@alpha:22",
kind: "keyboard_interactive",
name: "Two factor",
instructions: "Enter your token",
prompts: [{ text: "Verification code:", echo: true }],
});
await expect(app.page.getByRole("dialog", { name: /root@alpha/ })).toBeVisible();
},
"feature locked dialog": async (app) => {
await app.launch({
settings: { ...ACKNOWLEDGED },
servers: [server({ id: "s-1", name: "alpha" })],
commands: { connect: { error: { message: "Locked", code: null, feature_locked: { feature: "document_export", tier: "free" } } } },
});
await app.page.getByRole("button", { name: /^alpha\b/ }).click();
await expect(app.page.getByRole("dialog")).toBeVisible();
},
"connecting tab": async (app) => {
await app.launch({
settings: { ...ACKNOWLEDGED },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Review screenshots for the connect dialogs and panels (issue #1384):
// SCREENSHOT_LABEL=before|after, SCREENSHOT_SCHEME=dark for the dark theme.
import { expect, test, type AppDriver } from "../support/app";
import { emitProgress, snapshotStep } from "../support/connecting";
import { ACKNOWLEDGED, failingStepLog, populated, server } from "../support/data";
import { captureCurrent } from "../support/screenshots";

const scheme = process.env.SCREENSHOT_SCHEME === "dark" ? "dark" : "light";
const base = () => ({ settings: { ...ACKNOWLEDGED }, servers: [server({ id: "s-1", name: "alpha" })] });
const connect = (app: AppDriver) => app.page.getByRole("button", { name: /^alpha\b/ }).click();

const SCREENS: Record<string, (app: AppDriver) => Promise<void>> = {
"hostkey-unknown": async (app) => {
await app.launch({ ...base(), hostKeys: { "s-1": { kind: "unknown", fingerprint: "SHA256:abc", keyType: "ssh-ed25519" } } });
await connect(app);
await expect(app.page.getByRole("dialog")).toBeVisible();
},
"hostkey-mismatch": async (app) => {
await app.launch({ ...base(), hostKeys: { "s-1": { kind: "mismatch", fingerprint: "SHA256:new", expectedFingerprint: "SHA256:old", keyType: "ssh-ed25519" } } });
await connect(app);
await expect(app.page.getByRole("alertdialog")).toBeVisible();
},
"auth-prompt": async (app) => {
await app.launch(base());
await app.emit("auth-prompt-needed", {
promptId: "p1", connectId: "c1", hop: "root@alpha:22", kind: "keyboard_interactive",
name: "Two factor", instructions: "Enter your token", prompts: [{ text: "Verification code:", echo: true }],
});
await expect(app.page.getByRole("dialog", { name: /root@alpha/ })).toBeVisible();
},
"feature-locked": async (app) => {
await app.launch({ ...base(), commands: { connect: { error: { message: "Locked", code: null, feature_locked: { feature: "document_export", tier: "free" } } } } });
await connect(app);
await expect(app.page.getByRole("dialog")).toBeVisible();
},
"connecting-running": async (app) => {
await app.launch({ ...base(), commands: { connect: { hold: true } } });
await connect(app);
await emitProgress(app, [
snapshotStep("dnsResolution", "ok", null, null, 3),
snapshotStep("tcpConnect", "ok", null, null, 12),
snapshotStep("hostKeyCheck", "warning", null, null, 1),
snapshotStep("handshake", "running", { code: "waitingForResponse" }),
]);
await expect(app.page.getByTestId("connect-progress-list")).toBeVisible();
},
"connect-failed": async (app) => {
await app.launch({ ...base(), commands: { connect: { hold: true } } });
await connect(app);
await emitProgress(app, [snapshotStep("authentication", "failed", { code: "authMethod", method: "password" }, "SSH_AUTH_FAILED")]);
await app.release("connect", { error: { message: "Authentication failed", code: "SSH_AUTH_FAILED", connect_log: failingStepLog(2) } });
const log = app.page.getByTestId("connect-step-log");
if ((await log.getAttribute("open")) === null) await log.locator("summary").click();
await expect(log.locator("[data-failed='true']")).toBeVisible();
},
"unusable-server": async (app) => {
await app.launch({
...populated(),
commands: { list_unusable_servers: { result: [{ id: "u-1", name: "legacy-box", host: "legacy.example.test", groupId: null, reason: "unknown_auth_method" }] } },
});
await app.page.getByRole("button", { name: "Manage", exact: true }).click();
await app.page.getByRole("treeitem", { name: /legacy-box/ }).click();
await expect(app.page.getByRole("button", { name: /Delete/ }).first()).toBeVisible();
},
toast: async (app) => {
await app.launch({
...base(),
hostKeys: { "s-1": { kind: "unknown", fingerprint: "SHA256:abc", keyType: "ssh-ed25519" } },
commands: { confirm_host_key: { error: { message: "Could not save the key", code: null } } },
});
await connect(app);
await app.page.getByRole("button", { name: "Trust", exact: true }).click();
await expect(app.page.getByText("Could not save the key")).toBeVisible();
},
};

for (const [name, open] of Object.entries(SCREENS)) {
test(`screenshot ${name} (${scheme})`, async ({ app }) => {
if (process.env.SCREENSHOT_LABEL === undefined) test.skip(true, "set SCREENSHOT_LABEL to capture");
await app.page.emulateMedia({ colorScheme: scheme });
await open(app);
await captureCurrent(app.page, `${name}-${scheme}`);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,19 @@ test("opens a focused connecting tab before connect resolves and lists the steps

await emitProgress(app, [
snapshotStep("dnsResolution", "ok", { code: "contacting", target: "h.example.test:22" }),
snapshotStep("tcpConnect", "ok", { code: "contacting", target: "10.0.0.1:22" }),
snapshotStep("tcpConnect", "ok", { code: "contacting", target: "10.0.0.1:22" }, null, 1530),
snapshotStep("hostKeyCheck", "running", { code: "waitingForDecision" }),
]);
const rows = page.getByTestId("connect-progress-list").getByRole("listitem");
await expect(rows).toHaveCount(3);
await expect(rows.nth(0)).toContainText("DNS resolution");
await expect(rows.nth(0)).toContainText("h.example.test:22");
await expect(rows.nth(2)).toContainText("waiting for your decision");
// Finished steps show a mono duration, a running step none.
await expect(rows.nth(1).getByTestId("step-duration")).toHaveText("1.5 s");
await expect(rows.nth(1).getByTestId("step-duration")).toHaveClass(/font-mono/);
await expect(rows.nth(2).getByTestId("step-duration")).toHaveCount(0);
await expect(rows.nth(1).locator('[data-icon="check"]')).toHaveCount(1);
await expectNoSeriousA11yViolations(page, "connecting tab");
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ test("host key prompt: shows the key, accepts nothing without a click, Reject le
await expect(dialog).toContainText("fresh.example.test:2222");
await expect(dialog).toContainText(FINGERPRINT);
await expect(dialog).toContainText("ssh-ed25519");
// Unknown variant: plain "Offered" row, no danger band or ticks.
await expect(dialog.getByRole("term").filter({ hasText: /^Offered$/ })).toHaveCount(1);
await expect(dialog.getByTestId("host-key-header")).toHaveCount(0);

// Nothing is decided while the dialog is open.
expect(await app.calls("confirm_host_key")).toEqual([]);
Expand Down Expand Up @@ -64,6 +67,11 @@ test("host key prompt: a changed key shows both fingerprints, accepts nothing wi
await expect(dialog).toContainText(KNOWN);
await expect(dialog).toContainText(FINGERPRINT);
await expect(dialog).toContainText("ssh-ed25519");
// Mismatch variant: danger header band with warn icon, ticks, label/value rows.
await expect(dialog.getByTestId("host-key-header")).toHaveClass(/bg-danger-subtle/);
await expect(dialog.getByTestId("host-key-header").locator('[data-icon="warn"]')).toHaveCount(1);
await expect(page.getByTestId("dialog-ticks")).toHaveCount(1);
await expect(dialog.getByRole("term")).toHaveText(["Known", "Offered Now", "Key type"]);

expect(await app.calls("confirm_host_key")).toEqual([]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useRef } from "react";
import { useTranslation } from "react-i18next";
import type { AuthPromptNeededEvent } from "../api/types";
import { TECHNICAL_INPUT_PROPS } from "../lib/technicalInputProps";
import { Button, DialogFrame, Field, FIELD_CONTROL_CLASS } from "./ui";
import { Button, DialogFrame, Field, FIELD_CONTROL_CLASS, Icon } from "./ui";

interface AuthPromptDialogProps {
event: AuthPromptNeededEvent;
Expand Down Expand Up @@ -55,6 +55,7 @@ export function AuthPromptDialog({ event, onSubmit, onCancel }: AuthPromptDialog
<DialogFrame
layer="app"
size="md"
icon={<Icon name="lock" />}
title={t("authPrompt.title", { hop: event.hop })}
onClose={cancel}
initialFocusRef={firstRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ beforeEach(() => {
});

describe("AuthPromptHost", () => {
it("renders the foundation dialog with a lock icon in the header", async () => {
const { show } = renderHost();
show(kbd);
const dialog = await screen.findByRole("dialog");
expect(dialog.querySelector('[data-icon="lock"]')).not.toBeNull();
expect(dialog).toHaveClass("bg-surface-raised");
});

it("masks echo-off prompts, shows echo-on prompts plain and focuses the first field", async () => {
const { show } = renderHost();
show(kbd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useTranslation } from "react-i18next";
import type { ConnectStepDetail, ConnectStepSnapshot } from "../api/types";
import { Spinner, Icon } from "./ui";
import type { TranslateFn } from "../i18nTypes";
import { formatDuration } from "../lib/connectStepLog";

type T = TranslateFn;

Expand Down Expand Up @@ -45,7 +46,7 @@ export function ConnectProgressList({ steps }: { steps: ConnectStepSnapshot[] })
<ul
aria-label={t("connectTab.stepsLabel")}
data-testid="connect-progress-list"
className="space-y-1 text-sm"
className="border border-border-strong bg-surface-raised text-sm"
>
{steps.map((step, i) => {
const failed = step.status === "failed";
Expand All @@ -57,8 +58,8 @@ export function ConnectProgressList({ steps }: { steps: ConnectStepSnapshot[] })
data-failed={failed ? "true" : undefined}
className={
failed
? "flex items-baseline gap-2 rounded border border-danger-border-strong bg-danger-subtle/40 px-2 py-1 text-danger-fg-soft"
: "flex items-baseline gap-2 px-2 py-1"
? "flex items-baseline gap-2 border-t border-danger-border bg-danger-subtle px-3 py-2 text-danger-fg first:border-t-0"
: "flex items-baseline gap-2 border-t border-border px-3 py-2 first:border-t-0"
}
>
<span className="inline-flex w-4 shrink-0 justify-center text-fg-muted" aria-hidden="true">
Expand All @@ -68,6 +69,8 @@ export function ConnectProgressList({ steps }: { steps: ConnectStepSnapshot[] })
"–"
) : step.status === "ok" ? (
<Icon name="check" className="text-success-fg" />
) : step.status === "warning" ? (
<Icon name="warn" className="text-warning-fg" />
) : (
<Icon name="x" />
)}
Expand All @@ -78,7 +81,12 @@ export function ConnectProgressList({ steps }: { steps: ConnectStepSnapshot[] })
: t(`connectLog.step.${step.kind}`)}
</span>
{multiHop && <span className="text-fg-subtle">{step.hop}</span>}
{detail && <span className="break-all text-fg-subtle">{detail}</span>}
{detail && <span className="font-mono text-xs break-all text-fg-subtle">{detail}</span>}
{step.durationMs !== null && (
<span className="ml-auto shrink-0 font-mono text-xs text-fg-subtle" data-testid="step-duration">
{formatDuration(step.durationMs)}
</span>
)}
</li>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function ConnectStepLog({ steps }: { steps: ConnectStepRecord[] }) {
</span>
<span className="min-w-0 font-medium">{stepLabel(t, record.step, record.status.state)}</span>
<span>{stepStatusText(t, record)}</span>
<span className="text-fg-subtle">{formatDuration(record.durationMs)}</span>
<span className="font-mono text-fg-subtle">{formatDuration(record.durationMs)}</span>
</div>
{details && <div className="ml-5 break-all text-fg-subtle">{details}</div>}
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const snap = (
kind: ConnectStepSnapshot["kind"],
status: ConnectStepSnapshot["status"],
detail: ConnectStepSnapshot["detail"] = null,
): ConnectStepSnapshot => ({ kind, hopIndex: 0, hop: "u@h:22", status, errorCode: null, detail });
): ConnectStepSnapshot => ({ kind, hopIndex: 0, hop: "u@h:22", status, errorCode: null, detail, durationMs: null });

function tab(overrides: Partial<SessionTab>): SessionTab {
return {
Expand Down Expand Up @@ -40,6 +40,25 @@ function view(t: SessionTab, onRetry = vi.fn(), onClose = vi.fn()) {
}

describe("ConnectingTabView", () => {
it("shows status icons per step (incl. warning) and mono durations only for finished steps", () => {
view(
tab({
progress: [
{ ...snap("dnsResolution", "ok"), durationMs: 42 },
{ ...snap("outdatedAlgorithms", "warning"), durationMs: 1530 },
snap("hostKeyCheck", "running"),
],
}),
);
const items = screen.getAllByRole("listitem");
expect(items[0].querySelector('[data-icon="check"]')).not.toBeNull();
expect(items[1].querySelector('[data-icon="warn"]')).not.toBeNull();
expect(items[0].querySelector('[data-testid="step-duration"]')).toHaveTextContent("42 ms");
expect(items[0].querySelector('[data-testid="step-duration"]')).toHaveClass("font-mono");
expect(items[1].querySelector('[data-testid="step-duration"]')).toHaveTextContent("1.5 s");
expect(items[2].querySelector('[data-testid="step-duration"]')).toBeNull();
});

it("lists the steps with detail texts and offers Cancel while running", () => {
const { onClose } = view(
tab({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,31 @@ describe.each(branches)("HostKeyDialog ($name)", ({ event, role, rejectLabel, tr
expect(description?.textContent?.length ?? 0).toBeGreaterThan(0);
});

it("renders label/value rows and the danger header band only for the mismatch", () => {
renderDialog(event);
expect(screen.getByTestId("host-key-address")).toHaveClass("font-mono");
if (role === "alertdialog") {
expect(screen.getByTestId("host-key-header")).toHaveClass("bg-danger-subtle");
expect(screen.getByText("Bekannt")).toBeInTheDocument();
} else {
expect(screen.queryByTestId("host-key-header")).toBeNull();
expect(screen.queryByTestId("dialog-ticks")).toBeNull();
}
});

it("labels the fingerprint row 'Offered Now' for a mismatch and 'Offered' for an unknown host", () => {
renderDialog(event);
const labels = screen.getAllByRole("term").map((n) => n.textContent);
if (role === "alertdialog") {
expect(labels).toContain("Jetzt angeboten");
} else {
expect(labels).toContain("Angeboten");
expect(labels).not.toContain("Jetzt angeboten");
}
});

it("draws the danger corner ticks, hidden in the narrow layout, with an offset shadow", () => {
if (role !== "alertdialog") return;
renderDialog(event);
const wrapper = screen.getByTestId("dialog-ticks");
expect(wrapper).toHaveClass("narrow:hidden");
Expand Down Expand Up @@ -412,8 +436,9 @@ describe("HostKeyDialog — unbekannt und geändert bleiben unterscheidbar (Issu

expect(unknown.className).toContain("border-border-strong");
expect(unknown.className).not.toContain("red");
expect(mismatch.className).toContain("border-danger");
expect(mismatch.className).toContain("bg-danger-subtle/95");
expect(mismatch.className).toContain("border-danger-border");
expect(unknown.className).not.toContain("border-danger-border");
expect(mismatch.className).toContain("bg-surface-raised");

expect(unknown.buttons).toEqual(["Ablehnen", "Vertrauen"]);
expect(mismatch.buttons).toEqual(["Verbindung abbrechen", "Trotzdem vertrauen"]);
Expand All @@ -432,7 +457,8 @@ describe("HostKeyDialog — unbekannt und geändert bleiben unterscheidbar (Issu
describe.each(branches)("HostKeyDialog key type ($name)", ({ event }) => {
it("shows the key type of the offered key", () => {
renderDialog({ ...event, keyType: "ssh-ed25519" });
expect(screen.getByTestId("host-key-type")).toHaveTextContent("Schlüsseltyp: ssh-ed25519");
expect(screen.getByTestId("host-key-type")).toHaveTextContent("Schlüsseltypssh-ed25519");
expect(screen.getByText("ssh-ed25519")).toHaveClass("select-text");
expect(screen.getByText("example.com:22")).toBeInTheDocument();
expect(screen.getByText(event.fingerprint)).toBeInTheDocument();
});
Expand Down
Loading
Loading