fix(webui): use file-type icons in file change activity

This commit is contained in:
chengyongru authored and chengyongru committed 2026-10-17 23:27:00 +08:00
1 parent d076e4ef13
commit 8de03ac0a2
8 files changed
+132 -68

No files matched your search

+33 -3
View File
@@ -1,10 +1,14 @@
import { cleanup, render, screen, within } from "@testing-library/react";
import { act, cleanup, fireEvent, render, screen, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { afterEach, expect, it } from "vitest";
import { FileCode2 } from "lucide-react";
import { afterEach, expect, it, vi } from "vitest";
import { ActivityStep } from "@/components/thread/activity/ActivityStep";
afterEach(cleanup);
afterEach(() => {
cleanup();
vi.useRealTimers();
});
it("animates a running label with details and keeps the completed activity readable", () => {
const { rerender } = render(<ActivityStep label="Running Blender" detail="--json project new" active />);
@@ -32,3 +36,29 @@ it("keeps truncated activity details available on keyboard focus", async () => {
const tooltip = await screen.findByRole("tooltip");
expect(within(tooltip).getByText(/Used Blender/)).toHaveTextContent("--json project new");
});
it("describes a named operation marker on keyboard focus before the file action", async () => {
render(<ActivityStep icon={FileCode2} markerLabel="Created" label={<button>src/app.tsx</button>} />);
await userEvent.tab();
const marker = screen.getByRole("img", { name: "Created" });
expect(marker).toHaveFocus();
expect(marker.closest('[aria-hidden="true"]')).toBeNull();
expect(screen.getByRole("tooltip")).toHaveTextContent("Created");
await userEvent.tab();
expect(screen.getByRole("button", { name: "src/app.tsx" })).toHaveFocus();
});
it("uses the shared hover delay for a named operation marker", () => {
vi.useFakeTimers();
render(<ActivityStep icon={FileCode2} markerLabel="Created" label={<span>src/app.tsx</span>} />);
const marker = screen.getByRole("img", { name: "Created" });
fireEvent.pointerMove(marker, { pointerType: "mouse" });
act(() => vi.advanceTimersByTime(499));
expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
act(() => vi.advanceTimersByTime(1));
expect(screen.getByRole("tooltip")).toHaveTextContent("Created");
});