Skip to content

Commit b8a57ec

Browse files
voidstackloopclaude
andcommitted
Close the coverage gap in check_input_persistence's four-way status
The core "lost input" scenario this check exists to catch (a field silently clears itself with no explanation -> Fail) had never actually been exercised by a test — every existing input-persistence test asserted the Pass path. The Warn branches (a session-timeout notice explaining an apparent loss; no text field to test at all) were likewise unverified. Added three fixtures exercising each untested branch: - input-vanishes-form.html: a field cleared by the page's own JS with no explanation -> Fail. - session-timeout-warning-form.html: a session-expiry notice appears -> Warn, not Fail, since the site explains the apparent loss. - no-text-field-form.html: only a checkbox and a select, no text field to test -> Warn, not a silently skipped check. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 39817e9 commit b8a57ec

4 files changed

Lines changed: 115 additions & 0 deletions

File tree

‎fixtures/input-vanishes-form.html‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head><meta charset="utf-8"><title>Input Vanishes Silently</title></head>
4+
<body>
5+
<!-- Simulates a real "lost input" bug: something on the page clears the
6+
field shortly after the user types, with no explanation (no session
7+
warning, nothing) — check_input_persistence should Fail on this. -->
8+
<form>
9+
<label for="fullname">Full name</label>
10+
<input id="fullname" name="fullname" type="text">
11+
12+
<button type="submit">Submit</button>
13+
</form>
14+
<script>
15+
setTimeout(() => {
16+
document.getElementById('fullname').value = '';
17+
}, 300);
18+
</script>
19+
</body>
20+
</html>

‎fixtures/no-text-field-form.html‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head><meta charset="utf-8"><title>No Text Field</title></head>
4+
<body>
5+
<!-- Nothing here is a text input or textarea — check_input_persistence
6+
has no field to plant a marker in and should say so, not silently
7+
report on the wrong element type. -->
8+
<form>
9+
<label><input type="checkbox" name="agree"> I agree to the terms</label>
10+
11+
<label for="permit-type">Permit type</label>
12+
<select id="permit-type" name="permit-type">
13+
<option value="residential">Residential</option>
14+
<option value="commercial">Commercial</option>
15+
</select>
16+
17+
<button type="submit">Submit</button>
18+
</form>
19+
</body>
20+
</html>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head><meta charset="utf-8"><title>Session Timeout Warning</title></head>
4+
<body>
5+
<!-- A page that explains an apparent loss instead of leaving the user
6+
guessing — check_input_persistence should Warn (not Fail), since
7+
the site itself is telling the user what happened. -->
8+
<form>
9+
<label for="fullname">Full name</label>
10+
<input id="fullname" name="fullname" type="text">
11+
12+
<button type="submit">Submit</button>
13+
</form>
14+
<p id="notice" hidden>Your session has expired. Please log in again.</p>
15+
<script>
16+
setTimeout(() => {
17+
document.getElementById('notice').hidden = false;
18+
}, 300);
19+
</script>
20+
</body>
21+
</html>

‎tests/checks_test.rs‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,60 @@ async fn input_persistence_targets_the_real_form_not_a_header_search_box() {
223223
);
224224
}
225225

226+
#[tokio::test]
227+
async fn input_that_vanishes_with_no_explanation_is_a_fail() {
228+
// fixtures/input-vanishes-form.html clears the field on its own,
229+
// shortly after the user types, with nothing on the page explaining
230+
// why — the core "lost input" scenario this check exists to catch,
231+
// never directly asserted before (every other input-persistence test
232+
// asserts the Pass path).
233+
let (_browser, page, _handle) = open_fixture("input-vanishes-form.html").await;
234+
let result = checks::check_input_persistence(&page, 1)
235+
.await
236+
.expect("check_input_persistence");
237+
assert_eq!(result.status, checks::Status::Fail, "got: {result:?}");
238+
assert!(
239+
result.detail.contains("input retained=false"),
240+
"got: {}",
241+
result.detail
242+
);
243+
}
244+
245+
#[tokio::test]
246+
async fn input_loss_explained_by_a_session_notice_is_a_warn_not_a_fail() {
247+
// fixtures/session-timeout-warning-form.html surfaces a session-expiry
248+
// notice — the site explaining an apparent loss should be a Warn, not
249+
// the same Fail as a silent, unexplained one.
250+
let (_browser, page, _handle) = open_fixture("session-timeout-warning-form.html").await;
251+
let result = checks::check_input_persistence(&page, 1)
252+
.await
253+
.expect("check_input_persistence");
254+
assert_eq!(result.status, checks::Status::Warn, "got: {result:?}");
255+
assert!(
256+
result.detail.contains("session-timeout wording seen=true"),
257+
"got: {}",
258+
result.detail
259+
);
260+
}
261+
262+
#[tokio::test]
263+
async fn no_text_field_to_test_is_reported_not_silently_skipped() {
264+
// fixtures/no-text-field-form.html has only a checkbox and a select —
265+
// check_input_persistence has nothing to plant a marker in and should
266+
// say so plainly, rather than the caller mistaking a missing check for
267+
// an untested-and-fine one.
268+
let (_browser, page, _handle) = open_fixture("no-text-field-form.html").await;
269+
let result = checks::check_input_persistence(&page, 1)
270+
.await
271+
.expect("check_input_persistence");
272+
assert_eq!(result.status, checks::Status::Warn, "got: {result:?}");
273+
assert!(
274+
result.detail.contains("No text field found to test"),
275+
"got: {}",
276+
result.detail
277+
);
278+
}
279+
226280
#[tokio::test]
227281
async fn icon_only_next_button_is_recognized_via_aria_label() {
228282
// fixtures/icon-only-buttons.html's Next/Submit buttons have no text,

0 commit comments

Comments
 (0)