Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

feat(console): a named-page pager under every wizard page

Petr Baucha583d7fb9c0a
diff --git a/console/apps/switch-console-desktop/src/renderer/features/room-templates/room-template-import-view.tsx b/console/apps/switch-console-desktop/src/renderer/features/room-templates/room-template-import-view.tsx
index 4adc99d46..dfb3128e8 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/room-templates/room-template-import-view.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/room-templates/room-template-import-view.tsx
@@ -24,6 +24,7 @@ import { Button } from '@renderer/lib/ui/button';
import { Field, FieldGroup, FieldLabel } from '@renderer/lib/ui/field';
import { Input } from '@renderer/lib/ui/input';
import { SegmentedControl } from '@renderer/lib/ui/segmented-control';
+import { StepPager } from '@renderer/lib/ui/step-pager';
// ── Source step ─────────────────────────────────────────────────────────────
@@ -40,6 +41,7 @@ function SourceStep({
onYamlChange,
parseError,
onNext,
+ canAdvance,
onFileSelect,
onSaveToServer,
saving,
@@ -49,6 +51,9 @@ function SourceStep({
onYamlChange: (text: string) => void;
parseError: string | null;
onNext: () => void;
+ /** Whether there is a document to go on with. Decided by the page, so the
+ * Next button and the pager's arrow cannot come to different answers. */
+ canAdvance: boolean;
onFileSelect: (name: string) => void;
onSaveToServer: () => void;
saving: boolean;
@@ -175,7 +180,7 @@ function SourceStep({
<Save className="mr-1.5 size-3.5" />
{saving ? 'Saving…' : 'Save to workspace'}
</Button>
- <Button disabled={!yamlText.trim() || saving} onClick={onNext}>
+ <Button disabled={!canAdvance} onClick={onNext}>
Next
<ArrowRight className="ml-1.5 size-3.5" />
</Button>
@@ -330,6 +335,10 @@ const TemplateImportPanel = observer(function TemplateImportPanel() {
}
}, [initialTemplateId, initialYaml, editing, serverId, handleParseAndAdvance]);
+ // The pager's arrow only repeats the Next button below, so both read this
+ // rather than spelling the condition once each and drifting apart.
+ const canAdvance = yamlText.trim().length > 0 && !saving;
+
if (editingTemplate) {
const nothingChanged =
yamlText === initialYaml &&
@@ -379,6 +388,7 @@ const TemplateImportPanel = observer(function TemplateImportPanel() {
onYamlChange={setYamlText}
parseError={parseError}
onNext={handleParseAndAdvance}
+ canAdvance={canAdvance}
onFileSelect={setSourceName}
onSaveToServer={handleSaveToServer}
saving={saving}
@@ -401,12 +411,20 @@ const TemplateImportPanel = observer(function TemplateImportPanel() {
<ServerPage
title="Import a template"
description="Paste an agent, room or group template, or pick a YAML file. The document says which it is."
+ footer={
+ <StepPager
+ pageName="Pick a template"
+ onBack={null}
+ onNext={canAdvance ? () => void handleParseAndAdvance() : null}
+ />
+ }
>
<SourceStep
yamlText={yamlText}
onYamlChange={setYamlText}
parseError={parseError}
onNext={handleParseAndAdvance}
+ canAdvance={canAdvance}
onFileSelect={setSourceName}
onSaveToServer={handleSaveToServer}
saving={saving}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/AddServerModal.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/AddServerModal.tsx
index 868374054..cb01771a8 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/AddServerModal.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/AddServerModal.tsx
@@ -19,7 +19,7 @@ import {
import { Field, FieldGroup, FieldLabel } from '@renderer/lib/ui/field';
import { Input } from '@renderer/lib/ui/input';
import { Spinner } from '@renderer/lib/ui/spinner';
-import { WizardStepHeader } from '@renderer/lib/ui/wizard-step-header';
+import { StepPager } from '@renderer/lib/ui/step-pager';
import type {
AddServerChoiceName,
AddServerStepName,
@@ -91,16 +91,6 @@ const _stepsAreComplete: Step extends AddServerStepName ? true : never = true;
void _stepsAreExhaustive;
void _stepsAreComplete;
-/**
- * How many steps connecting to a server someone else runs takes: choose that
- * path, point at the server, sign in, then say which messaging account is you.
- *
- * The chooser is step 1 but carries no counter — the other two paths it leads
- * to are not four steps, and a count shown before the choice would promise a
- * length that depends on what is clicked next.
- */
-const CONNECT_STEPS = 4;
-
/**
* Add a Switch server: run one here, run one on a host you have onboarded, or
* connect to one someone else runs.
@@ -239,8 +229,6 @@ export const AddServerModal = observer(function AddServerModal(props: Props) {
<LinkAccountsStep
serverId={connected.id}
serverName={connected.name}
- step={CONNECT_STEPS}
- of={CONNECT_STEPS}
onDone={() => finish(connected.id)}
/>
);
@@ -306,6 +294,7 @@ function ChooseStep({
Cancel
</Button>
</DialogFooter>
+ <StepPager pageName="Add a server" onBack={null} onNext={null} />
</>
);
}
@@ -373,6 +362,11 @@ const LocalSetupStep = observer(function LocalSetupStep({
const dockerUnavailable = docker && !docker.available ? docker : null;
const idle = !running && !starting;
+ // The pager's back arrow only ever repeats the footer's Back, so the two read
+ // one const. Held shut while the stack comes up: leaving mid-install abandons
+ // a Docker start with nothing watching it.
+ const goBack = onBack && !starting ? onBack : null;
+
const primaryLabel = running ? 'Done' : store.phase === 'error' ? 'Retry' : 'Start';
const onPrimary = () => {
if (running) onDone(store.status?.serverId ?? null);
@@ -449,8 +443,8 @@ const LocalSetupStep = observer(function LocalSetupStep({
)}
</DialogContentArea>
<DialogFooter>
- {onBack && !starting ? (
- <Button variant="outline" onClick={onBack}>
+ {goBack ? (
+ <Button variant="outline" onClick={goBack}>
Back
</Button>
) : (
@@ -462,6 +456,7 @@ const LocalSetupStep = observer(function LocalSetupStep({
{starting ? 'Starting…' : primaryLabel}
</ConfirmButton>
</DialogFooter>
+ <StepPager pageName="Set up a server" onBack={goBack} onNext={null} />
</>
);
});
@@ -551,6 +546,10 @@ const RemoteHostSetupStep = observer(function RemoteHostSetupStep({
const hostBlocked = sshHost ? store.isHostBlocked(sshHost) : false;
const canStart = !!sshHost && name.trim().length > 0 && dockerReady && !starting && !hostBlocked;
+ // One const for the footer's Back and the pager's back arrow, which only
+ // repeats it. Shut while the stack comes up, for the same reason as the
+ // local page: an abandoned Docker start has nothing watching it.
+ const goBack = starting ? null : onBack;
const primaryLabel = running ? 'Done' : status?.phase === 'error' ? 'Retry' : 'Start';
const onPrimary = () => {
if (running) onDone(sshHost ? (store.statusFor(sshHost).serverId ?? null) : null);
@@ -684,8 +683,8 @@ const RemoteHostSetupStep = observer(function RemoteHostSetupStep({
)}
</DialogContentArea>
<DialogFooter>
- {!starting ? (
- <Button variant="outline" onClick={onBack}>
+ {goBack ? (
+ <Button variant="outline" onClick={goBack}>
Back
</Button>
) : (
@@ -697,6 +696,7 @@ const RemoteHostSetupStep = observer(function RemoteHostSetupStep({
{starting ? 'Starting…' : primaryLabel}
</ConfirmButton>
</DialogFooter>
+ <StepPager pageName="Set up on a remote host" onBack={goBack} onNext={null} />
</>
);
});
@@ -795,15 +795,16 @@ const ExternalServerStep = observer(function ExternalServerStep({
onSuccess();
}, [isValid, isEdit, savedId, trimmedName, trimmedGateway, trimmedApi, onSuccess, onConnected]);
+ // The footer's Back and the pager's back arrow are the same move, so they
+ // read one const. Shut while the form is submitting: the write registers a
+ // server, and stepping off it mid-way leaves one behind with no page on it.
+ const goBack = onBack && !submitting ? onBack : null;
+
return (
<>
- {isEdit ? (
- <DialogHeader showCloseButton={false}>
- <DialogTitle>Edit connection</DialogTitle>
- </DialogHeader>
- ) : (
- <WizardStepHeader title="Connect to an existing server" step={2} of={CONNECT_STEPS} />
- )}
+ <DialogHeader showCloseButton={false}>
+ <DialogTitle>{isEdit ? 'Edit connection' : 'Connect to an existing server'}</DialogTitle>
+ </DialogHeader>
<DialogContentArea className="pt-0">
<FieldGroup>
{!isEdit && (
@@ -843,13 +844,20 @@ const ExternalServerStep = observer(function ExternalServerStep({
</FieldGroup>
</DialogContentArea>
<DialogFooter>
- <Button variant="outline" onClick={onBack ?? onClose}>
+ <Button
+ variant="outline"
+ onClick={goBack ?? onClose}
+ disabled={onBack !== undefined && goBack === null}
+ >
{onBack ? 'Back' : 'Cancel'}
</Button>
<ConfirmButton onClick={() => void handleSubmit()} disabled={!isValid || submitting}>
{submitting ? (savedId ? 'Saving…' : 'Adding…') : savedId ? 'Save changes' : 'Add server'}
</ConfirmButton>
</DialogFooter>
+ {/* Editing a connection is one dialog rather than a flow, and a pager on
+ it would invent pages either side that do not exist. */}
+ {!isEdit && <StepPager pageName="Connect to a server" onBack={goBack} onNext={null} />}
</>
);
});
@@ -883,9 +891,14 @@ const SignInStep = observer(function SignInStep({
if (await signIn.signInWithPassword()) onSignedIn();
};
+ // One const for the footer's Back and the pager's back arrow that repeats it.
+ const goBack = signIn.submitting ? null : onBack;
+
return (
<>
- <WizardStepHeader title={`Sign in to ${server.name}`} step={3} of={CONNECT_STEPS} />
+ <DialogHeader showCloseButton={false}>
+ <DialogTitle>Sign in to {server.name}</DialogTitle>
+ </DialogHeader>
<DialogContentArea className="pt-0">
<ServerSignInFields
signIn={signIn}
@@ -895,7 +908,7 @@ const SignInStep = observer(function SignInStep({
/>
</DialogContentArea>
<DialogFooter>
- <Button variant="outline" onClick={onBack} disabled={signIn.submitting}>
+ <Button variant="outline" onClick={onBack} disabled={goBack === null}>
Back
</Button>
{canUsePassword ? (
@@ -917,6 +930,7 @@ const SignInStep = observer(function SignInStep({
)
)}
</DialogFooter>
+ <StepPager pageName="Sign in" onBack={goBack} onNext={null} />
</>
);
});
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/link-accounts-step.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/link-accounts-step.tsx
index 03844e40b..cbf165cf7 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/link-accounts-step.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/link-accounts-step.tsx
@@ -9,9 +9,14 @@ import { failureText } from '@renderer/lib/errors/describe-failure';
import { rpc } from '@renderer/lib/ipc';
import { Button } from '@renderer/lib/ui/button';
import { ConfirmButton } from '@renderer/lib/ui/confirm-button';
-import { DialogContentArea, DialogFooter } from '@renderer/lib/ui/dialog';
+import {
+ DialogContentArea,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from '@renderer/lib/ui/dialog';
import { Spinner } from '@renderer/lib/ui/spinner';
-import { WizardStepHeader } from '@renderer/lib/ui/wizard-step-header';
+import { StepPager } from '@renderer/lib/ui/step-pager';
import type { LinkedIdentity, RemoteBridge } from '@shared/core/switch-servers/switch-servers';
import { BridgeIdentitySearch } from './bridge-identity-search';
import { connectedAppsSummary, LINK_ACCOUNTS_LATER } from './link-accounts-prose';
@@ -29,14 +34,10 @@ import { useMyIdentities } from './use-my-identities';
export const LinkAccountsStep = observer(function LinkAccountsStep({
serverId,
serverName,
- step,
- of,
onDone,
}: {
serverId: string;
serverName: string;
- step: number;
- of: number;
onDone: () => void;
}) {
// Which app's directory is open, or null while the list is. Linking happens
@@ -52,14 +53,16 @@ export const LinkAccountsStep = observer(function LinkAccountsStep({
});
const { identities } = useMyIdentities(workspaceId);
+ // The footer's Back and the pager's back arrow are the same move, so they
+ // read one const.
+ const goBack = () => setLinking(null);
+
if (linking && workspaceId !== null) {
return (
<>
- <WizardStepHeader
- title={`Link your ${bridgePlatformLabel(linking.type)} account`}
- step={step}
- of={of}
- />
+ <DialogHeader showCloseButton={false}>
+ <DialogTitle>Link your {bridgePlatformLabel(linking.type)} account</DialogTitle>
+ </DialogHeader>
<DialogContentArea className="pt-0">
<div className="flex w-full flex-col gap-4">
<p className="text-sm text-foreground-muted">
@@ -77,17 +80,24 @@ export const LinkAccountsStep = observer(function LinkAccountsStep({
</div>
</DialogContentArea>
<DialogFooter>
- <Button variant="outline" onClick={() => setLinking(null)}>
+ <Button variant="outline" onClick={goBack}>
Back
</Button>
</DialogFooter>
+ <StepPager
+ pageName={`Link ${bridgePlatformLabel(linking.type)}`}
+ onBack={goBack}
+ onNext={null}
+ />
</>
);
}
return (
<>
- <WizardStepHeader title="Link your messaging accounts" step={step} of={of} />
+ <DialogHeader showCloseButton={false}>
+ <DialogTitle>Link your messaging accounts</DialogTitle>
+ </DialogHeader>
<DialogContentArea className="pt-0">
<BridgeList
serverName={serverName}
@@ -102,6 +112,9 @@ export const LinkAccountsStep = observer(function LinkAccountsStep({
<DialogFooter>
<ConfirmButton onClick={onDone}>Done</ConfirmButton>
</DialogFooter>
+ {/* The last page of the flow, and signing in cannot be undone by walking
+ backwards, so there is nowhere for either arrow to go. */}
+ <StepPager pageName="Link accounts" onBack={null} onNext={null} />
</>
);
});
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-page.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-page.tsx
index cd80e2b23..c1d76cb5f 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-page.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-page.tsx
@@ -10,6 +10,7 @@ export function ServerPage({
title,
description,
action,
+ footer,
children,
}: {
title: string;
@@ -17,20 +18,26 @@ export function ServerPage({
/** Header-level action, where the page has one. Agents has none: its add
* affordance is the first tile of its grid. */
action?: ReactNode;
+ /** A bar pinned under the page, outside the scrolling content — a pager for
+ * the pages that are one step of a flow. */
+ footer?: ReactNode;
children: ReactNode;
}) {
return (
- <div className="relative z-10 flex min-h-0 flex-1 flex-col overflow-auto bg-background">
- <div className="mx-auto w-full max-w-4xl space-y-6 p-6">
- <header className="flex items-start justify-between gap-3">
- <div className="min-w-0">
- <h2 className="truncate text-2xl font-semibold text-foreground">{title}</h2>
- <p className="mt-1 text-sm text-foreground-muted">{description}</p>
- </div>
- {action && <div className="flex shrink-0 items-center gap-2">{action}</div>}
- </header>
- {children}
+ <div className="relative z-10 flex min-h-0 flex-1 flex-col bg-background">
+ <div className="flex min-h-0 flex-1 flex-col overflow-auto">
+ <div className="mx-auto w-full max-w-4xl space-y-6 p-6">
+ <header className="flex items-start justify-between gap-3">
+ <div className="min-w-0">
+ <h2 className="truncate text-2xl font-semibold text-foreground">{title}</h2>
+ <p className="mt-1 text-sm text-foreground-muted">{description}</p>
+ </div>
+ {action && <div className="flex shrink-0 items-center gap-2">{action}</div>}
+ </header>
+ {children}
+ </div>
</div>
+ {footer}
</div>
);
}
diff --git a/console/apps/switch-console-desktop/src/renderer/lib/ui/step-pager.tsx b/console/apps/switch-console-desktop/src/renderer/lib/ui/step-pager.tsx
new file mode 100644
index 000000000..85e8c1e1a
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/lib/ui/step-pager.tsx
@@ -0,0 +1,67 @@
+import { ChevronLeft, ChevronRight } from 'lucide-react';
+import { cn } from '@renderer/utils/utils';
+import { Button } from './button';
+
+/**
+ * The bar at the foot of a paged flow: which page you are on, and the way back
+ * or on from it.
+ *
+ * It names the page rather than counting it. A count is only honest once the
+ * sequence has a fixed length, and these flows branch — how many pages are left
+ * after "Add a server" depends on the answer given there — so a number would
+ * have to renumber itself halfway through.
+ *
+ * An arrow only repeats a move the page already offers — its Back, its Next.
+ * Where the way on is a button that installs a stack, signs you in or creates a
+ * server, the page passes a null `onNext`: a chevron whose whole label is "next"
+ * must not be the thing that commits you to any of those. The inert arrow stays
+ * on screen rather than disappearing, so the bar keeps its shape from page to
+ * page and the name does not shift under the eye.
+ *
+ * An inert arrow is `aria-disabled` rather than `disabled`, and says in its
+ * label why it leads nowhere. A chevron is already a control that explains
+ * nothing on sight; dropping it out of the tab order as well would leave the
+ * one place the reason is written unreachable by the people who most need it.
+ */
+export function StepPager({
+ pageName,
+ onBack,
+ onNext,
+}: {
+ pageName: string;
+ onBack: (() => void) | null;
+ onNext: (() => void) | null;
+}) {
+ return (
+ <nav
+ aria-label="Pages in this flow"
+ className="flex shrink-0 items-center justify-center gap-4 border-t border-border bg-background-quaternary-1 px-3 py-1.5"
+ >
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ aria-label={onBack === null ? 'Previous page — this is the first page' : 'Previous page'}
+ aria-disabled={onBack === null || undefined}
+ className={cn(onBack === null && 'opacity-50')}
+ onClick={onBack ?? undefined}
+ >
+ <ChevronLeft className="size-3.5" />
+ </Button>
+ <span aria-current="step" className="min-w-40 text-center text-xs text-foreground-muted">
+ {pageName}
+ </span>
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ aria-label={
+ onNext === null ? 'Next page — use the button on this page to go on' : 'Next page'
+ }
+ aria-disabled={onNext === null || undefined}
+ className={cn(onNext === null && 'opacity-50')}
+ onClick={onNext ?? undefined}
+ >
+ <ChevronRight className="size-3.5" />
+ </Button>
+ </nav>
+ );
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/lib/ui/wizard-step-header.tsx b/console/apps/switch-console-desktop/src/renderer/lib/ui/wizard-step-header.tsx
deleted file mode 100644
index 61c2c4a9c..000000000
--- a/console/apps/switch-console-desktop/src/renderer/lib/ui/wizard-step-header.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import { DialogHeader, DialogTitle } from './dialog';
-
-/**
- * A dialog header that says where in a sequence you are.
- *
- * The count is only honest once the sequence has a fixed length, so a step that
- * might or might not be reached must not be counted — a wizard that renumbers
- * itself halfway through is worse than one that never numbered itself at all.
- */
-export function WizardStepHeader({ title, step, of }: { title: string; step: number; of: number }) {
- return (
- <DialogHeader className="flex-col items-start gap-1">
- <DialogTitle>{title}</DialogTitle>
- <p className="text-xs text-foreground-muted">
- Step {step} of {of}
- </p>
- </DialogHeader>
- );
-}
diff --git a/console/apps/switch-console-desktop/src/renderer/tests/browser/step-pager.test.tsx b/console/apps/switch-console-desktop/src/renderer/tests/browser/step-pager.test.tsx
new file mode 100644
index 000000000..de75c58b0
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/tests/browser/step-pager.test.tsx
@@ -0,0 +1,106 @@
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { StepPager } from '@renderer/lib/ui/step-pager';
+
+/**
+ * The pager is the only thing on a wizard page that says where you are, and its
+ * arrows are unlabelled. So what matters is that an arrow with nowhere to go
+ * cannot be pressed: a page that is mid-install passes no way back, and a
+ * chevron that fired anyway would abandon the install with nothing watching it.
+ */
+
+let container: HTMLDivElement | null = null;
+let root: Root | null = null;
+
+afterEach(async () => {
+ if (root) await act(async () => root!.unmount());
+ container?.remove();
+ container = null;
+ root = null;
+});
+
+async function render(node: React.ReactNode): Promise<HTMLDivElement> {
+ container = document.createElement('div');
+ document.body.appendChild(container);
+ root = createRoot(container);
+ await act(async () => root!.render(node));
+ return container;
+}
+
+// Matched on the start of the label, because an arrow leading nowhere appends
+// the reason to its own.
+function arrow(el: HTMLElement, label: string): HTMLButtonElement {
+ const found = el.querySelector<HTMLButtonElement>(`[aria-label^="${label}"]`);
+ expect(found).not.toBeNull();
+ return found!;
+}
+
+describe('the pager on a wizard page', () => {
+ it('names the page and moves either way when both are open', async () => {
+ const onBack = vi.fn();
+ const onNext = vi.fn();
+ const el = await render(
+ <StepPager pageName="Connect to a server" onBack={onBack} onNext={onNext} />
+ );
+
+ expect(el.textContent).toContain('Connect to a server');
+
+ await act(async () => arrow(el, 'Previous page').click());
+ await act(async () => arrow(el, 'Next page').click());
+
+ expect(onBack).toHaveBeenCalledOnce();
+ expect(onNext).toHaveBeenCalledOnce();
+ });
+
+ // Shown rather than hidden: the bar keeps the same shape from page to page,
+ // so the name does not move as the flow advances.
+ it('keeps an arrow with nowhere to go on screen and dead', async () => {
+ const el = await render(<StepPager pageName="Sign in" onBack={vi.fn()} onNext={null} />);
+
+ const next = arrow(el, 'Next page');
+ // However the button primitive spells it, it has to reach a screen reader
+ // as unavailable — the chevron itself says nothing about where it leads.
+ expect(next.matches(':disabled, [aria-disabled="true"], [data-disabled]')).toBe(true);
+ });
+
+ /**
+ * The same arrow, the same handler, closed and then open.
+ *
+ * `aria-disabled` leaves the button clickable — that is the price of keeping
+ * it in the tab order — so nothing but the missing handler stops it firing,
+ * and a page whose way on commits an install would be committed by a chevron
+ * labelled "next". Driving one button through both states is what makes this
+ * a test: asserting on a separate always-dead arrow would pass against an
+ * implementation that fires whatever it is given.
+ */
+ it('fires nothing while the way on is closed, and fires once when it opens', async () => {
+ const onNext = vi.fn();
+ const page = (open: boolean) => (
+ <StepPager pageName="Sign in" onBack={null} onNext={open ? onNext : null} />
+ );
+ const el = await render(page(false));
+
+ await act(async () => arrow(el, 'Next page').click());
+ expect(onNext).not.toHaveBeenCalled();
+
+ await act(async () => root!.render(page(true)));
+ await act(async () => arrow(el, 'Next page').click());
+
+ expect(onNext).toHaveBeenCalledOnce();
+ });
+
+ it('leaves the dead arrow reachable, with the reason in its label', async () => {
+ // `disabled` would take it out of the tab order, and the label is the only
+ // place the reason is written — so the people who cannot see the greyed-out
+ // chevron would be the ones who never hear why it leads nowhere.
+ const el = await render(<StepPager pageName="Sign in" onBack={null} onNext={null} />);
+
+ for (const label of ['Previous page', 'Next page']) {
+ const button = arrow(el, label);
+ expect(button.hasAttribute('disabled')).toBe(false);
+ expect(button.tabIndex).toBeGreaterThanOrEqual(0);
+ expect(button.getAttribute('aria-label')!.length).toBeGreaterThan(label.length);
+ }
+ });
+});