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.
101 lines
3.7 KiB
TypeScript
101 lines
3.7 KiB
TypeScript
/**
|
|
* F35.1 — presentational tests for {@link ModelServerLaunchBadge}. Pure render
|
|
* of the folded launch state: lifecycle labels, the reused/fresh distinction,
|
|
* the actionable failure (with a details toggle that hides the code by default),
|
|
* and the "render nothing" cases for unmanaged rows.
|
|
*/
|
|
|
|
import { describe, it, expect } from "vitest";
|
|
import { render, screen, fireEvent } from "@testing-library/react";
|
|
|
|
import { ModelServerLaunchBadge } from "./ModelServerLaunchBadge";
|
|
|
|
describe("ModelServerLaunchBadge (F35.1)", () => {
|
|
it("renders nothing without a status or a failure", () => {
|
|
const { container } = render(<ModelServerLaunchBadge />);
|
|
expect(container.firstChild).toBeNull();
|
|
});
|
|
|
|
it("renders nothing for a notConfigured status (unmanaged endpoint)", () => {
|
|
const { container } = render(
|
|
<ModelServerLaunchBadge status={{ state: "notConfigured" }} />,
|
|
);
|
|
expect(container.firstChild).toBeNull();
|
|
});
|
|
|
|
it("shows the probing and starting lifecycle labels", () => {
|
|
const { rerender } = render(
|
|
<ModelServerLaunchBadge status={{ state: "probing" }} />,
|
|
);
|
|
expect(screen.getByLabelText("état du serveur de modèle").textContent).toMatch(
|
|
/vérification/i,
|
|
);
|
|
rerender(<ModelServerLaunchBadge status={{ state: "starting" }} />);
|
|
expect(screen.getByLabelText("état du serveur de modèle").textContent).toMatch(
|
|
/démarrage/i,
|
|
);
|
|
});
|
|
|
|
it("distinguishes a reused server from a freshly started one", () => {
|
|
const { rerender } = render(
|
|
<ModelServerLaunchBadge status={{ state: "ready", reused: true }} />,
|
|
);
|
|
expect(screen.getByLabelText("état du serveur de modèle").textContent).toMatch(
|
|
/réutilisé/i,
|
|
);
|
|
rerender(
|
|
<ModelServerLaunchBadge status={{ state: "ready", reused: false }} />,
|
|
);
|
|
const label = screen.getByLabelText("état du serveur de modèle").textContent ?? "";
|
|
expect(label).toMatch(/prêt/i);
|
|
expect(label).not.toMatch(/réutilisé/i);
|
|
});
|
|
|
|
it("shows an actionable failure message, not a bare 'agent failed'", () => {
|
|
render(
|
|
<ModelServerLaunchBadge
|
|
failure={{
|
|
cause: "model_server",
|
|
code: "SERVER_UNREACHABLE",
|
|
message: "llama-server did not become ready on :8080",
|
|
}}
|
|
/>,
|
|
);
|
|
const alert = screen.getByRole("alert");
|
|
expect(alert.textContent).toMatch(/did not become ready on :8080/);
|
|
// The code is not exposed by default (logs/detail stay hidden).
|
|
expect(screen.queryByLabelText("détail de l'échec du lancement")).toBeNull();
|
|
});
|
|
|
|
it("reveals the stable code/cause only when Détails is toggled", () => {
|
|
render(
|
|
<ModelServerLaunchBadge
|
|
failure={{ cause: "model_server", code: "SPAWN", message: "boom" }}
|
|
/>,
|
|
);
|
|
fireEvent.click(screen.getByLabelText("afficher ou masquer le détail de l'échec"));
|
|
const detail = screen.getByLabelText("détail de l'échec du lancement");
|
|
expect(detail.textContent).toMatch(/SPAWN/);
|
|
expect(detail.textContent).toMatch(/model_server/);
|
|
});
|
|
|
|
it("prefers the agent-scoped failure over a failed status", () => {
|
|
render(
|
|
<ModelServerLaunchBadge
|
|
status={{ state: "failed", code: "S1", message: "status-level" }}
|
|
failure={{ cause: "model_server", code: "A1", message: "agent-level" }}
|
|
/>,
|
|
);
|
|
expect(screen.getByRole("alert").textContent).toMatch(/agent-level/);
|
|
});
|
|
|
|
it("falls back to a failed status when there is no agent failure", () => {
|
|
render(
|
|
<ModelServerLaunchBadge
|
|
status={{ state: "failed", code: "S1", message: "status-level boom" }}
|
|
/>,
|
|
);
|
|
expect(screen.getByRole("alert").textContent).toMatch(/status-level boom/);
|
|
});
|
|
});
|