返回 DeepSeek-TUI-2026
snapshot.rs
根目录 / crates / tui-core / tests / snapshot.rs
1 use deepseek_tui_core::{Pane, UiEvent, UiState};
2
3 #[test]
4 fn reducer_produces_stable_snapshot_for_core_workflow() {
5 let mut state = UiState::default();
6 state.reduce(UiEvent::PromptSubmitted("hello".to_string()));
7 state.reduce(UiEvent::ToolStarted("web.search".to_string()));
8 state.reduce(UiEvent::ResponseDelta("partial".to_string()));
9 state.reduce(UiEvent::ToolFinished("web.search".to_string()));
10 state.reduce(UiEvent::ApprovalRequested("approval-1".to_string()));
11 state.reduce(UiEvent::ApprovalResolved("approval-1".to_string()));
12 state.reduce(UiEvent::JobQueued("job-1".to_string()));
13 state.reduce(UiEvent::JobProgress {
14 job_id: "job-1".to_string(),
15 progress: 60,
16 });
17 state.reduce(UiEvent::JobCompleted("job-1".to_string()));
18 state.reduce(UiEvent::KeyPressed('5'));
19
20 assert_eq!(state.active_pane, Pane::Jobs);
21 assert_eq!(
22 state.snapshot(),
23 "pane=Jobs;paused=false;pending_tasks=0;active_jobs=0;pending_approvals=0;active_tool=;status=job completed"
24 );
25 }
26
26 lines RUST