Files
codex/codex-rs/tui/src/analytics/compact_tests.rs
T
Felipe Coury 9bd49c9dcc Add an account Summary tab to Analytics (#45769)
## What changed

- Make Summary the initial Analytics tab, showing profile identity, token totals, streaks, activity insights, and most-used plugins and skills.
- Move daily, weekly, and cumulative token activity charts into Summary. Replace the usage menu's separate views with “View analytics”; `/usage weekly` and the other explicit modes open Summary with the requested view, while reopening from the menu retains navigation.
- Load account profiles independently of other reports, preserve missing values separately from zero, and reject responses when the active account changes. Refresh retries profile failures.
- Adapt Summary to narrow terminals and compact large chart totals and axis labels. Show the account email without its ID in the Analytics header.
- Flush queued transcript history before opening an overlay so startup output stays in the transcript.

## Testing

Add profile decoding and account identity tests, Summary layout and navigation snapshots, refresh and cancellation coverage, and regression tests for retained navigation and transcript history when opening Analytics.

GitOrigin-RevId: 6dbe6c4c98209000d8b4bc18a4e01b98fab5991a
2026-09-15 19:13:08 +00:00

49 lines
1.5 KiB
Rust

//! Large report totals and axes stay compact while selected-day details retain precision.
use super::*;
#[test]
fn report_headlines_and_axes_compact_large_values() {
let mut screenshots = Vec::new();
for (section, unit, total, headline) in [
(
Section::Usage,
models::AccountAnalyticsUnit::Tokens,
12_280_365_226.0,
"12.3B tokens",
),
(
Section::Plugins,
models::AccountAnalyticsUnit::Count,
9_749.0,
"9.7K calls",
),
(
Section::Skills,
models::AccountAnalyticsUnit::Count,
2_901.0,
"2.9K uses",
),
] {
let mut view = fixture::view(models::AccountKind::Enterprise);
view.section = section;
view.sections[section].history = Load::Ready(models::AccountAnalyticsHistory {
unit,
updated_at: None,
data: vec![models::AccountAnalyticsDay {
date: view.end_date,
total,
values: vec![models::AccountAnalyticsValue {
key: "test".into(),
label: "Example".into(),
value: total,
}],
}],
});
let rendered = screen(&mut view, /*width*/ 100, /*height*/ 30);
assert!(rendered.contains(headline));
assert!(rendered.contains(&data::amount(total)));
screenshots.push(rendered);
}
insta::assert_snapshot!(screenshots.join("\n"));
}