Skip to content

Commit 8ea401c

Browse files
kdy1claude
andcommitted
test(desktop): check that no stepper failure names a value
The doc comment on `step_to` promises its failures name no value, since a secret filled into a stepper could come back re-parsed (`0042` as `42`), where the ledger would not redact it. Only the "steps past" message was checked. The test now drives every failure `step_to` gives: a wrap, a step past and back, a step past that cannot go back, a probe that left the value changed, and one out of time. It asserts no ASCII digit appears in any of them. Asked for by michal-e2e's review of #2353. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 786e290 commit 8ea401c

2 files changed

Lines changed: 75 additions & 0 deletions

File tree

‎crates/e2e-desktop-napi/src/actions/mod.rs‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,80 @@ mod tests {
11871187
assert_eq!(failure.details, Some(serde_json::json!({ "retryable": true })));
11881188
}
11891189

1190+
#[test]
1191+
fn names_no_value_in_any_stepper_failure() {
1192+
let digitless = |failure: crate::failure::Failure| {
1193+
assert!(!failure.message.chars().any(|c| c.is_ascii_digit()), "names a value: {}", failure.message);
1194+
};
1195+
// Wraps: one step up from 42 goes to 0.
1196+
let value = Cell::new(42.0);
1197+
digitless(
1198+
step_to(
1199+
43.0,
1200+
Some(42.0),
1201+
later(),
1202+
|_| {
1203+
value.set(0.0);
1204+
Ok(())
1205+
},
1206+
|| Some(value.get()),
1207+
)
1208+
.expect_err("wraps"),
1209+
);
1210+
// Steps past and back: 40, 42, 44 past 43, then back to 40.
1211+
let value = Cell::new(40.0);
1212+
digitless(
1213+
step_to(
1214+
43.0,
1215+
Some(40.0),
1216+
later(),
1217+
|up| {
1218+
value.set(value.get() + if up { 2.0 } else { -2.0 });
1219+
Ok(())
1220+
},
1221+
|| Some(value.get()),
1222+
)
1223+
.expect_err("past"),
1224+
);
1225+
// Steps past and cannot go back.
1226+
let value = Cell::new(40.0);
1227+
digitless(
1228+
step_to(
1229+
43.0,
1230+
Some(40.0),
1231+
later(),
1232+
|up| {
1233+
if up {
1234+
value.set(value.get() + 2.0)
1235+
}
1236+
Ok(())
1237+
},
1238+
|| Some(value.get()),
1239+
)
1240+
.expect_err("stuck past"),
1241+
);
1242+
// Already showed the target up to rounding, and the step to tell it left it changed.
1243+
let summed = 0.1 + 0.1 + 0.1;
1244+
let value = Cell::new(summed);
1245+
digitless(
1246+
step_to(
1247+
0.3,
1248+
Some(summed),
1249+
later(),
1250+
|up| {
1251+
if !up {
1252+
value.set(value.get() - 0.1)
1253+
}
1254+
Ok(())
1255+
},
1256+
|| Some(value.get()),
1257+
)
1258+
.expect_err("left changed"),
1259+
);
1260+
// Out of time before the first step.
1261+
digitless(step_to(43.0, Some(40.0), Instant::now(), |_| Ok(()), || Some(40.0)).expect_err("no time"));
1262+
}
1263+
11901264
#[test]
11911265
fn takes_only_a_finite_number() {
11921266
assert_eq!(super::finite(" 3 "), Ok(3.0));

‎crates/e2e-desktop-napi/src/actions/values.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ pub(super) fn shown_number(read: Result<Value, AXError>, what: &str) -> Outcome<
223223
_ => Ok(None),
224224
}
225225
}
226+
226227
/// Whether a stepper's target lies outside the range it reports: below `min` or above `max`. A bound it does not report
227228
/// limits nothing.
228229
pub(super) fn outside(target: f64, min: Option<f64>, max: Option<f64>) -> bool {

0 commit comments

Comments
 (0)