Skip to content

Commit 39817e9

Browse files
voidstackloopclaude
andcommitted
Test check_validation_errors' required_count == 0 early return
A form with nothing marked required/aria-required has nothing for native constraint validation to exercise, so this branch deliberately Warns instead of claiming a false Pass — but nothing ever proved that guard actually fires; it was unverified dead ground like the other early-return branches closed in the last two commits. Added fixtures/no-required-fields-form.html and a test asserting both the Warn status and the specific "couldn't exercise validation" message. Verified it was meaningful by temporarily disabling the guard (`if false`) — the check still returned Warn by coincidence, but with the wrong message, and the assertion caught it — before restoring the real `if required_count == 0`. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 5f9a2c1 commit 39817e9

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head><meta charset="utf-8"><title>No Required Fields</title></head>
4+
<body>
5+
<!-- Nothing here is marked required or aria-required — native
6+
constraint validation has nothing to exercise, so
7+
check_validation_errors should Warn rather than claim a false Pass. -->
8+
<form>
9+
<label for="comment">Optional comment</label>
10+
<input id="comment" name="comment" type="text">
11+
12+
<button type="submit">Submit</button>
13+
</form>
14+
</body>
15+
</html>

‎tests/checks_test.rs‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,25 @@ async fn required_document_upload_with_accept_and_a_label_passes() {
285285
assert_eq!(result.status, checks::Status::Pass, "got: {result:?}");
286286
}
287287

288+
#[tokio::test]
289+
async fn form_with_no_required_fields_warns_instead_of_a_false_pass() {
290+
// fixtures/no-required-fields-form.html has nothing marked required or
291+
// aria-required — native constraint validation has nothing to
292+
// exercise, so check_validation_errors should say so (Warn) rather
293+
// than claim a false Pass. The required_count == 0 early return, never
294+
// directly asserted before.
295+
let (_browser, page, _handle) = open_fixture("no-required-fields-form.html").await;
296+
let result = checks::check_validation_errors(&page)
297+
.await
298+
.expect("check_validation_errors");
299+
assert_eq!(result.status, checks::Status::Warn, "got: {result:?}");
300+
assert!(
301+
result.detail.contains("couldn't exercise validation"),
302+
"got: {}",
303+
result.detail
304+
);
305+
}
306+
288307
#[tokio::test]
289308
async fn page_text_promising_a_document_upload_with_no_file_field_is_flagged() {
290309
// fixtures/mentions-documents-no-upload-form.html tells the user to

0 commit comments

Comments
 (0)