Lot en un seul commit: les deux features partagent les mêmes contrats (domain/settings.rs, DTO, commandes Tauri/HTTP, web-server) et les mêmes surfaces UI — la séparation par fichiers était impossible sans chirurgie de hunks risquant des états intermédiaires non compilables (convention lot des batches #310-#313 et #315). #325 — icône configurable par projet, watermark CLI custom: - domaine: ProjectIconSet (devicon, simple-icons, lucide, idea), ProjectIconRef validé (nom ASCII 1..=64, -_. internes), champ icon optionnel sur ProjectSettings; sérialisation camelCase et try_from strict - application: UpdateProjectSettings.execute accepte un patch theme_color OU icon (absent = inchangé, null = défaut produit), tests in-dependants avec store mémoire - backend/app-tauri/web-server: ProjectIconRefDto, UpdateProjectSettingsRequestDto avec icon optionnel (désérialisation additive), commandes update_project_settings alignées Tauri/HTTP, tests DTO et HTTP (défaut null, set, clear, nom invalide rejeté) - frontend: catalogue projectIcons (recherche EN), ProjectIconPicker en grille multi-lignes dans Paramètres projet, affichage de l'icône dans ProjectTabs et watermark grand format à faible opacité en fond de CLI custom; ports ProjectSettings.icon, Partial<ProjectSettings>, adapters tauri/mock/http et tests alignés #326 — localisation FR/EN et traduction des textes IdeA: - domaine: IdeaLanguage (fr | en), champ language optionnel sur IdeaUserSettings (absence = défaut produit, série additive validée) - backend/web-server: UserSettingsDto.language, update_user_settings accepte language, tests HTTP alignés; fixtures structured_launch_d3 mises à jour - frontend: i18n/ (catalogue FR/EN, I18nProvider, scan anti-régression des sources visibles), GeneralSettings avec sélecteur de langue dans les paramètres, setupI18n dans vitest; migration de l'ensemble des textes hardcodés vers le catalogue sur toutes les surfaces (agents, layout, projets, tickets, sprints, web, plugins, permissions, git, templates, skills, mémoire, model servers, embedder, first-run, devices, scheduled tasks, workstate, dialogs), FR conservé par défaut; recherche d'icônes #325 en anglais conformément au ticket QA verte sur feature/batch-325-326-project-icons-localisation. Aucun push.
97 lines
3.9 KiB
TypeScript
97 lines
3.9 KiB
TypeScript
/**
|
|
* #46 — the project tab bar's "+" add-project button. It must be present,
|
|
* enabled and visibly a button in EVERY state (notably with zero open projects,
|
|
* where it is the only way to add a project as a tab), and clicking it opens the
|
|
* Projects panel. The visibility regression it guards against: the button used
|
|
* to render with the `ghost` variant (no border/background, muted text) so it
|
|
* read as faint text rather than a control.
|
|
*/
|
|
import { describe, it, expect, vi } from "vitest";
|
|
import { render, screen, fireEvent, within } from "@testing-library/react";
|
|
|
|
import type { TabItem } from "@/shared";
|
|
import { ProjectTabs } from "./ProjectTabs";
|
|
|
|
const TABS: TabItem[] = [
|
|
{ id: "a", label: "alpha" },
|
|
{ id: "b", label: "beta" },
|
|
];
|
|
|
|
function renderTabs(props: Partial<React.ComponentProps<typeof ProjectTabs>> = {}) {
|
|
const onOpenProjectsPanel = vi.fn();
|
|
render(
|
|
<ProjectTabs
|
|
items={props.items ?? TABS}
|
|
activeTabId={props.activeTabId ?? "a"}
|
|
onSelect={props.onSelect ?? vi.fn()}
|
|
onClose={props.onClose ?? vi.fn()}
|
|
projectsPanelOpen={props.projectsPanelOpen ?? false}
|
|
onOpenProjectsPanel={onOpenProjectsPanel}
|
|
activityByProjectId={props.activityByProjectId}
|
|
/>,
|
|
);
|
|
return { onOpenProjectsPanel };
|
|
}
|
|
|
|
describe("ProjectTabs add-project button (#46)", () => {
|
|
it("renders the + button when projects are open", () => {
|
|
renderTabs({ items: TABS });
|
|
const btn = screen.getByRole("button", { name: "ouvrir le panneau des projets" });
|
|
expect(btn).toBeTruthy();
|
|
expect(btn.textContent).toContain("+");
|
|
expect((btn as HTMLButtonElement).disabled).toBe(false);
|
|
});
|
|
|
|
it("still renders the + button with ZERO open projects (only way to add one)", () => {
|
|
renderTabs({ items: [], activeTabId: null });
|
|
// The empty placeholder is shown…
|
|
expect(screen.getByText("Aucun onglet ouvert.")).toBeTruthy();
|
|
// …and the add-project button is still present and enabled.
|
|
const btn = screen.getByRole("button", { name: "ouvrir le panneau des projets" });
|
|
expect(btn).toBeTruthy();
|
|
expect((btn as HTMLButtonElement).disabled).toBe(false);
|
|
});
|
|
|
|
it("is a visible bordered control, not the near-invisible ghost glyph", () => {
|
|
// Regression guard for #46: the secondary variant carries a border; the old
|
|
// ghost variant did not. Asserting the border class keeps the button from
|
|
// silently reverting to the invisible style.
|
|
renderTabs({ items: [] });
|
|
const btn = screen.getByRole("button", { name: "ouvrir le panneau des projets" });
|
|
expect(btn.className).toContain("border");
|
|
expect(btn.className).not.toContain("text-muted");
|
|
});
|
|
|
|
it("reflects the panel-open state via aria-pressed", () => {
|
|
const { onOpenProjectsPanel } = renderTabs({ projectsPanelOpen: true });
|
|
const btn = screen.getByRole("button", { name: "ouvrir le panneau des projets" });
|
|
expect(btn.getAttribute("aria-pressed")).toBe("true");
|
|
expect(onOpenProjectsPanel).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("opens the Projects panel on click, independent of any active project", () => {
|
|
const { onOpenProjectsPanel } = renderTabs({ items: [], activeTabId: null });
|
|
fireEvent.click(screen.getByRole("button", { name: "ouvrir le panneau des projets" }));
|
|
expect(onOpenProjectsPanel).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|
|
|
|
describe("ProjectTabs project activity dots (#159)", () => {
|
|
it("renders the neutral activity dot to the left of a project name by default", () => {
|
|
renderTabs({ items: TABS });
|
|
|
|
const tab = screen.getByRole("tab", { name: /alpha/ });
|
|
expect(within(tab).getByTitle(/alpha.*prêt/i)).toBeTruthy();
|
|
});
|
|
|
|
it("renders idle and busy project activity states", () => {
|
|
renderTabs({
|
|
items: TABS,
|
|
activityByProjectId: { a: "idle", b: "busy" },
|
|
});
|
|
|
|
expect(screen.getByTitle(/alpha.*prêt/i)).toBeTruthy();
|
|
expect(screen.getByTitle(/beta.*échange en cours/i)).toBeTruthy();
|
|
});
|
|
});
|