mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-11-27 17:00:37 +00:00
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:
parent
dccb163836
commit
ee72fe281c
@ -731,6 +731,7 @@ export function SidecarPanel({ className }: { className?: string }) {
|
|||||||
/>
|
/>
|
||||||
<Tooltip content={t.sidecar.send}>
|
<Tooltip content={t.sidecar.send}>
|
||||||
<PromptInputSubmit
|
<PromptInputSubmit
|
||||||
|
aria-label={t.sidecar.send}
|
||||||
className="rounded-full"
|
className="rounded-full"
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
status={
|
status={
|
||||||
|
|||||||
@ -386,7 +386,7 @@ test("clearing the target quote cancels the pending rewrite", async ({
|
|||||||
panel.getByRole("button", { name: "Rewrite selection" }),
|
panel.getByRole("button", { name: "Rewrite selection" }),
|
||||||
).toBeHidden();
|
).toBeHidden();
|
||||||
await expect(
|
await expect(
|
||||||
panel.getByRole("button", { name: "Submit", exact: true }),
|
panel.getByRole("button", { name: "Send", exact: true }),
|
||||||
).toBeDisabled();
|
).toBeDisabled();
|
||||||
expect(submitted).toBeUndefined();
|
expect(submitted).toBeUndefined();
|
||||||
});
|
});
|
||||||
@ -407,7 +407,7 @@ for (const discard of ["close draft", "delete thread"] as const) {
|
|||||||
.getByRole("button", { name: "Rewrite selection" })
|
.getByRole("button", { name: "Rewrite selection" })
|
||||||
.click();
|
.click();
|
||||||
const composer = page.getByPlaceholder(/deeper follow-up/i);
|
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.fill(text);
|
||||||
await composer
|
await composer
|
||||||
.locator("xpath=ancestor::form")
|
.locator("xpath=ancestor::form")
|
||||||
|
|||||||
@ -162,7 +162,10 @@ async function expectComposerHeightsEqual(page: Page) {
|
|||||||
|
|
||||||
async function expectSidecarModelPinnedToSubmit(page: Page) {
|
async function expectSidecarModelPinnedToSubmit(page: Page) {
|
||||||
const metrics = await page.evaluate(() => {
|
const metrics = await page.evaluate(() => {
|
||||||
const getComposerMetrics = (placeholderPattern: RegExp) => {
|
const getComposerMetrics = (
|
||||||
|
placeholderPattern: RegExp,
|
||||||
|
submitLabel: string,
|
||||||
|
) => {
|
||||||
const textarea = Array.from(document.querySelectorAll("textarea")).find(
|
const textarea = Array.from(document.querySelectorAll("textarea")).find(
|
||||||
(element) =>
|
(element) =>
|
||||||
placeholderPattern.test(element.getAttribute("placeholder") ?? ""),
|
placeholderPattern.test(element.getAttribute("placeholder") ?? ""),
|
||||||
@ -186,7 +189,7 @@ async function expectSidecarModelPinnedToSubmit(page: Page) {
|
|||||||
const model = buttons.find(
|
const model = buttons.find(
|
||||||
(button) => button.label === "DeepSeek V4 Pro",
|
(button) => button.label === "DeepSeek V4 Pro",
|
||||||
);
|
);
|
||||||
const submit = buttons.find((button) => button.label === "Submit");
|
const submit = buttons.find((button) => button.label === submitLabel);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
formLeft: Math.round(formBox.left),
|
formLeft: Math.round(formBox.left),
|
||||||
@ -204,8 +207,8 @@ async function expectSidecarModelPinnedToSubmit(page: Page) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
main: getComposerMetrics(/how can i assist you/i),
|
main: getComposerMetrics(/how can i assist you/i, "Submit"),
|
||||||
sidecar: getComposerMetrics(/deeper follow-up/i),
|
sidecar: getComposerMetrics(/deeper follow-up/i, "Send"),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -281,7 +284,7 @@ async function expectSidecarModelHiddenWhenCompact(page: Page) {
|
|||||||
|
|
||||||
expect(metrics).not.toBeNull();
|
expect(metrics).not.toBeNull();
|
||||||
expect(metrics!.labels).toContain("Pro");
|
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!.labels).not.toContain("DeepSeek V4 Pro");
|
||||||
expect(metrics!.overflows).toBe(false);
|
expect(metrics!.overflows).toBe(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ import {
|
|||||||
import { SidecarPanel } from "@/components/workspace/sidecar/sidecar-panel";
|
import { SidecarPanel } from "@/components/workspace/sidecar/sidecar-panel";
|
||||||
import { AuthProvider } from "@/core/auth/AuthProvider";
|
import { AuthProvider } from "@/core/auth/AuthProvider";
|
||||||
import type { User } from "@/core/auth/types";
|
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";
|
import { I18nProvider } from "@/core/i18n/context";
|
||||||
|
|
||||||
// PromptInput clears the composer only when onSubmit resolves, so these tests
|
// PromptInput clears the composer only when onSubmit resolves, so these tests
|
||||||
@ -104,9 +104,12 @@ function Setup({ threadId }: { threadId: string | null }) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderPanel(threadId: string | null): ReactNode {
|
function renderPanel(
|
||||||
|
threadId: string | null,
|
||||||
|
locale: Locale = DEFAULT_LOCALE,
|
||||||
|
): ReactNode {
|
||||||
return (
|
return (
|
||||||
<I18nProvider initialLocale={DEFAULT_LOCALE}>
|
<I18nProvider initialLocale={locale}>
|
||||||
<QueryClientProvider
|
<QueryClientProvider
|
||||||
client={
|
client={
|
||||||
new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
||||||
@ -159,6 +162,17 @@ beforeEach(() => {
|
|||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
cleanup();
|
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", () => {
|
describe("SidecarPanel keeps the draft when a send fails", () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user