Skip to content

Commit e9c7bb6

Browse files
committed
test(tui): tolerate seeded session-context reminder in usage-report test
App::new seeds the provider transcript with the immutable session-context system reminder, so materialized_provider_messages() is never empty for a fresh test app. Assert the usage report adds no provider-visible messages instead of asserting an empty transcript.
1 parent 1dfb56a commit e9c7bb6

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

  • crates/jcode-tui/src/tui/app/tests/commands_accounts_02

crates/jcode-tui/src/tui/app/tests/commands_accounts_02/part_01.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ fn test_usage_card_does_not_capture_typing() {
4141
fn test_usage_report_updates_display_only_card_without_system_message() {
4242
let mut app = create_test_app();
4343
app.usage_report_refreshing = true;
44+
// App::new seeds the provider transcript with the immutable session-context
45+
// reminder, so assert the usage report adds nothing on top of it rather
46+
// than expecting an empty transcript.
47+
let provider_messages_before = app.materialized_provider_messages().len();
4448
app.handle_usage_report(vec![crate::usage::ProviderUsage {
4549
provider_name: "OpenAI (ChatGPT)".to_string(),
4650
limits: vec![crate::usage::UsageLimit {
@@ -63,7 +67,12 @@ fn test_usage_report_updates_display_only_card_without_system_message() {
6367
assert!(msg.content.contains("5h"));
6468
assert!(msg.content.contains("82%"));
6569
assert!(msg.content.contains("plan: pro"));
66-
assert!(app.materialized_provider_messages().is_empty());
70+
let leaked = app.materialized_provider_messages();
71+
assert_eq!(
72+
leaked.len(),
73+
provider_messages_before,
74+
"usage report must not add provider-visible messages: {leaked:#?}"
75+
);
6776
}
6877

6978
#[test]

0 commit comments

Comments
 (0)