Commit 3b0b8160a3

3b0b8160a3de5a7bafe233e7cacfdc3f2744036d

parent: d413bbbb54

Unsigned

cmc <hello@cleberg.net> · 2026-10-26 19:53 UTC

Audit Inspect's recent searches, and fix what it found (!61)

The section renders only once a lookup has been run, so the empty-state suite
never had it in the tree. Its four findings were known only from driving one real
lookup by hand. `testSeededRecentSearches` covers it on purpose.

## It needs its own launch argument

Inspect renders either a result or the recent list, never both, so
`DOMAIN_DIG_SEED_FIXTURES` takes the branch and the section never appears. The
first attempt did exactly that and audited the batch screen instead — 35
findings, all already covered by `testSeededBatchResults`.

`DOMAIN_DIG_SEED_RECENT` seeds `recentSearches` alone. Assigning that property
does not persist: only `addRecentSearch` and `clearRecentSearches` write to
defaults, so it leaks no more than the other fixtures.

The test asserts "RECENT" is on screen before auditing. Without it the test
passes while measuring the wrong thing, which is how the first attempt looked
green until the finding list was read.

## Two of the eight findings were real

- **`hitRegion` on "Clear".** A `Button("Clear")` with a `.caption2` font and no
  padding is about 16pt tall, well under the WCAG 2.5.8 floor. Given
  `minWidth`/`minHeight` of `AppLayout.minimumTapTarget` and a `contentShape`.
- **`sufficientElementDescription` on each domain chip.** The label was the bare
  domain, which reads as neither a word nor an action. Given
  `accessibilityLabel("Look up <domain>")`; "Clear" likewise got "Clear recent
  searches".

Eight became three: two characterised noise entries and `dynamicType` on the
"RECENT" header, identical on both runtimes. `dynamicType` on "Clear" cleared as
a side effect of the 44pt frame, which fits those findings tracking geometry
rather than the element.

## Enforcement

The section gates on everything the project enforces except `.dynamicType`
(`enforcedAuditTypes.subtracting(.dynamicType)`). It is the only seeded screen
that gates at all.

Layout checked by capture: the header row reads normally with the taller Clear
target.

## Also

Closes the search for the store-pollution source, per the decision to archive
it. The remaining plan was to instrument a full-suite run and bisect which test
precedes contamination; the reset from `!51` makes the question unobservable
from the suite's results, so the answer would change nothing. Recorded in
`Docs/ACCESSIBILITY.txt` as closed rather than forgotten.

Verified: `./Scripts/audit-a11y.sh` passes on both tiers with no enforced
failures. 377/377 unit tests. Ratchet unchanged at 280.

Ref #21

Layout: unified · split

Docs/ACCESSIBILITY.txt +47 −15
@@ -435,20 +435,45 @@ naming the screen something other than what the Settings row that opens it
435says. Left as reported. It is the one `textClipped` finding still open on 435says. Left as reported. It is the one `textClipped` finding still open on
436History & Network, and why that screen stays report-only. 436History & Network, and why that screen stays report-only.
437 437
438## Recent searches are never audited 438## Recent searches
439 439
440The empty-state suite launches a fresh install, so Inspect's recent-searches 440Inspect's recent-searches section appears only once a lookup has been run, so
441section — which only appears once a lookup has been run — is never in the tree 441the empty-state suite never had it in the tree. Four findings in it were found
442when the audit walks it. Driving one real lookup and re-auditing surfaced four 442by accident, by driving one real lookup; `testSeededRecentSearches` now covers
443findings in it on iOS 27.0: 443it on purpose.
444 444
445- `dynamicType` on the "RECENT" header and on the "Clear" button 445**It needs its own launch argument.** `DOMAIN_DIG_SEED_FIXTURES` cannot be used:
446- `hitRegion` too small on "Clear" 446Inspect renders either a result or the recent list, never both, so seeding the
447- `sufficientElementDescription`, "label not human-readable", on a domain chip 447batch results takes the branch and the section never appears. The first attempt
448 448did exactly that and audited the batch screen instead — 35 findings, all of them
449These are latent rather than new: nothing in the section changed when Inspect 449already covered by `testSeededBatchResults`. `DOMAIN_DIG_SEED_RECENT` seeds
450moved to a `List`. They need a seeded recent-searches fixture to be audited 450`recentSearches` alone. Assigning that property does not persist (only
451properly, which the seed harness does not have. 451`addRecentSearch` and `clearRecentSearches` write to defaults), so it leaks no
452more than the other fixtures.
453
454The test asserts "RECENT" is on screen before auditing. Without that it passes
455while measuring the wrong thing, which is how the first attempt looked green
456until the finding list was read.
457
458Under audit, the section reported eight findings. Two kinds were real:
459
460- **`hitRegion` on "Clear".** A `Button("Clear")` with a `.caption2` font and no
461 padding is about 16pt tall, well under the WCAG 2.5.8 floor. Given
462 `minWidth`/`minHeight` of `AppLayout.minimumTapTarget` and a
463 `contentShape(Rectangle())`.
464- **`sufficientElementDescription` on each domain chip.** The button's label was
465 the bare domain, which reads as neither a word nor an action. Given
466 `accessibilityLabel("Look up <domain>")`; "Clear" likewise got "Clear recent
467 searches".
468
469Eight findings became three: two characterised noise entries, and `dynamicType`
470on the "RECENT" header. `dynamicType` on "Clear" cleared as a side effect of the
47144pt frame, which is consistent with those findings tracking geometry rather
472than the element.
473
474So the section gates on everything the project enforces except `.dynamicType` —
475`enforcedAuditTypes.subtracting(.dynamicType)`. It is the only seeded screen
476that gates at all.
452 477
453## The empty-state screens are cleared before each launch 478## The empty-state screens are cleared before each launch
454 479
@@ -468,7 +493,14 @@ the live view model and `auditFixturesActive` blocks persistence precisely so
468they cannot leak, and running the whole audit class against a cleared store 493they cannot leak, and running the whole audit class against a cleared store
469reproduces neither the failure nor the extra findings. Ruled out as well: the 494reproduces neither the failure nor the extra findings. Ruled out as well: the
470unit target, which leaves `trackedDomains` as an empty array in the app's own 495unit target, which leaves `trackedDomains` as an empty array in the app's own
471defaults. The source of the rows was never isolated. 496defaults.
497
498**The source of the rows was never isolated, and the search is closed.** The
499remaining plan was to instrument a full-suite run, dump `trackedDomains` at each
500launch and bisect which test precedes contamination. That is not being done: the
501reset below makes the question unobservable from the suite's results, so the
502answer would change nothing. Reopen it only if a finding shows up that the reset
503does not explain.
472 504
473What fixed it is making the question moot. `AuditFixtures.resetStoreIfRequested` 505What fixed it is making the question moot. `AuditFixtures.resetStoreIfRequested`
474clears the app's defaults domain and the history files when 506clears the app's defaults domain and the history files when
DomainDig/AuditFixtures.swift +20
@@ -58,6 +58,26 @@ enum AuditFixtures {
58 /// layout and traits, not string equality, so coverage wins. 58 /// layout and traits, not string equality, so coverage wins.
59 private static let now = Date() 59 private static let now = Date()
60 60
61 /// Inspect's recent-searches section renders only once a lookup has been
62 /// run, so a fresh-install audit never sees it. Assigning
63 /// `recentSearches` does not persist — only `addRecentSearch` and
64 /// `clearRecentSearches` write to defaults — so these stay in memory like
65 /// the rest of the fixtures.
66 ///
67 /// Its own argument rather than part of `DOMAIN_DIG_SEED_FIXTURES`,
68 /// because Inspect shows either a result or the recent list, never both:
69 /// seeding the batch results takes the branch and the section never
70 /// renders.
71 static var recentSearches: [String] {
72 ["healthy.example", "expiring.example", "broken.example"]
73 }
74
75 static let recentSearchesArgument = "DOMAIN_DIG_SEED_RECENT"
76
77 static var recentSearchesRequested: Bool {
78 ProcessInfo.processInfo.arguments.contains(recentSearchesArgument)
79 }
80
61 static var trackedDomains: [TrackedDomain] { 81 static var trackedDomains: [TrackedDomain] {
62 [ 82 [
63 TrackedDomain( 83 TrackedDomain(
DomainDig/ContentView.swift +8
@@ -589,6 +589,11 @@ struct ContentView: View {
589 } 589 }
590 .font(appDensity.font(.caption2)) 590 .font(appDensity.font(.caption2))
591 .foregroundStyle(ThemeToken.textSecondary) 591 .foregroundStyle(ThemeToken.textSecondary)
592 // `.caption2` text alone is around 16pt tall, well under the
593 // WCAG 2.5.8 floor, which is what the audit reports here.
594 .frame(minWidth: AppLayout.minimumTapTarget, minHeight: AppLayout.minimumTapTarget)
595 .contentShape(Rectangle())
596 .accessibilityLabel("Clear recent searches")
592 } 597 }
593 598
594 ForEach(viewModel.recentSearches, id: \.self) { domain in 599 ForEach(viewModel.recentSearches, id: \.self) { domain in
@@ -606,6 +611,9 @@ struct ContentView: View {
606 .background(ThemeToken.surface) 611 .background(ThemeToken.surface)
607 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius)) 612 .clipShape(RoundedRectangle(cornerRadius: appDensity.metrics.cardCornerRadius))
608 } 613 }
614 // A bare domain reads as neither a word nor an action; the
615 // button re-runs the lookup, so say that.
616 .accessibilityLabel("Look up \(domain)")
609 } 617 }
610 } 618 }
611 .padding(.top, appDensity.metrics.cardSpacing) 619 .padding(.top, appDensity.metrics.cardSpacing)
DomainDig/DomainViewModel.swift +5
@@ -1793,6 +1793,11 @@ final class DomainViewModel {
1793 private(set) var auditFixturesActive = false 1793 private(set) var auditFixturesActive = false
1794 1794
1795 func seedAuditFixturesIfRequested() { 1795 func seedAuditFixturesIfRequested() {
1796 // Independent of the fixtures below: Inspect renders either a result or
1797 // the recent list, so the two cannot be seeded together.
1798 if AuditFixtures.recentSearchesRequested {
1799 recentSearches = AuditFixtures.recentSearches
1800 }
1796 guard AuditFixtures.requested, !auditFixturesActive else { return } 1801 guard AuditFixtures.requested, !auditFixturesActive else { return }
1797 auditFixturesActive = true 1802 auditFixturesActive = true
1798 trackedDomains = AuditFixtures.trackedDomains 1803 trackedDomains = AuditFixtures.trackedDomains
DomainDigUITests/AccessibilityAuditHarness.swift +13 −1
@@ -57,9 +57,18 @@ enum AccessibilityAuditHarness {
57 /// row treatment went unmeasured. 57 /// row treatment went unmeasured.
58 private static let seedFixturesArgument = "DOMAIN_DIG_SEED_FIXTURES" 58 private static let seedFixturesArgument = "DOMAIN_DIG_SEED_FIXTURES"
59 59
60 /// Matches `AuditFixtures.recentSearchesArgument`. Separate from the
61 /// fixtures above because Inspect shows either a result or the recent
62 /// list, never both.
63 private static let seedRecentSearchesArgument = "DOMAIN_DIG_SEED_RECENT"
64
60 /// Launches the app with feature gating lifted, optionally at a specific 65 /// Launches the app with feature gating lifted, optionally at a specific
61 /// content size category and with the audit fixtures seeded. 66 /// content size category and with the audit fixtures seeded.
62 static func launch(contentSizeCategory: String? = nil, seeded: Bool = false) -> XCUIApplication { 67 static func launch(
68 contentSizeCategory: String? = nil,
69 seeded: Bool = false,
70 recentSearches: Bool = false
71 ) -> XCUIApplication {
63 let app = XCUIApplication() 72 let app = XCUIApplication()
64 // Every launch starts from a cleared store, so a screen the enforced 73 // Every launch starts from a cleared store, so a screen the enforced
65 // suite audits as empty is empty whatever ran before it. 74 // suite audits as empty is empty whatever ran before it.
@@ -67,6 +76,9 @@ enum AccessibilityAuditHarness {
67 if seeded { 76 if seeded {
68 app.launchArguments.append(seedFixturesArgument) 77 app.launchArguments.append(seedFixturesArgument)
69 } 78 }
79 if recentSearches {
80 app.launchArguments.append(seedRecentSearchesArgument)
81 }
70 if let contentSizeCategory { 82 if let contentSizeCategory {
71 app.launchArguments += ["-UIPreferredContentSizeCategoryName", contentSizeCategory] 83 app.launchArguments += ["-UIPreferredContentSizeCategoryName", contentSizeCategory]
72 } 84 }
DomainDigUITests/AccessibilityAuditTests.swift +27
@@ -274,6 +274,33 @@ final class AccessibilityAuditTests: XCTestCase {
274 /// One launch rather than ten: re-selecting the Settings tab pops it back 274 /// One launch rather than ten: re-selecting the Settings tab pops it back
275 /// to root, so each destination is reached from a known place, and the 275 /// to root, so each destination is reached from a known place, and the
276 /// store reset means the launch state is the same for all of them. 276 /// store reset means the launch state is the same for all of them.
277 /// Inspect with its recent-searches section present.
278 ///
279 /// The section renders only once a lookup has been run, so the empty-state
280 /// suite never has it in the tree. Four findings in it were found by
281 /// accident, by driving one real lookup; seeding `recentSearches` puts them
282 /// under the suite on purpose and keeps the launch deterministic.
283 ///
284 /// Gated on everything the project enforces except `.dynamicType`, which
285 /// still reports against the "RECENT" header. That one is the
286 /// position-dependent finding described in `Docs/ACCESSIBILITY.txt`, not a
287 /// property of the header — unlike the other seeded tests, nothing else
288 /// here needs to stay report-only.
289 func testSeededRecentSearches() throws {
290 let app = AccessibilityAuditHarness.launch(recentSearches: true)
291 app.selectRootTab("Inspect")
292 XCTAssertTrue(
293 app.staticTexts["RECENT"].waitForExistence(timeout: 10),
294 "The recent-searches section must render, or this audits nothing"
295 )
296 try AccessibilityAuditHarness.audit(
297 app,
298 screen: "recent-searches",
299 test: self,
300 enforcing: AccessibilityAuditHarness.enforcedAuditTypes.subtracting(.dynamicType)
301 )
302 }
303
277 func testSettingsDestinations() throws { 304 func testSettingsDestinations() throws {
278 let destinations = [ 305 let destinations = [
279 "Display", 306 "Display",