Skip to content

Commit 57adfdf

Browse files
CodeWhale Botclaude
andcommitted
test(tui): align pricing and picker-action tests with the 7d2308a provider fix
Five codewhale-tui tests failed after 7d2308a (reported on Linux at 0cf390f, confirmed by the same filters on macOS). In each case the product behaviour is the intended one and the test encoded the old behaviour: - pricing::tests::stepfun_billing_surface_keeps_payg_separate_from_step_plan and unpublished_cache_write_fails_closed_but_documented_same_rate_prices used DEFAULT_STEPFUN_MODEL as a fixture while asserting Step 3.7 Flash's PAYG rate (0.735) and its unpublished cache-write policy. The default is now step-5-preview, whose documented cache-write is the input rate. The tests now name step-3.7-flash, the model their numbers belong to. - tui::ui::tests::model_picker_actions: Shift+P / Shift+F are query text while searching (so `Step-5-Preview` can be typed), and Ctrl+P / Ctrl+F act on the highlighted row. shift_p/shift_f_after_a_search_* become ctrl_p/ctrl_f_after_a_search_* driving Ctrl chords, and pin_and_fleet_hints_hide_when_no_catalog_route_is_highlighted now expects the Ctrl hints while searching and no shifted hints. Checks (macOS, on c5cd7c8 plus these two files): `scripts/dev-cargo.sh test -p codewhale-tui --lib -- pricing::tests:: tui::ui::tests::model_picker_actions tui::model_picker` 123 passed, 0 failed. Touched paths: crates/tui/src/pricing.rs, crates/tui/src/tui/ui/tests/model_picker_actions.rs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent c5cd7c8 commit 57adfdf

2 files changed

Lines changed: 37 additions & 28 deletions

File tree

‎crates/tui/src/pricing.rs‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2843,14 +2843,14 @@ mod tests {
28432843
// rate.
28442844
let stepfun = pricing_for_billing_surface(
28452845
ProviderKind::Stepfun,
2846-
DEFAULT_STEPFUN_MODEL,
2846+
"step-3.7-flash",
28472847
Some(STEPFUN_PAYG_BILLING_SURFACE),
28482848
)
28492849
.expect("StepFun PAYG row");
28502850
assert_eq!(stepfun.usd.cache_write, CacheWritePolicy::Unpublished);
28512851
let failed = audit_turn_cost_for_route_at(
28522852
ProviderKind::Stepfun,
2853-
DEFAULT_STEPFUN_MODEL,
2853+
"step-3.7-flash",
28542854
Some(STEPFUN_PAYG_BILLING_SURFACE),
28552855
&write_heavy,
28562856
now,
@@ -2871,7 +2871,7 @@ mod tests {
28712871
assert!(
28722872
audit_turn_cost_for_route_at(
28732873
ProviderKind::Stepfun,
2874-
DEFAULT_STEPFUN_MODEL,
2874+
"step-3.7-flash",
28752875
Some(STEPFUN_PAYG_BILLING_SURFACE),
28762876
&no_write,
28772877
now,
@@ -3499,7 +3499,7 @@ mod tests {
34993499
};
35003500
let payg = calculate_turn_cost_estimate_for_billing_surface(
35013501
ProviderKind::Stepfun,
3502-
DEFAULT_STEPFUN_MODEL,
3502+
"step-3.7-flash",
35033503
Some(STEPFUN_PAYG_BILLING_SURFACE),
35043504
&usage,
35053505
)
@@ -3512,30 +3512,30 @@ mod tests {
35123512
assert!(
35133513
calculate_turn_cost_estimate_for_provider(
35143514
ProviderKind::Stepfun,
3515-
DEFAULT_STEPFUN_MODEL,
3515+
"step-3.7-flash",
35163516
&usage,
35173517
)
35183518
.is_none()
35193519
);
35203520
assert!(
35213521
calculate_turn_cost_estimate_for_provider_at(
35223522
ProviderKind::Stepfun,
3523-
DEFAULT_STEPFUN_MODEL,
3523+
"step-3.7-flash",
35243524
&usage,
35253525
Utc::now(),
35263526
)
35273527
.is_none()
35283528
);
35293529
assert!(!has_pricing_for_provider(
35303530
ProviderKind::Stepfun,
3531-
DEFAULT_STEPFUN_MODEL
3531+
"step-3.7-flash"
35323532
));
35333533

35343534
for surface in [None, Some(STEPFUN_PLAN_BILLING_SURFACE)] {
35353535
assert!(
35363536
calculate_turn_cost_estimate_for_billing_surface(
35373537
ProviderKind::Stepfun,
3538-
DEFAULT_STEPFUN_MODEL,
3538+
"step-3.7-flash",
35393539
surface,
35403540
&usage,
35413541
)
@@ -3559,37 +3559,37 @@ mod tests {
35593559
assert!(
35603560
calculate_turn_cost_estimate_for_billing_surface(
35613561
provider,
3562-
DEFAULT_STEPFUN_MODEL,
3562+
"step-3.7-flash",
35633563
Some(STEPFUN_PAYG_BILLING_SURFACE),
35643564
&usage,
35653565
)
35663566
.is_none(),
35673567
"{provider:?}"
35683568
);
35693569
assert!(
3570-
calculate_turn_cost_estimate_for_provider(provider, DEFAULT_STEPFUN_MODEL, &usage,)
3570+
calculate_turn_cost_estimate_for_provider(provider, "step-3.7-flash", &usage,)
35713571
.is_none(),
35723572
"{provider:?}"
35733573
);
35743574
assert!(
35753575
calculate_turn_cost_estimate_for_provider_at(
35763576
provider,
3577-
DEFAULT_STEPFUN_MODEL,
3577+
"step-3.7-flash",
35783578
&usage,
35793579
Utc::now(),
35803580
)
35813581
.is_none(),
35823582
"{provider:?}"
35833583
);
35843584
assert!(
3585-
!has_pricing_for_provider(provider, DEFAULT_STEPFUN_MODEL),
3585+
!has_pricing_for_provider(provider, "step-3.7-flash"),
35863586
"{provider:?}"
35873587
);
35883588
}
35893589

35903590
let recorded = calculate_turn_cost_estimate_for_route_at(
35913591
ProviderKind::Stepfun,
3592-
DEFAULT_STEPFUN_MODEL,
3592+
"step-3.7-flash",
35933593
Some(STEPFUN_PAYG_BILLING_SURFACE),
35943594
&usage,
35953595
Utc::now(),

‎crates/tui/src/tui/ui/tests/model_picker_actions.rs‎

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! #6500: the model picker's ⇧P / ⇧F / ⇧D after a search, driven through the
1+
//! #6500: the model picker's Ctrl+P / Ctrl+F / ⇧D after a search, driven through the
22
//! open view stack, the event handler, disk, and the rendered picker.
33
44
use super::*;
@@ -42,6 +42,10 @@ fn shifted(ch: char) -> KeyEvent {
4242
KeyEvent::new(KeyCode::Char(ch), KeyModifiers::SHIFT)
4343
}
4444

45+
fn ctrl(ch: char) -> KeyEvent {
46+
KeyEvent::new(KeyCode::Char(ch), KeyModifiers::CONTROL)
47+
}
48+
4549
fn render_picker(app: &mut App) -> String {
4650
assert_eq!(app.view_stack.top_kind(), Some(ModalKind::ModelPicker));
4751
let view = app.view_stack.pop().unwrap();
@@ -71,15 +75,15 @@ fn row_line<'a>(screen: &'a str, model: &str) -> &'a str {
7175
}
7276

7377
#[test]
74-
fn shift_p_after_a_search_pins_the_highlighted_row_and_says_so_in_the_picker() {
78+
fn ctrl_p_after_a_search_pins_the_highlighted_row_and_says_so_in_the_picker() {
7579
let _lock = crate::test_support::lock_test_env();
7680
let root = tempfile::tempdir().unwrap();
7781
let _home = crate::test_support::EnvVarGuard::set("CODEWHALE_HOME", root.path().join("home"));
7882
let (mut app, config) = app_with_open_picker(root.path());
7983
let model = app.model.clone();
8084
type_query(&mut app, &model);
8185

82-
let events = app.view_stack.handle_key(shifted('P'));
86+
let events = app.view_stack.handle_key(ctrl('p'));
8387
let [
8488
ViewEvent::ModelPickerTogglePin {
8589
provider,
@@ -88,7 +92,7 @@ fn shift_p_after_a_search_pins_the_highlighted_row_and_says_so_in_the_picker() {
8892
},
8993
] = events.as_slice()
9094
else {
91-
panic!("⇧P while searching must pin the highlighted row, got {events:?}");
95+
panic!("Ctrl+P while searching must pin the highlighted row, got {events:?}");
9296
};
9397
assert_eq!(picked, &model);
9498
let provider_key = provider_id
@@ -116,11 +120,11 @@ fn shift_p_after_a_search_pins_the_highlighted_row_and_says_so_in_the_picker() {
116120
);
117121
assert!(
118122
screen.contains(&format!("Model: {model}")) && !screen.contains(&format!("{model}P")),
119-
"⇧P must not become query text:\n{screen}"
123+
"Ctrl+P must not become query text:\n{screen}"
120124
);
121125

122126
// The same chord on the same row unpins it, on disk and on screen.
123-
let events = app.view_stack.handle_key(shifted('P'));
127+
let events = app.view_stack.handle_key(ctrl('p'));
124128
assert!(matches!(
125129
events.as_slice(),
126130
[ViewEvent::ModelPickerTogglePin { model: again, .. }] if again == &model
@@ -137,15 +141,15 @@ fn shift_p_after_a_search_pins_the_highlighted_row_and_says_so_in_the_picker() {
137141
}
138142

139143
#[test]
140-
fn shift_f_after_a_search_adds_the_highlighted_row_to_fleet_and_says_so_in_the_picker() {
144+
fn ctrl_f_after_a_search_adds_the_highlighted_row_to_fleet_and_says_so_in_the_picker() {
141145
let _lock = crate::test_support::lock_test_env();
142146
let root = tempfile::tempdir().unwrap();
143147
let _home = crate::test_support::EnvVarGuard::set("CODEWHALE_HOME", root.path().join("home"));
144148
let (mut app, config) = app_with_open_picker(root.path());
145149
let model = app.model.clone();
146150
type_query(&mut app, &model);
147151

148-
let events = app.view_stack.handle_key(shifted('F'));
152+
let events = app.view_stack.handle_key(ctrl('f'));
149153
let [
150154
ViewEvent::ModelPickerToggleFleet {
151155
provider,
@@ -154,7 +158,7 @@ fn shift_f_after_a_search_adds_the_highlighted_row_to_fleet_and_says_so_in_the_p
154158
},
155159
] = events.as_slice()
156160
else {
157-
panic!("⇧F while searching must toggle Fleet for the highlighted row, got {events:?}");
161+
panic!("Ctrl+F while searching must toggle Fleet for the highlighted row, got {events:?}");
158162
};
159163
assert_eq!(picked, &model);
160164
let provider_key = provider_id
@@ -181,7 +185,7 @@ fn shift_f_after_a_search_adds_the_highlighted_row_to_fleet_and_says_so_in_the_p
181185
);
182186

183187
// Toggling again removes the shortlist row it added.
184-
let events = app.view_stack.handle_key(shifted('F'));
188+
let events = app.view_stack.handle_key(ctrl('f'));
185189
assert!(matches!(
186190
events.as_slice(),
187191
[ViewEvent::ModelPickerToggleFleet { model: again, .. }] if again == &model
@@ -272,8 +276,9 @@ fn picker_receipt_renders_its_semantic_level_through_the_palette() {
272276
assert_eq!(receipt_fg(&mut app, success), theme.status_working);
273277
}
274278

275-
/// #6523 review: while a custom model id is typed there is no highlighted
276-
/// catalog route, ⇧P / ⇧F are query text, so the footer must not offer them.
279+
/// #6523 review: while searching, ⇧P / ⇧F are query text and Ctrl+P / Ctrl+F
280+
/// are offered for a highlighted catalog route; with no highlighted route
281+
/// (a custom model id) neither is offered.
277282
#[test]
278283
fn pin_and_fleet_hints_hide_when_no_catalog_route_is_highlighted() {
279284
let _lock = crate::test_support::lock_test_env();
@@ -284,9 +289,13 @@ fn pin_and_fleet_hints_hide_when_no_catalog_route_is_highlighted() {
284289
type_query(&mut app, &model);
285290
let screen = render_picker(&mut app);
286291
assert!(
287-
screen.contains("⇧P") && screen.contains("⇧F"),
292+
screen.contains("Ctrl+P") && screen.contains("Ctrl+F"),
288293
"a highlighted route offers its verbs:\n{screen}"
289294
);
295+
assert!(
296+
!screen.contains("⇧P") && !screen.contains("⇧F"),
297+
"shifted letters are query text while searching:\n{screen}"
298+
);
290299

291300
let mut app_custom = {
292301
let (app, _config) = app_with_open_picker(root.path());
@@ -295,9 +304,9 @@ fn pin_and_fleet_hints_hide_when_no_catalog_route_is_highlighted() {
295304
type_query(&mut app_custom, "zz-no-such-model-xyz");
296305
let screen = render_picker(&mut app_custom);
297306
assert!(
298-
!screen.contains("⇧P") && !screen.contains("⇧F"),
307+
!screen.contains("Ctrl+P") && !screen.contains("Ctrl+F"),
299308
"no highlighted route, no Pin/Fleet hints:\n{screen}"
300309
);
301-
let events = app_custom.view_stack.handle_key(shifted('P'));
310+
let events = app_custom.view_stack.handle_key(ctrl('p'));
302311
assert!(events.is_empty(), "{events:?}");
303312
}

0 commit comments

Comments
 (0)