summaryrefslogtreecommitdiff
path: root/DomainDigUITests/AccessibilityAuditTests.swift
blob: 63b3d02122d5a2d7f44d5c9125e86d06b9787686 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import XCTest

/// One accessibility audit per primary screen, plus a Dynamic Type sweep.
///
/// See `AccessibilityAuditHarness` for why these report rather than fail by
/// default, and how to make them enforcing.
@MainActor
final class AccessibilityAuditTests: XCTestCase {
    override func setUp() {
        // Keep going after a failure so an enforced audit still collects and
        // attaches every finding. With this off, XCTest aborts at the first
        // reported issue and the burndown list is lost precisely when a category
        // is being enforced.
        continueAfterFailure = true
    }

    // MARK: Per-screen audits

    func testInspectScreen() throws {
        let app = AccessibilityAuditHarness.launch()
        app.selectRootTab("Inspect")
        try AccessibilityAuditHarness.audit(app, screen: "inspect", test: self)
    }

    func testDashboardScreen() throws {
        let app = AccessibilityAuditHarness.launch()
        app.selectRootTab("Dashboard")
        try AccessibilityAuditHarness.audit(app, screen: "dashboard", test: self)
    }

    func testAuditScreen() throws {
        let app = AccessibilityAuditHarness.launch()
        app.selectRootTab("Audit")
        try AccessibilityAuditHarness.audit(app, screen: "audit", test: self)
    }

    func testHistoryScreen() throws {
        let app = AccessibilityAuditHarness.launch()
        app.selectRootTab("History")
        try AccessibilityAuditHarness.audit(app, screen: "history", test: self)
    }

    func testSettingsScreen() throws {
        let app = AccessibilityAuditHarness.launch()
        app.selectRootTab("Settings")
        try AccessibilityAuditHarness.audit(app, screen: "settings", test: self)
    }

    func testTrackedDomainsScreen() throws {
        let app = AccessibilityAuditHarness.launch()
        app.selectRootTab("Settings")

        let trackedDomains = app.buttons["Tracked Domains"]
        XCTAssertTrue(
            trackedDomains.waitForExistence(timeout: 5),
            "Settings no longer offers a Tracked Domains row"
        )
        trackedDomains.tap()

        try AccessibilityAuditHarness.audit(app, screen: "tracked-domains", test: self)
    }

    // MARK: Dynamic Type

    /// Re-audits every root screen at the largest accessibility content size.
    ///
    /// This is where clipped text and fixed-height containers surface — the
    /// `.accessibility5`-class failures that the fixed geometry in
    /// `AppDensityMetrics` is expected to produce until phase 3 of #21 lands.
    func testAllScreensAtLargestAccessibilitySize() throws {
        let app = AccessibilityAuditHarness.launch(
            contentSizeCategory: "UICTContentSizeCategoryAccessibilityXXXL"
        )

        for tab in ["Inspect", "Dashboard", "Audit", "History", "Settings"] {
            app.selectRootTab(tab)
            try AccessibilityAuditHarness.audit(
                app,
                screen: "\(tab.lowercased())-accessibilityXXXL",
                test: self
            )
        }
    }
}