Files
IdeA/frontend/src/features/projects/ProjectsView.docking.test.tsx
Blomios 1a1429f10e feat(domain,application,infrastructure,backend,web-server,app-tauri,frontend): lot utilisateur #325 #326 — icônes projet avec watermark CLI custom et localisation FR/EN (QA verte)
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.
2026-09-11 21:53:56 +02:00

130 lines
4.9 KiB
TypeScript

/**
* #22 — view anchoring/docking in `ProjectsView`. A view opened from the menu
* starts floating (modal window); its header controls move it into the in-flow
* left/right {@link DockRegion} and back, and the one-slot-per-view invariant
* holds (docking a floating view removes the modal window).
*/
import { describe, it, expect } from "vitest";
import { render, screen, within, waitFor, fireEvent } from "@testing-library/react";
import {
MockAgentGateway,
MockGitGateway,
MockProfileGateway,
MockProjectGateway,
MockSystemGateway,
MockTemplateGateway,
MockWindowGateway,
MockWorkStateGateway,
} from "@/adapters/mock";
import type { Gateways } from "@/ports";
import { DIProvider } from "@/app/di";
import { ProjectsView } from "./ProjectsView";
async function renderWithProject() {
const project = new MockProjectGateway();
await project.createProject("alpha", "/p/a");
const agentGateway = new MockAgentGateway();
const gateways = {
system: new MockSystemGateway(),
project,
agent: agentGateway,
profile: new MockProfileGateway(),
template: new MockTemplateGateway(agentGateway),
git: new MockGitGateway(),
workState: new MockWorkStateGateway(),
window: new MockWindowGateway(),
} as unknown as Gateways;
render(
<DIProvider gateways={gateways}>
<ProjectsView />
</DIProvider>,
);
// Open the seeded project so panels have an active project to render for.
fireEvent.click(await screen.findByRole("button", { name: "Ouvrir" }));
await waitFor(() =>
expect(within(screen.getByRole("tablist")).getAllByRole("tab")).toHaveLength(1),
);
}
/**
* Opens a panel floating via the single « Panneaux » menu (#26): menu → panel
* entry (opens its placement submenu) → « Flottant ». `panelTitle` is the
* panel's human title ("Git", "Agents", …).
*/
function openPanelFloating(panelTitle: string) {
fireEvent.click(screen.getByRole("button", { name: "Panneaux" }));
fireEvent.click(screen.getByRole("button", { name: panelTitle }));
fireEvent.click(screen.getByRole("button", { name: "Flottant" }));
}
describe("ProjectsView view docking (#22)", () => {
it("opens a view floating, then docks it left as an in-flow column", async () => {
await renderWithProject();
// View → Git opens a modal floating window (historical behaviour).
openPanelFloating("Git");
const dialog = await screen.findByRole("dialog", { name: "Git" });
expect(dialog).toBeTruthy();
// Dock it to the left via the header control.
fireEvent.click(within(dialog).getByRole("button", { name: "Ancré à gauche — Git" }));
// The modal window is gone; the Git view now lives in the left dock column.
await waitFor(() =>
expect(screen.queryByRole("dialog", { name: "Git" })).toBeNull(),
);
const leftDock = screen.getByRole("complementary", { name: "Zone ancrée à gauche" });
expect(within(leftDock).getByLabelText("Git — panneau")).toBeTruthy();
// The main surface is still present beside the dock (in-flow, not overlay).
expect(screen.getByRole("main")).toBeTruthy();
});
it("keeps one slot per view: docking right moves it off the left dock", async () => {
await renderWithProject();
openPanelFloating("Git");
const dialog = await screen.findByRole("dialog", { name: "Git" });
fireEvent.click(within(dialog).getByRole("button", { name: "Ancré à gauche — Git" }));
const leftDock = await screen.findByRole("complementary", { name: "Zone ancrée à gauche" });
const leftHeader = within(leftDock).getByLabelText("Git — panneau");
// Move it to the Zone ancrée à droite from the docked header control.
fireEvent.click(
within(leftHeader).getByRole("button", { name: "Ancré à droite — Git" }),
);
await waitFor(() =>
expect(screen.queryByRole("complementary", { name: "Zone ancrée à gauche" })).toBeNull(),
);
const rightDock = screen.getByRole("complementary", { name: "Zone ancrée à droite" });
expect(within(rightDock).getByLabelText("Git — panneau")).toBeTruthy();
});
it("docks two different views side by side (left + right)", async () => {
await renderWithProject();
// Dock Git left.
openPanelFloating("Git");
fireEvent.click(
within(await screen.findByRole("dialog", { name: "Git" })).getByRole(
"button",
{ name: "Ancré à gauche — Git" },
),
);
// Dock Agents right.
openPanelFloating("Agents");
fireEvent.click(
within(await screen.findByRole("dialog", { name: "Agents" })).getByRole(
"button",
{ name: "Ancré à droite — Agents" },
),
);
const leftDock = await screen.findByRole("complementary", { name: "Zone ancrée à gauche" });
const rightDock = await screen.findByRole("complementary", { name: "Zone ancrée à droite" });
expect(within(leftDock).getByLabelText("Git — panneau")).toBeTruthy();
expect(within(rightDock).getByLabelText("Agents — panneau")).toBeTruthy();
});
});