fa156d6a59
Chat UI: - Each Claude/Codex session keeps its own chat/terminal view; Settings only sets how new sessions open. - Composer + menu: upload, project files and folders (#54, also dragged from the Files/Changes tree), context files, recent uploads, skills, plugins. - Activity side panel (progress, outputs, files read, uploads, memory, skills, connectors) with a file preview; edited-file counts per turn. - Permission-mode chip (Shift+Tab steps, read back from the pane: server/lib/pane-mode.js, GET|POST /api/run/:id/permission-mode). - Stop (Esc) while the main agent works; the status is checked per agent (with session_id /api/agents ignores its status filter) and re-read every 5 s while Stop shows. - Dropped images shown in the conversation (GET /api/run/drop/:name, the requester's own drop dir), full-size viewer. - A plain-text paste over 5,000 characters is attached as pasted-text.txt, so no prompt reaches tmux/argv limits (#68). Changes panel: every /api/lanes/:id/git* route takes ?source=<lane_sources id> (sourceFolder; ENOSOURCE otherwise) and a folder picker switches the whole panel to a workspace's extra folder (#70). Server mode S3 (one Linux user per account) — experimental, verified with fake sudo plus a P6 managed-settings spike on a test account: - member tmux listing runs in the background (cached, 15 s => unknown); - transcript snapshot copy is async, chunked, temp file + rename; - Express Layer patch only on Express 4; - tmux capturePane/sendKey go to the member's own server. Docs: the multi-user design moved in as docs/plans/server-mode/README.md (the AgentHub-Server repo is gone); S3-PLAN P6 result; LANES/API/openapi.
106 lines
4.5 KiB
TypeScript
106 lines
4.5 KiB
TypeScript
/**
|
|
* @file AppearanceSettings.test.tsx
|
|
* @description Tests for the Settings → Appearance section: the language switch, the terminal font picker, and the mode switch and the per-mode theme cards writing through useTheme to `<html>`.
|
|
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
|
*/
|
|
|
|
import { describe, it, expect, beforeEach, vi } from "vitest";
|
|
import { act, render, screen, within } from "@testing-library/react";
|
|
import userEvent from "@testing-library/user-event";
|
|
import i18n from "../../../i18n";
|
|
import { AppearanceSettings } from "../AppearanceSettings";
|
|
|
|
vi.mock("../PetSettings", () => ({ PetSettings: () => <div data-testid="pet-settings" /> }));
|
|
|
|
const root = document.documentElement;
|
|
|
|
describe("AppearanceSettings", () => {
|
|
beforeEach(() => {
|
|
localStorage.clear();
|
|
root.classList.remove("dark");
|
|
root.removeAttribute("data-theme");
|
|
root.removeAttribute("data-mode");
|
|
});
|
|
|
|
it("switches the interface language and holds the pet block", async () => {
|
|
const user = userEvent.setup();
|
|
render(<AppearanceSettings />);
|
|
expect(screen.getByTestId("pet-settings").closest("section")).toHaveAttribute("id", "pet");
|
|
const group = screen.getByRole("radiogroup", { name: "Interface language" });
|
|
expect(within(group).getByRole("radio", { name: "English" })).toHaveAttribute(
|
|
"aria-checked",
|
|
"true"
|
|
);
|
|
await user.click(within(group).getByRole("radio", { name: "Tiếng Việt" }));
|
|
expect(i18n.language).toBe("vi");
|
|
await act(async () => {
|
|
await i18n.changeLanguage("en");
|
|
});
|
|
});
|
|
|
|
it("renders every theme of both modes, defaults selected", () => {
|
|
render(<AppearanceSettings />);
|
|
const pressed = screen
|
|
.getAllByRole("button", { pressed: true })
|
|
.map((b) => b.getAttribute("aria-label") ?? b.textContent);
|
|
expect(pressed).toHaveLength(2); // both Default cards
|
|
expect(screen.getByRole("radio", { name: /Dark/ })).toHaveAttribute("aria-checked", "true");
|
|
for (const name of [
|
|
"Darcula",
|
|
"Apple Dark",
|
|
"Orca Dark",
|
|
"Apple Light",
|
|
"Canvas",
|
|
"Orca Light",
|
|
]) {
|
|
expect(screen.getByText(name)).toBeInTheDocument();
|
|
}
|
|
});
|
|
|
|
it("picking a dark theme applies it at once; a light pick waits for light mode", async () => {
|
|
const user = userEvent.setup();
|
|
render(<AppearanceSettings />);
|
|
await user.click(screen.getByRole("button", { name: /Darcula/ }));
|
|
expect(root.dataset.theme).toBe("darcula");
|
|
await user.click(screen.getByRole("button", { name: /Canvas/ }));
|
|
expect(root.dataset.theme).toBe("darcula");
|
|
await user.click(screen.getByRole("radio", { name: /^Light$/ }));
|
|
expect(root.classList.contains("dark")).toBe(false);
|
|
expect(root.dataset.theme).toBe("canvas");
|
|
expect(screen.getByRole("button", { name: /Canvas/ })).toHaveAttribute("aria-pressed", "true");
|
|
});
|
|
|
|
it("the System mode is checked after choosing it", async () => {
|
|
const user = userEvent.setup();
|
|
render(<AppearanceSettings />);
|
|
await user.click(screen.getByRole("radio", { name: "System" }));
|
|
expect(screen.getByRole("radio", { name: "System" })).toHaveAttribute("aria-checked", "true");
|
|
expect(localStorage.getItem("theme")).toBe("system");
|
|
});
|
|
|
|
it("each swatch scopes its own mode and theme", () => {
|
|
const { container } = render(<AppearanceSettings />);
|
|
expect(container.querySelector('.dark[data-theme="darcula"]')).not.toBeNull();
|
|
expect(container.querySelector('[data-mode="light"][data-theme="canvas"]')).not.toBeNull();
|
|
expect(container.querySelector('[data-mode="light"]:not([data-theme])')).not.toBeNull();
|
|
});
|
|
|
|
it("picks the terminal font, JetBrains Mono by default, and warns on System", async () => {
|
|
const user = userEvent.setup();
|
|
render(<AppearanceSettings />);
|
|
const trigger = screen.getByRole("button", { name: /Terminal font/ });
|
|
expect(trigger).toHaveTextContent("JetBrains Mono");
|
|
const pick = async (name: string) => {
|
|
await user.click(screen.getByRole("button", { name: /Terminal font/ }));
|
|
await user.click(screen.getByRole("option", { name }));
|
|
};
|
|
await pick("Maple Mono (rounded)");
|
|
expect(localStorage.getItem("agenthub.terminal.font")).toBe("maple");
|
|
expect(screen.getByTestId("terminal-font-preview").style.fontFamily).toContain("Maple Mono");
|
|
expect(screen.queryByText(/may lack some Vietnamese letters/)).toBeNull();
|
|
await pick("System font");
|
|
expect(localStorage.getItem("agenthub.terminal.font")).toBe("system");
|
|
expect(screen.getByText(/may lack some Vietnamese letters/)).toBeInTheDocument();
|
|
});
|
|
});
|