Skip to content

Commit c3ae8a8

Browse files
committed
test(tui): neutralize model hints in placeholder header test
The startup-phase label only renders when no model hint is known, so a sibling test that exports JCODE_MODEL or persists a config default_model in the shared test home suppressed the 'loading session' placeholder. Pin JCODE_MODEL=unknown (which also disables the config fallback) under the env lock for the duration.
1 parent 0210517 commit c3ae8a8

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

crates/jcode-tui/src/tui/ui_header.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1481,8 +1481,17 @@ mod tests {
14811481
fn build_header_lines_omits_placeholder_provider_label_when_unknown() {
14821482
// Reads model/provider env-derived state: without the env lock, the
14831483
// sibling test that sets JCODE_MODEL=gpt-5.4 mid-flight leaks into this
1484-
// render and the "loading session…" placeholder never appears.
1484+
// render and the "loading session…" placeholder never appears. The
1485+
// startup-phase label is also only rendered when no model hint is
1486+
// known, so neutralize JCODE_MODEL/JCODE_PROVIDER for the duration
1487+
// ("unknown" also suppresses the shared test home's config
1488+
// default_model fallback, which another test may have persisted).
14851489
let _guard = crate::storage::lock_test_env();
1490+
let prev_model = std::env::var_os("JCODE_MODEL");
1491+
let prev_provider = std::env::var_os("JCODE_PROVIDER");
1492+
crate::env::set_var("JCODE_MODEL", "unknown");
1493+
crate::env::remove_var("JCODE_PROVIDER");
1494+
14861495
let mut app = crate::tui::app::App::new_for_remote(None);
14871496
app.set_remote_startup_phase(crate::tui::app::RemoteStartupPhase::LoadingSession);
14881497

@@ -1495,6 +1504,17 @@ mod tests {
14951504
.map(|span| span.content.as_ref())
14961505
.collect::<String>();
14971506

1507+
if let Some(prev_model) = prev_model {
1508+
crate::env::set_var("JCODE_MODEL", prev_model);
1509+
} else {
1510+
crate::env::remove_var("JCODE_MODEL");
1511+
}
1512+
if let Some(prev_provider) = prev_provider {
1513+
crate::env::set_var("JCODE_PROVIDER", prev_provider);
1514+
} else {
1515+
crate::env::remove_var("JCODE_PROVIDER");
1516+
}
1517+
14981518
assert!(rendered.contains("loading session…"), "{rendered}");
14991519
assert!(!rendered.contains("(unknown)"));
15001520
assert!(!rendered.contains("(remote)"));

0 commit comments

Comments
 (0)