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.
140 lines
4.5 KiB
Rust
140 lines
4.5 KiB
Rust
use std::path::PathBuf;
|
|
use std::sync::Arc;
|
|
|
|
use domain::{
|
|
DefaultAgentTerminalInterface, FileSystem, IdeaLanguage, IdeaUserSettings, ProjectIconRef,
|
|
ProjectIconSet, ProjectPath, ProjectSettings, ProjectSettingsStore, ThemeColor,
|
|
UserSettingsStore,
|
|
};
|
|
use infrastructure::{FsProjectSettingsStore, FsUserSettingsStore, LocalFileSystem};
|
|
use uuid::Uuid;
|
|
|
|
struct TempDir(PathBuf);
|
|
impl TempDir {
|
|
fn new() -> Self {
|
|
let path = std::env::temp_dir().join(format!("idea-settings-{}", Uuid::new_v4()));
|
|
std::fs::create_dir_all(&path).unwrap();
|
|
Self(path)
|
|
}
|
|
fn root(&self) -> ProjectPath {
|
|
ProjectPath::new(self.0.to_string_lossy().into_owned()).unwrap()
|
|
}
|
|
}
|
|
impl Drop for TempDir {
|
|
fn drop(&mut self) {
|
|
let _ = std::fs::remove_dir_all(&self.0);
|
|
}
|
|
}
|
|
fn fs() -> Arc<dyn FileSystem> {
|
|
Arc::new(LocalFileSystem::new())
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn global_user_preference_persists_outside_project() {
|
|
let tmp = TempDir::new();
|
|
let store = FsUserSettingsStore::new(fs(), tmp.0.to_string_lossy());
|
|
assert_eq!(store.load().await.unwrap(), IdeaUserSettings::default());
|
|
let settings = IdeaUserSettings {
|
|
default_agent_terminal_interface: Some(DefaultAgentTerminalInterface::IdeaCli),
|
|
language: Some(IdeaLanguage::En),
|
|
};
|
|
store.save(&settings).await.unwrap();
|
|
assert_eq!(
|
|
FsUserSettingsStore::new(fs(), tmp.0.to_string_lossy())
|
|
.load()
|
|
.await
|
|
.unwrap(),
|
|
settings
|
|
);
|
|
assert!(tmp.0.join("settings.json").is_file());
|
|
assert!(!tmp.0.join(".ideai").exists());
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn project_settings_missing_then_valid_round_trip() {
|
|
let tmp = TempDir::new();
|
|
let store = FsProjectSettingsStore::new(fs());
|
|
assert_eq!(
|
|
store.load(&tmp.root()).await.unwrap(),
|
|
ProjectSettings::default()
|
|
);
|
|
assert!(!tmp.0.join(".ideai/project-settings.json").exists());
|
|
let settings = ProjectSettings {
|
|
theme_color: Some(ThemeColor::new("#12AbEF").unwrap()),
|
|
icon: Some(ProjectIconRef::new(ProjectIconSet::Devicon, "cplusplus").unwrap()),
|
|
};
|
|
store.save(&tmp.root(), &settings).await.unwrap();
|
|
assert_eq!(store.load(&tmp.root()).await.unwrap(), settings);
|
|
assert_eq!(
|
|
std::fs::read_to_string(tmp.0.join(".ideai/project-settings.json")).unwrap(),
|
|
"{\n \"themeColor\": \"#12AbEF\",\n \"icon\": {\n \"set\": \"devicon\",\n \"name\": \"cplusplus\"\n }\n}\n"
|
|
);
|
|
assert!(!tmp.0.join(".ideai/CONTEXT.md").exists());
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn project_settings_are_isolated_and_missing_defaults_are_not_persisted() {
|
|
let first = TempDir::new();
|
|
let second = TempDir::new();
|
|
let third = TempDir::new();
|
|
let store = FsProjectSettingsStore::new(fs());
|
|
|
|
store
|
|
.save(
|
|
&first.root(),
|
|
&ProjectSettings {
|
|
theme_color: Some(ThemeColor::new("#AA3366").unwrap()),
|
|
icon: Some(ProjectIconRef::new(ProjectIconSet::Devicon, "rust").unwrap()),
|
|
},
|
|
)
|
|
.await
|
|
.unwrap();
|
|
store
|
|
.save(
|
|
&second.root(),
|
|
&ProjectSettings {
|
|
theme_color: None,
|
|
icon: Some(ProjectIconRef::new(ProjectIconSet::SimpleIcons, "docker").unwrap()),
|
|
},
|
|
)
|
|
.await
|
|
.unwrap();
|
|
|
|
let second_settings = store.load(&second.root()).await.unwrap();
|
|
assert_eq!(second_settings.theme_color, None);
|
|
assert_eq!(
|
|
second_settings.icon.as_ref().map(ProjectIconRef::set),
|
|
Some(ProjectIconSet::SimpleIcons)
|
|
);
|
|
assert_eq!(
|
|
second_settings.icon.as_ref().map(ProjectIconRef::name),
|
|
Some("docker")
|
|
);
|
|
assert_eq!(
|
|
store
|
|
.load(&first.root())
|
|
.await
|
|
.unwrap()
|
|
.theme_color
|
|
.as_ref()
|
|
.map(ThemeColor::as_str),
|
|
Some("#AA3366")
|
|
);
|
|
let first_icon = store.load(&first.root()).await.unwrap().icon.unwrap();
|
|
assert_eq!(first_icon.set(), ProjectIconSet::Devicon);
|
|
assert_eq!(first_icon.name(), "rust");
|
|
assert_eq!(
|
|
store.load(&third.root()).await.unwrap(),
|
|
ProjectSettings::default()
|
|
);
|
|
assert!(!third.0.join(".ideai/project-settings.json").exists());
|
|
}
|
|
|
|
#[test]
|
|
fn theme_color_validation_is_strict() {
|
|
assert!(ThemeColor::new("#112233").is_ok());
|
|
for invalid in ["112233", "#123", "#GG0000", "#11223344", "# 12233"] {
|
|
assert!(ThemeColor::new(invalid).is_err(), "accepted {invalid}");
|
|
}
|
|
}
|