Skip to content

Commit 8227c8d

Browse files
claudesinelaw
authored andcommitted
test(trust,dock): tighten the new e2e guards against vacuous passes
Assertions that can be satisfied by the starting state prove nothing. Each of the three now pins the "before" as well as the "after": the delete-confirmation helper asserts the heading is absent before waiting for it, and the trust-radio test asserts the Trust option starts unselected before claiming the click selected it. Button hits also match the rendered `[ Delete ]` / `[ OK ]` rather than the bare word, so a click can't land on an unrelated row that happens to contain it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015UhcWWiiLz3uEQfxVp5aYk
1 parent a9e4cf2 commit 8227c8d

1 file changed

Lines changed: 30 additions & 7 deletions

File tree

crates/fresh-editor/tests/e2e/orchestrator_dialog_trust_repro.rs

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,22 @@ fn open_delete_confirmation(height: u16) -> (tempfile::TempDir, EditorTestHarnes
111111
h.render().unwrap();
112112
open_dock(&mut h);
113113

114+
// Guard the wait below against passing vacuously: the confirmation's
115+
// heading must not already be on screen before we ask for it.
116+
assert!(
117+
!h.screen_to_string().contains("Confirm Delete"),
118+
"the dock must not already be showing a delete confirmation"
119+
);
120+
114121
let card_row = row_of(&h, "alphaproj") as u16;
115122
h.mouse_right_click(4, card_row).unwrap();
116-
h.wait_until(|h| h.screen_to_string().contains("Delete"))
123+
// Match the rendered button, not the bare word — "Delete" alone could pick
124+
// up any other row that happens to mention it.
125+
h.wait_until(|h| h.screen_to_string().contains("[ Delete ]"))
117126
.unwrap();
118127

119-
let (dcol, drow) = pos_of(&h, "Delete");
120-
h.mouse_click(dcol, drow).unwrap();
128+
let (dcol, drow) = pos_of(&h, "[ Delete ]");
129+
h.mouse_click(dcol + 2, drow).unwrap();
121130
h.wait_until(|h| h.screen_to_string().contains("Confirm Delete"))
122131
.unwrap();
123132
(tmp, h)
@@ -285,6 +294,20 @@ fn trust_dialog_radio_click_selects_without_accepting() {
285294
h.wait_until(|h| h.screen_to_string().contains("SECURITY WARNING"))
286295
.unwrap();
287296

297+
// The prompt opens on the safe default, so the "(*)" assertion below is a
298+
// real state change rather than a value that was already there.
299+
let trust_row = row_of(&h, "Trust folder & Allow Tooling");
300+
let before = h
301+
.screen_to_string()
302+
.lines()
303+
.nth(trust_row)
304+
.unwrap()
305+
.to_string();
306+
assert!(
307+
before.contains("( )"),
308+
"the Trust option should start unselected.\nRow: {before}"
309+
);
310+
288311
// Click "Trust folder & Allow Tooling (T)".
289312
let (col, row) = pos_of(&h, "Trust folder & Allow Tooling");
290313
h.mouse_click(col + 2, row).unwrap();
@@ -304,7 +327,6 @@ fn trust_dialog_radio_click_selects_without_accepting() {
304327
);
305328

306329
// The click did move the selection: the Trust row is now the marked radio.
307-
let trust_row = row_of(&h, "Trust folder & Allow Tooling");
308330
let line = h
309331
.screen_to_string()
310332
.lines()
@@ -316,9 +338,10 @@ fn trust_dialog_radio_click_selects_without_accepting() {
316338
"the clicked row should become the selected radio.\nRow: {line}"
317339
);
318340

319-
// [ OK ] commits it.
320-
let (ok_col, ok_row) = pos_of(&h, "OK");
321-
h.mouse_click(ok_col + 1, ok_row).unwrap();
341+
// [ OK ] commits it. Match the rendered button so the hit can't land on a
342+
// stray "OK" elsewhere on screen.
343+
let (ok_col, ok_row) = pos_of(&h, "[ OK ]");
344+
h.mouse_click(ok_col + 2, ok_row).unwrap();
322345
h.wait_until(|h| !h.screen_to_string().contains("SECURITY WARNING"))
323346
.unwrap();
324347
let status = status_bar(&h);

0 commit comments

Comments
 (0)