Étend le port/usecases window et layout.customPluginLayout pour ouvrir et piloter des fenêtres OS hébergeant un layout plugin, en réutilisant contributes.layouts plutôt qu'un système de fenêtres parallèle. Câble la commande Tauri et l'état app-tauri correspondants. Cargo test -p domain --test window : 5/5 Cargo test -p application --test window_usecases : 7/7 Cargo test -p infrastructure --test window_state_store : 1/1 Cargo test -p app-tauri view_window_tests : 8/8 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
62 lines
1.7 KiB
Rust
62 lines
1.7 KiB
Rust
//! Integration tests for [`FsWindowStateStore`] against a real temp directory.
|
|
|
|
use std::path::PathBuf;
|
|
use std::sync::Arc;
|
|
|
|
use domain::layout::{PersistedWindowKind, PersistedWindowState, WindowStateSnapshot};
|
|
use domain::ports::{FileSystem, WindowStateStore};
|
|
use infrastructure::{FsWindowStateStore, LocalFileSystem};
|
|
use uuid::Uuid;
|
|
|
|
struct TempDir(PathBuf);
|
|
|
|
impl TempDir {
|
|
fn new() -> Self {
|
|
let path = std::env::temp_dir().join(format!("idea-window-store-{}", Uuid::new_v4()));
|
|
std::fs::create_dir_all(&path).unwrap();
|
|
Self(path)
|
|
}
|
|
|
|
fn app_data_dir(&self) -> String {
|
|
self.0.to_string_lossy().into_owned()
|
|
}
|
|
}
|
|
|
|
impl Drop for TempDir {
|
|
fn drop(&mut self) {
|
|
let _ = std::fs::remove_dir_all(&self.0);
|
|
}
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn window_state_save_then_load_roundtrips() {
|
|
let tmp = TempDir::new();
|
|
let fs: Arc<dyn FileSystem> = Arc::new(LocalFileSystem::new());
|
|
let store = FsWindowStateStore::new(fs, tmp.app_data_dir());
|
|
|
|
assert_eq!(
|
|
store.load_window_state().await.unwrap(),
|
|
WindowStateSnapshot::default()
|
|
);
|
|
|
|
let snapshot = WindowStateSnapshot::new(vec![PersistedWindowState {
|
|
label: "main".to_owned(),
|
|
kind: PersistedWindowKind::Main,
|
|
panel: None,
|
|
project_id: None,
|
|
plugin_layout: None,
|
|
url: None,
|
|
visible: true,
|
|
maximized: true,
|
|
fullscreen: false,
|
|
outer_position: None,
|
|
outer_size: None,
|
|
monitor: None,
|
|
last_focused_at: None,
|
|
}]);
|
|
|
|
store.save_window_state(&snapshot).await.unwrap();
|
|
assert_eq!(store.load_window_state().await.unwrap(), snapshot);
|
|
assert!(tmp.0.join("windows.json").exists());
|
|
}
|