Assert popup selection in permissions history tests

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Ahmed Ibrahim
2026-03-14 03:52:57 +00:00
co-authored by Codex
parent 5dbb9c0048
commit dc8d5d46da
2 changed files with 26 additions and 3 deletions
+4 -3
View File
@@ -46,9 +46,9 @@ Older failures also appeared on Linux, but the repeated cross-PR signal is stron
## Current Fix In Progress
- Harden `permissions_selection_can_disable_smart_approvals` in `codex-rs/tui/src/chatwidget/tests.rs`.
- Seed the popup into Smart Approvals mode explicitly, then assert the selected row before and after navigation instead of assuming the initial cursor position.
- Rationale: recent merged PR `#14645` fixed another Smart Approvals popup test that was implicitly relying on selection state. This remaining test still used the same brittle pattern.
- Harden the nearby permissions-history popup tests in `codex-rs/tui/src/chatwidget/tests.rs`.
- Assert the selected row before hitting `Enter`, and assert that the selection actually moved after navigation instead of relying on implicit popup cursor placement.
- Rationale: recent merged PR `#14645` fixed one Smart Approvals popup test in this cluster, and the just-passing `permissions_selection_can_disable_smart_approvals` change fixed another. These adjacent history tests were still exercising the same selection flow without proving the cursor state.
## Constraints
@@ -63,3 +63,4 @@ Older failures also appeared on Linux, but the repeated cross-PR signal is stron
| --- | --- | --- | --- |
| `60f44b4d7` | PR bootstrap | partial pass | PR opened and non-Rust checks passed after rebasing to current `main`, but `rust-ci` skipped because only the tracking doc changed. This commit does not count toward the five full-suite green commits. |
| `b9c655ad4` | First full-suite flaky-test fix | full pass | Full PR CI passed on run `23078933382`, including `Tests — windows-x64 - x86_64-pc-windows-msvc` and `Tests — windows-arm64 - aarch64-pc-windows-msvc`. The approvals matrix write-file command now uses deterministic Python I/O instead of shell redirection. This is pass 1 of 5. |
| `5dbb9c004` | Second full-suite flaky-test fix | full pass | Full PR CI passed on run `23079410130`, including both Windows test jobs. `permissions_selection_can_disable_smart_approvals` now seeds Smart Approvals mode explicitly and asserts the popup selection before and after navigation. This is pass 2 of 5. |
+22
View File
@@ -6600,6 +6600,13 @@ fn render_bottom_popup(chat: &ChatWidget, width: u16) -> String {
lines.join("\n")
}
fn selected_popup_line(popup: &str) -> &str {
popup
.lines()
.find(|line| line.contains('›'))
.expect("expected popup to have a selected row")
}
#[tokio::test]
async fn apps_popup_stays_loading_until_final_snapshot_updates() {
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(None).await;
@@ -8329,7 +8336,17 @@ async fn permissions_selection_emits_history_cell_when_selection_changes() {
chat.config.notices.hide_full_access_warning = Some(true);
chat.open_permissions_popup();
let popup = render_bottom_popup(&chat, 120);
assert!(
selected_popup_line(&popup).contains("(current)"),
"expected permissions popup to open with the current preset selected: {popup}"
);
chat.handle_key_event(KeyEvent::from(KeyCode::Down));
let popup = render_bottom_popup(&chat, 120);
assert!(
!selected_popup_line(&popup).contains("(current)"),
"expected moving down to change the selected preset before confirmation: {popup}"
);
chat.handle_key_event(KeyEvent::from(KeyCode::Enter));
let cells = drain_insert_history(&mut rx);
@@ -8433,6 +8450,11 @@ async fn permissions_selection_emits_history_cell_when_current_is_selected() {
.expect("set sandbox policy");
chat.open_permissions_popup();
let popup = render_bottom_popup(&chat, 120);
assert!(
selected_popup_line(&popup).contains("(current)"),
"expected permissions popup to open with the current preset selected: {popup}"
);
chat.handle_key_event(KeyEvent::from(KeyCode::Enter));
let cells = drain_insert_history(&mut rx);