Skip to content

Commit ce7a240

Browse files
cursoragentechobt
andcommitted
test(tui): fix unused-mut and dump harness snapshots
Remove unused mut on the auth select-method snapshot and write buffer dumps when CORTEX_DUMP_SNAPSHOTS is set for PR screenshots. Co-authored-by: Mathis <echobt@users.noreply.github.com>
1 parent 9c976ec commit ce7a240

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/cortex-tui/src/runner/login_screen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ mod tests {
924924

925925
#[test]
926926
fn snapshot_auth_select_method() {
927-
let mut screen = LoginScreen::new(PathBuf::from("/tmp"), None);
927+
let screen = LoginScreen::new(PathBuf::from("/tmp"), None);
928928
let backend = TestBackend::new(80, 24);
929929
let mut terminal = Terminal::new(backend).expect("test backend");
930930
terminal.draw(|f| screen.render(f)).expect("draw");

src/cortex-tui/src/views/minimal_session/tests.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,20 @@ mod harness_snapshots {
2929
buffer_text(&buf)
3030
}
3131

32+
fn dump_snapshot(name: &str, text: &str) {
33+
let Ok(dir) = std::env::var("CORTEX_DUMP_SNAPSHOTS") else {
34+
return;
35+
};
36+
let path = std::path::Path::new(&dir);
37+
let _ = std::fs::create_dir_all(path);
38+
let _ = std::fs::write(path.join(format!("{name}.txt")), text);
39+
}
40+
3241
#[test]
3342
fn snapshot_home_empty_session() {
3443
let state = AppState::default();
3544
let text = render(&state, 80, 24);
45+
dump_snapshot("home", &text);
3646
assert!(!text.to_lowercase().contains("grok"));
3747
assert!(
3848
text.contains("Cortex") || text.contains("session") || !text.trim().is_empty(),
@@ -46,6 +56,7 @@ mod harness_snapshots {
4656
state.add_message(cortex_core::widgets::Message::user("List the files"));
4757
state.add_message(cortex_core::widgets::Message::assistant("Hi"));
4858
let text = render(&state, 80, 24);
59+
dump_snapshot("session", &text);
4960
assert!(text.contains("List the files") || text.contains("Hi"));
5061
assert!(!text.to_lowercase().contains("grok"));
5162
}
@@ -64,6 +75,7 @@ mod harness_snapshots {
6475
call.append_output("reading src/main.rs".into());
6576
state.tool_calls.push(call);
6677
let text = render(&state, 80, 24);
78+
dump_snapshot("tools_running", &text);
6779
assert!(
6880
text.contains("Read") && text.contains("main.rs"),
6981
"tool row missing: {text}"
@@ -89,6 +101,7 @@ mod harness_snapshots {
89101
});
90102
state.tool_calls.push(call);
91103
let text = render(&state, 80, 24);
104+
dump_snapshot("plan", &text);
92105
assert!(
93106
text.contains("Plan") && (text.contains("mermaid") || text.contains("device")),
94107
"plan mermaid missing: {text}"
@@ -102,6 +115,7 @@ mod harness_snapshots {
102115
"The coding service is temporarily unavailable",
103116
));
104117
let text = render(&state, 80, 24);
118+
dump_snapshot("error", &text);
105119
assert!(text.contains("temporarily unavailable") || text.contains("coding service"));
106120
assert!(!text.to_lowercase().contains("reqwest"));
107121
assert!(!text.to_lowercase().contains("grok"));

0 commit comments

Comments
 (0)