fix(frontend): localize the sidecar send button's accessible name (#8418)

* fix(frontend): localize the sidecar send button's accessible name

* test(frontend): align sidecar E2E with localized send name
This commit is contained in:
Hu Hongwei 2026-11-21 20:42:18 +08:00 committed by GitHub
parent dccb163836
commit ee72fe281c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 28 additions and 10 deletions

View File

@ -731,6 +731,7 @@ export function SidecarPanel({ className }: { className?: string }) {
/>
<Tooltip content={t.sidecar.send}>
<PromptInputSubmit
aria-label={t.sidecar.send}
className="rounded-full"
disabled={disabled}
status={

View File

@ -386,7 +386,7 @@ test("clearing the target quote cancels the pending rewrite", async ({
panel.getByRole("button", { name: "Rewrite selection" }),
).toBeHidden();
await expect(
panel.getByRole("button", { name: "Submit", exact: true }),
panel.getByRole("button", { name: "Send", exact: true }),
).toBeDisabled();
expect(submitted).toBeUndefined();
});
@ -407,7 +407,7 @@ for (const discard of ["close draft", "delete thread"] as const) {
.getByRole("button", { name: "Rewrite selection" })
.click();
const composer = page.getByPlaceholder(/deeper follow-up/i);
const submit = async (text: string, button = "Submit") => {
const submit = async (text: string, button = "Send") => {
await composer.fill(text);
await composer
.locator("xpath=ancestor::form")

View File

@ -162,7 +162,10 @@ async function expectComposerHeightsEqual(page: Page) {
async function expectSidecarModelPinnedToSubmit(page: Page) {
const metrics = await page.evaluate(() => {
const getComposerMetrics = (placeholderPattern: RegExp) => {
const getComposerMetrics = (
placeholderPattern: RegExp,
submitLabel: string,
) => {
const textarea = Array.from(document.querySelectorAll("textarea")).find(
(element) =>
placeholderPattern.test(element.getAttribute("placeholder") ?? ""),
@ -186,7 +189,7 @@ async function expectSidecarModelPinnedToSubmit(page: Page) {
const model = buttons.find(
(button) => button.label === "DeepSeek V4 Pro",
);
const submit = buttons.find((button) => button.label === "Submit");
const submit = buttons.find((button) => button.label === submitLabel);
return {
formLeft: Math.round(formBox.left),
@ -204,8 +207,8 @@ async function expectSidecarModelPinnedToSubmit(page: Page) {
};
return {
main: getComposerMetrics(/how can i assist you/i),
sidecar: getComposerMetrics(/deeper follow-up/i),
main: getComposerMetrics(/how can i assist you/i, "Submit"),
sidecar: getComposerMetrics(/deeper follow-up/i, "Send"),
};
});
@ -281,7 +284,7 @@ async function expectSidecarModelHiddenWhenCompact(page: Page) {
expect(metrics).not.toBeNull();
expect(metrics!.labels).toContain("Pro");
expect(metrics!.labels).toContain("Submit");
expect(metrics!.labels).toContain("Send");
expect(metrics!.labels).not.toContain("DeepSeek V4 Pro");
expect(metrics!.overflows).toBe(false);
}

View File

@ -18,7 +18,7 @@ import {
import { SidecarPanel } from "@/components/workspace/sidecar/sidecar-panel";
import { AuthProvider } from "@/core/auth/AuthProvider";
import type { User } from "@/core/auth/types";
import { DEFAULT_LOCALE } from "@/core/i18n";
import { DEFAULT_LOCALE, type Locale } from "@/core/i18n";
import { I18nProvider } from "@/core/i18n/context";
// PromptInput clears the composer only when onSubmit resolves, so these tests
@ -104,9 +104,12 @@ function Setup({ threadId }: { threadId: string | null }) {
return null;
}
function renderPanel(threadId: string | null): ReactNode {
function renderPanel(
threadId: string | null,
locale: Locale = DEFAULT_LOCALE,
): ReactNode {
return (
<I18nProvider initialLocale={DEFAULT_LOCALE}>
<I18nProvider initialLocale={locale}>
<QueryClientProvider
client={
new QueryClient({ defaultOptions: { queries: { retry: false } } })
@ -159,6 +162,17 @@ beforeEach(() => {
afterEach(() => {
cleanup();
document.cookie = "locale=; max-age=0; path=/";
});
it("gives the sidecar send button its Chinese accessible name", async () => {
document.cookie = "locale=zh-CN; path=/";
render(renderPanel("sidecar-1", "zh-CN"));
const button = await screen.findByRole<HTMLButtonElement>("button", {
name: "发送",
});
expect(button.type).toBe("submit");
});
describe("SidecarPanel keeps the draft when a send fails", () => {