Skip to content

Commit 9bb7a3c

Browse files
steipetePeter Steinberger
andauthored
fix(ui): label Gateway connection settings for accessibility (#118000)
Co-authored-by: Peter Steinberger <[email protected]>
1 parent c9dc5fb commit 9bb7a3c

4 files changed

Lines changed: 85 additions & 1 deletion

File tree

‎ui/src/components/settings-ui.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ export function renderSettingsEmpty(message: unknown): TemplateResult {
337337
/** Secret text input with an inset reveal toggle — one field, no trailing
338338
* button, so secret rows line up with plain input rows in the same group. */
339339
export function renderSettingsSecretInput(props: {
340+
ariaLabel: string;
340341
value: string;
341342
placeholder?: string;
342343
visible: boolean;
@@ -351,6 +352,7 @@ export function renderSettingsSecretInput(props: {
351352
<input
352353
class="settings-input"
353354
type=${props.visible ? "text" : "password"}
355+
aria-label=${props.ariaLabel}
354356
autocomplete="off"
355357
spellcheck="false"
356358
.value=${props.value}

‎ui/src/e2e/sidebar-settings.e2e.test.ts‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,47 @@ import {
1111
const suite = createSidebarCustomizationSuite("Control UI sidebar settings mocked Gateway E2E");
1212

1313
suite.define(() => {
14+
it("keeps Gateway access fields editable by their visible labels", async () => {
15+
const context = await suite.newBrowserContext({
16+
locale: "en-US",
17+
serviceWorkers: "block",
18+
viewport: { height: 900, width: 1440 },
19+
});
20+
const page = await context.newPage();
21+
await installMockGateway(page);
22+
23+
try {
24+
await page.goto(`${suite.server.baseUrl}settings/connection`);
25+
26+
const gatewayUrl = page.getByLabel("WebSocket URL", { exact: true });
27+
const gatewayToken = page.getByLabel("Gateway Token", { exact: true });
28+
const password = page.getByLabel("Password (not stored)", { exact: true });
29+
const sessionKey = page.getByLabel("Default Session Key", { exact: true });
30+
31+
for (const input of [gatewayUrl, gatewayToken, password, sessionKey]) {
32+
await input.waitFor({ state: "visible" });
33+
expect(await input.isEditable()).toBe(true);
34+
}
35+
36+
await gatewayUrl.fill("ws://gateway.example.test:18789");
37+
await gatewayToken.fill("browser-proof-token");
38+
await password.fill("browser-proof-password");
39+
await sessionKey.fill("browser-proof-session");
40+
41+
expect(await gatewayUrl.inputValue()).toBe("ws://gateway.example.test:18789");
42+
expect(await gatewayToken.inputValue()).toBe("browser-proof-token");
43+
expect(await password.inputValue()).toBe("browser-proof-password");
44+
expect(await sessionKey.inputValue()).toBe("browser-proof-session");
45+
46+
await page.getByRole("button", { name: "Toggle password visibility", exact: true }).click();
47+
expect(await password.getAttribute("type")).toBe("text");
48+
expect(await password.inputValue()).toBe("browser-proof-password");
49+
expect(await password.isEditable()).toBe(true);
50+
} finally {
51+
await suite.closeBrowserContext(context);
52+
}
53+
});
54+
1455
it.each([
1556
{ mode: "standalone", webChrome: false },
1657
{ mode: "native web chrome", webChrome: true },

‎ui/src/pages/connection/view.render.test.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,42 @@ describe("connection view rendering", () => {
7676
expect(container.textContent).not.toContain("Last error");
7777
});
7878

79+
it("keeps every gateway access input labeled when credentials are revealed", () => {
80+
const container = document.createElement("div");
81+
const props = createConnectionProps({ password: "password" });
82+
const labels = [
83+
"WebSocket URL",
84+
"Gateway Token",
85+
"Password (not stored)",
86+
"Default Session Key",
87+
];
88+
const inputLabels = () =>
89+
Array.from(container.querySelectorAll<HTMLInputElement>(".settings-group input")).map(
90+
(input) => input.getAttribute("aria-label"),
91+
);
92+
93+
render(renderConnection(props), container);
94+
expect(inputLabels()).toEqual(labels);
95+
expect(
96+
container.querySelector<HTMLInputElement>('input[aria-label="Gateway Token"]')?.type,
97+
).toBe("password");
98+
expect(
99+
container.querySelector<HTMLInputElement>('input[aria-label="Password (not stored)"]')?.type,
100+
).toBe("password");
101+
102+
render(
103+
renderConnection({ ...props, showGatewayToken: true, showGatewayPassword: true }),
104+
container,
105+
);
106+
expect(inputLabels()).toEqual(labels);
107+
expect(
108+
container.querySelector<HTMLInputElement>('input[aria-label="Gateway Token"]')?.type,
109+
).toBe("text");
110+
expect(
111+
container.querySelector<HTMLInputElement>('input[aria-label="Password (not stored)"]')?.type,
112+
).toBe("text");
113+
});
114+
79115
it("hides token and password fields for trusted-proxy auth", async () => {
80116
const container = document.createElement("div");
81117
const hello = {

‎ui/src/pages/connection/view.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ function renderSecretRow(params: {
4747
onToggle: () => void;
4848
}) {
4949
const { label, ...secret } = params;
50-
return renderSettingsRow({ title: label, control: renderSettingsSecretInput(secret) });
50+
return renderSettingsRow({
51+
title: label,
52+
control: renderSettingsSecretInput({ ...secret, ariaLabel: label }),
53+
});
5154
}
5255

5356
export function renderConnection(props: ConnectionProps) {
@@ -68,6 +71,7 @@ export function renderConnection(props: ConnectionProps) {
6871
control: html`
6972
<input
7073
class="settings-input"
74+
aria-label=${t("connection.access.wsUrl")}
7175
.value=${props.settings.gatewayUrl}
7276
@input=${(e: Event) => {
7377
const settings = props.settings;
@@ -112,6 +116,7 @@ export function renderConnection(props: ConnectionProps) {
112116
control: html`
113117
<input
114118
class="settings-input"
119+
aria-label=${t("connection.access.sessionKey")}
115120
.value=${props.settings.sessionKey}
116121
@input=${(e: Event) => props.onSessionKeyChange((e.target as HTMLInputElement).value)}
117122
/>

0 commit comments

Comments
 (0)