Simplify TUI startup test coverage (#22573)

## Why

The TUI startup test surface had drifted into expensive, brittle
coverage:

- `tui/tests/suite/no_panic_on_startup.rs` was already ignored as flaky
while still spawning a PTY to exercise malformed exec-policy rules.
- `tui/tests/suite/model_availability_nux.rs` used a seeded session,
cursor-query spoofing, and repeated interrupts to verify a narrow
resume-path invariant.
- `app/tests.rs` had started accumulating unrelated startup and summary
coverage in one flat module even after the surrounding app code was
split into feature modules.

This keeps those behaviors covered while making the tests cheaper to
understand and less likely to rot. It also preserves the malformed-rules
regression from #8803 without requiring a terminal orchestration test.

## What changed

- Replaced the malformed `rules` startup PTY case with a direct
exec-policy loader regression:

[`rules_path_file_returns_read_dir_error`](https://github.com/openai/codex/blob/21b6b5622f18b8cac0ea41fd083b3106778d9ffc/codex-rs/core/src/exec_policy_tests.rs#L264-L284)
- Made the existing fresh-session-only startup tooltip behavior explicit
with

[`should_prepare_startup_tooltip_override`](https://github.com/openai/codex/blob/21b6b5622f18b8cac0ea41fd083b3106778d9ffc/codex-rs/tui/src/app/thread_routing.rs#L1272-L1279),
then added focused coverage for the resume/fork gate and the persisted
NUX counter.
- Split startup and session-summary coverage out of
`tui/src/app/tests.rs` into dedicated modules so the test layout better
mirrors the current app architecture.
- Converted one single-message goal validation snapshot into semantic
assertions where layout was not the behavior under test.
- Removed the two PTY-heavy suite files that the narrower tests now
supersede.

## Verification

- `cargo test -p codex-core rules_path_file_returns_read_dir_error`
- `cargo test -p codex-tui startup_`
- `cargo test -p codex-tui session_summary_`
- `cargo test -p codex-tui
goal_slash_command_rejects_oversized_objective`
This commit is contained in:
Eric Traut
2026-05-13 18:16:54 -07:00
committed by GitHub
Unverified
parent 4e368aa2e9
commit 35451ba79c
14 changed files with 373 additions and 630 deletions
+20
View File
@@ -260,6 +260,26 @@ async fn returns_empty_policy_when_no_policy_files_exist() {
assert!(!temp_dir.path().join(RULES_DIR_NAME).exists());
}
#[tokio::test]
async fn rules_path_file_returns_read_dir_error() {
let temp_dir = tempdir().expect("create temp dir");
let rules_path = temp_dir.path().join(RULES_DIR_NAME);
fs::write(&rules_path, "rules should be a directory").expect("write malformed rules path");
let config_stack = config_stack_for_dot_codex_folder(temp_dir.path());
let err = load_exec_policy(&config_stack)
.await
.expect_err("rules file should fail policy loading");
assert!(
matches!(
err,
ExecPolicyError::ReadDir { ref dir, .. } if dir == &rules_path
),
"expected malformed rules path to surface as ReadDir, got {err:?}"
);
}
#[tokio::test]
async fn collect_policy_files_returns_empty_when_dir_missing() {
let temp_dir = tempdir().expect("create temp dir");