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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
//! What a check is, and what its verdict means.
//!
//! # Why this exists
//!
//! A DOM-only test environment answers questions about a tree the user never
//! sees. It has no compositor, no hit-testing and no layout, so it reports a
//! node as fine while the screen shows nothing. A green suite over jsdom says
//! the code is self-consistent, not that the interface works.
//!
//! Two failure classes make the point, and both have shipped past a green unit
//! suite in a real application:
//!
//! - **Artwork that lays out and does not draw.** The semantic tree reports a
//! node whether or not a pixel was painted, and a node can have a correct box
//! and a correct stroke colour while drawing nothing at all. A renderer that
//! parses each inline `<svg>` from that element's markup alone will resolve a
//! reference into a shared sprite to nothing. jsdom cannot see this: its
//! `<svg>` is a well-behaved object that never goes near a rasteriser.
//! - **Controls that only exist while hovered.** A test that never moves a
//! pointer cannot see them at all.
//!
//! # What a check is
//!
//! A [`Check`] is a precondition, an action, and an assertion about the state
//! after it, all expressed against the running application. Every part is
//! observed rather than assumed, and [`Paints`](Expect::Paints) fails if the
//! element is in the tree with no box - which is the thing the semantic tree
//! alone will not tell you.
//!
//! Checks are data, and they belong to the application under test rather than
//! to this crate. See [`checks`] for where they are read from.
//!
//! ```sh
//! ps-qa qa # every check
//! ps-qa qa icons # one group
//! ```
use blitz_control_protocol::SemanticNode;
use std::collections::HashMap;
use crate::target::selector_matches_node;
/// A control to hover, and how many times to enter it.
///
/// `Some("Trigger")` and `Some(("Trigger", 5))` both parse, so a check that
/// only needs one entry says so in the shortest way and nothing already written
/// has to change.
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum Hover {
/// Enter once.
Once(String),
/// Enter this many times, leaving between each.
Times(String, u8),
}
impl Hover {
/// The control to enter.
pub fn target(&self) -> &str {
match self {
Hover::Once(name) | Hover::Times(name, _) => name,
}
}
/// How many entries, never fewer than one.
pub fn times(&self) -> u8 {
match self {
Hover::Once(_) => 1,
Hover::Times(_, times) => (*times).max(1),
}
}
}
/// What a single check asserts once its action has run.
///
/// The full vocabulary is kept whether or not a check currently uses every
/// variant. These are the choices available when writing one, documented with
/// the failure each is right for, and a variant deleted for being momentarily
/// unused is a distinction the next person has to rediscover. `Grows` went
/// unconstructed the moment one check was strengthened to `PaintsMore`; it is
/// still the correct assertion for anything that mounts without painting.
#[allow(dead_code)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum Expect {
/// No uncaptured or validation WebGPU error has occurred since page load.
///
/// The subject is ignored; use "gpu". Inspection drains recent messages,
/// but this assertion reads cumulative totals, so another inspector cannot
/// consume evidence and make an erroneous page pass.
GpuNoErrors,
/// A live WebGPU object has the specified kind and a matching JS label.
///
/// Subject: "kind:label", for example "render-pipeline:bloom".
/// `*` in the label matches any run of characters, including an empty run,
/// anywhere in the label. "render-pipeline:renderPipeline_bloom*" and
/// "texture:*-light-map" match. A label with no `*` matches exactly, and
/// the kind is always exact. `*` is not a literal.
/// This checks the native registry, including subsequent label changes.
GpuHasResource,
/// The newest submitted WebGPU frame contains at least this many draws
/// into the named target.
///
/// Subject: a texture label or "canvas:#id". A texture label uses the same
/// `*` matching as [`GpuHasResource`](Expect::GpuHasResource). A canvas
/// target ("canvas:#id" or "canvas:@handle") stays exact. Direct, indexed
/// and indirect draw calls all count. Multiple passes into the target are
/// summed.
/// An incomplete sample fails and is polled again within the outcome
/// budget, because counts from before the inspection lease prove nothing
/// about a newer unsampled submission.
GpuDraws(u64),
/// The named WebGPU texture or canvas drawing buffer contains visible ink.
///
/// Subject: `texture:<label>` or `canvas:#id`. The host copies that target
/// to RGBA8, the same image a document Capture returns. Visible ink is the
/// same contrast test `ps-qa capture` prints: a pixel counts when its
/// luminance differs from the modal background by more than 24 and its
/// alpha is at least 32. A blank readback fails.
GpuTextureInk,
/// The named node exists, is visible, and has a non-zero box.
///
/// Non-zero is the part that matters. A node with a box of `0x0` is in the
/// tree and on no screen, which is how a broken control passes a test that
/// only asked whether it existed.
Paints,
/// The named node exists in the tree and was laid out, whatever its box
/// measures.
///
/// For subjects whose observable is *text*. A heading that reports an
/// outcome — `Press saw true, left false` — is exactly as wide as its line
/// and exactly as tall as its shaped glyphs, so on a host with no font
/// registered it lays out at `1328x0` and every box-based assertion about
/// it fails while the engine did nothing wrong.
///
/// That is not a hypothetical. All six of ps-blitz's activation fixtures
/// asserted their outcomes with [`PaintsNamed`](Expect::PaintsNamed) over
/// heading text, and all six failed the moment the host of the day stopped
/// enabling `system-fonts`. They had only ever passed because that host
/// carried a font catalogue, which is the thing a headless check must not
/// need.
///
/// So this asks the question those checks actually mean: did the node the
/// document was supposed to produce appear, with the name it was supposed
/// to have. It is still falsifiable, and in the two ways that matter:
/// naming a heading the document never creates fails on the tree, and a
/// node that is created but never laid out fails on the bounds. What it
/// deliberately does not assert is that glyphs reached the scene, because
/// that is a question about fonts rather than about the engine.
///
/// Use [`Paints`](Expect::Paints) or [`PaintsNamed`](Expect::PaintsNamed)
/// for anything with a box of its own — a control, a panel, an icon. Those
/// are stronger and they cost nothing on a fontless host.
Present,
/// A painted named node is enabled after the action.
///
/// Use this for validation flows where entering a valid value unlocks a
/// Save or Send control without changing its geometry.
///
/// A control whose box comes from its own label has no box on a host with
/// no fonts, and this refuses it however right the flag is. Declare
/// [`text_sized`](Check::text_sized) on such a subject to judge the flag
/// alone.
Enabled,
/// A painted named node refuses input after the action.
///
/// This is the observable completion state for actions such as clearing a
/// saved value: the control remains visible, but cannot be invoked again
/// until there is something new to act on.
///
/// Takes [`text_sized`](Check::text_sized) on the same terms as
/// [`Enabled`](Expect::Enabled).
Disabled,
/// No node matching the name exists.
///
/// The assertion for a control that must *not* be reachable, and for
/// checking that a destructive action did not fire.
Absent,
/// The node may remain in the tree, but nothing matching it is on screen.
///
/// The inverse of [`Paints`](Expect::Paints), and the right question for
/// anything that closes. A dismissed dialog is not removed: measured after
/// a dialog's Cancel, the dialog's own content is still in the tree at
/// `0x0 HIDDEN`. Asking for absence there reports a working control as
/// broken, while asking for a box distinguishes dismissed from trapped -
/// full size while open, nothing once closed.
Vanishes,
/// The count of matching nodes changed in the given direction.
Grows,
/// More matching nodes are *on screen* than before.
///
/// [`Grows`](Expect::Grows) counts tree membership, which is the wrong
/// question for a control that reveals something already mounted. The
/// rename editor is built for the life of its component and merely hidden,
/// so the node count does not move when it opens - only its box does.
///
/// Counting painted nodes is also what makes the check falsifiable. A
/// `Paints` assertion on `textbox` stays green while the pencil is dead,
/// because the composer and the search field are textboxes that always
/// paint; verified by reintroducing the bug and watching it pass.
PaintsMore,
/// A repeated rendered family's members change while its viewport size may stay fixed.
///
/// Virtualized pagination replaces the five painted rows with the next
/// five rather than mounting ten. Count assertions therefore reject a
/// working pager. This compares the matching semantic identities and names
/// so replacing or recycling rows both prove that the page advanced.
FamilyChanges,
/// The count of matching nodes did not change.
Holds,
/// The count of matching nodes equals [`Check::expect_count`].
Count,
/// A node matching *both* a name and a role paints.
///
/// The precise form of [`Paints`](Expect::Paints), for the common case
/// where a control and the thing it opens share an accessible name.
/// An in-place rename control does exactly that: `Rename <subject>`
/// resolves to a button that always paints *and* a textbox that paints only
/// while editing, so a name-only `Paints` is satisfied by the pencil
/// whether or not the editor ever opens.
///
/// A count-based assertion is not the answer either. `PaintsMore` over
/// every `textbox` in the tree is fragile to whatever else happens to be
/// on screen - a composer, a search field, an editor left open by an
/// earlier check - and reported `2 -> 2` on a run where the editor
/// demonstrably opened. Asking about one node by name and role is the
/// question the check actually means.
///
/// Written as `role:name`, e.g. `textbox:Rename thing`.
///
/// Judged on geometry, not on the tree's `visible` flag, because the two
/// disagree. Measured on one node at one instant: `paint` reported the
/// rename editor `300.0x21.1 at 87,236 fg=#b0b5b9ff opacity=1.00 Visible`
/// while `dom` reported the same id `HIDDEN`. `paint` reads what the
/// render pass resolved; `visible` walks ancestors looking for
/// `display:none` and `aria-hidden`, and a wrapper whose class no longer
/// says `hidden` was still carrying it in the style tree while its subtree
/// laid out and drew.
///
/// So a check that trusts `visible` calls a control a person can see and
/// type into dead. Geometry plus a position is the honest question here.
PaintsNamed,
/// Every painted node in the matching family occupies its own position.
///
/// A repeated family can expose correct state and non-zero boxes while
/// every member is stacked on the same coordinates. This is the rendered
/// contract for layouts such as a colour flower.
DistinctPositions,
/// Every painted node in the matching family stays inside one comparison box.
///
/// Distinct positions alone do not prove a composition is intact: every
/// petal in a colour flower can occupy a different coordinate while the
/// whole family is detached from its wheel. `compare` names the semantic
/// container whose rendered bounds own the family.
ContainedBy,
/// The exact accessible name selected for this check's click still paints.
///
/// Use this for a row action whose label includes the row identity. It
/// proves that exact row survived without comparing a broad family count
/// that hover-revealed neighbours can legitimately change.
TargetPaints,
/// The subject's box is the size it is supposed to be.
///
/// Every other assertion here is satisfied by *any* non-zero box, which is
/// how a control with a correct role, a correct name and correct text
/// passes while rendering as a sliver. A pill that should stand 24px tall
/// and comes out at 8 has lost its padding or its line-height; a menu that
/// should be at least 190px wide and comes out at 40 has lost its
/// min-width. Both are the styling artefacts that make a component look
/// broken while the semantic tree reports it as fine.
///
/// Written as `WxH` in `expect_size`, either side optional and each a
/// minimum unless prefixed: `24` is at least 24, `=24` is exactly 24,
/// `<=24` is at most. Tolerance is a pixel, because layout rounds.
Measures,
/// The named subject paints above the named comparison control.
///
/// This is a rendered-order assertion, not DOM order. It verifies list
/// placement using the boxes a person actually sees.
Above,
/// The named subject paints entirely to the right of the comparison box.
///
/// This guards desktop compositions whose controls must sit beside a
/// primary visual rather than falling into the narrow/mobile stack.
RightOf,
/// The subject and comparison boxes share the same vertical center.
///
/// `RightOf` catches a desktop composition collapsing into a stack, but it
/// still passes when the primary visual is pinned to the top of a much
/// taller controls column. This assertion guards the authored balance of
/// the two side-by-side regions.
CenterAlignedY,
/// The rendered pixels stay identical across the declared pointer abuse.
///
/// This is deliberately a frame assertion rather than a DOM-count
/// assertion. A duplicated fixed child still exists once in the DOM and
/// has one layout box, but semi-transparent shadows darken on every
/// incremental resolve. The live runner captures before and after
/// [`after_prepare_hover`](Check::after_prepare_hover), with the pointer
/// returned to the same non-hover state.
PixelsHold,
/// The first stable neutral frame equals the neutral frame after one hover.
///
/// This catches controls whose initial display list is malformed until a
/// pointer invalidation repairs it. The semantic tree and layout boxes can
/// be correct in both frames, so a geometry-only assertion stays green.
PixelsHoldAfterHover,
/// Hovering the declared control visibly changes the captured region.
///
/// This guards authored hover feedback through rendered pixels. Semantic
/// inspection cannot see a `data-focused` style change, and merely proving
/// the pointer event was dispatched does not prove the person received
/// any feedback from it.
PixelsChange,
/// The captured region contains pixels visibly distinct from its backdrop.
///
/// Geometry and resolved stroke properties both stay valid when an SVG
/// references a missing sprite symbol. Raster ink is the observable that
/// distinguishes a real icon from an empty box.
VisibleInk,
/// The captured control contains visible pixels away from its border.
///
/// Use this for closed selectors and labeled fields: their border makes a
/// whole-region ink check pass even when the value a person needs to read
/// is blank. The center inset excludes that chrome and proves content.
InteriorInk,
/// The subject's resolved background colour is fully opaque.
///
/// A translucent child over an animated gradient cannot have a flat fill,
/// regardless of stacking contexts: the parent's pixels necessarily show
/// through. The live runner reads the colour Blitz hands to paint and
/// requires an alpha channel of `ff`.
OpaqueBackground,
/// The subject's resolved background colour has zero alpha.
///
/// This is stricter than merely being translucent: an opacity slider at its
/// floor must admit the native backdrop completely, not leave a pale film.
TransparentBackground,
/// The subject paints at opacity 1 rather than fading all of its content.
///
/// Use this when a disabled control may mute its background but must keep
/// an icon or label crisp. Applying opacity to the whole control also
/// fades the content and is the regression this distinguishes.
FullOpacity,
/// The platform window is transparent and its installed glass tint has
/// zero alpha.
///
/// Renderer paint cannot answer this: AppKit composites the window and its
/// glass view outside the document. This expectation reads the runtime's
/// applied native composition and rejects a merely transparent CSS root
/// sitting over an accent-coloured native sheet.
TransparentWindowTint,
/// Every named painted node matching the subject meets its contrast floor.
///
/// Text and labeled controls use 4.5:1. Graphical form chrome and
/// icon-only actions use 3:1, sampled from the paint property that actually
/// identifies them (foreground, border, or fill).
Contrast,
/// The subject's resolved font size increases after the action.
///
/// This verifies interface scaling against the computed style Blitz hands
/// to layout. Enlarging one control box is not enough: fixed-size text can
/// remain unreadably small inside it while a geometry-only check passes.
FontSizeGrows,
/// The exact semantic node's exposed value changed after the action.
///
/// This is the outcome for sliders, switches, and other value-bearing
/// controls whose geometry does not change when they work. The node id is
/// carried from the before snapshot so a repeated accessible name cannot
/// satisfy the assertion with a neighbouring row.
ValueChanges,
/// The subject node's semantic value equals [`Check::expect_value`].
///
/// Use this when a progressbar, meter or slider must expose one exact
/// value rather than merely a different one. That value is `aria-valuetext`
/// when the control has one, otherwise `aria-valuenow`, otherwise the
/// control's own value.
ValueIs,
/// The exact semantic node's selected/pressed state changed.
///
/// Radios and `aria-pressed` buttons expose selection as a boolean rather
/// than inventing a string value. This follows the activated node id, so a
/// neighbouring swatch cannot satisfy the verdict.
SelectionChanges,
/// Focus moved to the exact semantic node named by the subject.
FocusMoves,
/// The exact subject node's accessible name changed after the action.
///
/// Use this for status text that reports a completed refresh or re-check.
/// Following the node id prevents an unrelated new status row from
/// satisfying the outcome.
NameChanges,
}
/// A pointer gesture starting at a named control's painted center.
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
#[serde(deny_unknown_fields)]
pub struct PointerDrag {
pub from: String,
/// Optional painted destination; its center determines the drag offset.
/// This lets a QA page expose data-derived coordinates without copying them
/// into a static check manifest.
#[serde(default)]
pub to: Option<String>,
#[serde(default)]
pub dx: f64,
#[serde(default)]
pub dy: f64,
pub steps: u32,
#[serde(default)]
pub cancel: bool,
}
/// Which runtime credential a check may enter before the measured action.
///
/// The value is supplied by a `run-plan` session and is never part of the RON
/// check file or its report.
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum SecretInput {
Username,
Password,
}
/// One explicit rendered state accepted by an `any_of` check.
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
#[serde(deny_unknown_fields)]
pub struct OutcomeAlternative {
pub subject: String,
pub expect: Expect,
}
/// One phase of the timed keyboard sequence on [`Check`].
///
/// Hold and Wait take milliseconds. Every other variant names a key or a
/// chord, parsed the same way as [`Check::key`].
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum KeyStep {
/// Key down, then key up.
Press(String),
/// Key down, wait this many milliseconds, then key up.
Hold(String, u64),
/// Key down, leaving the key held for a later [`Up`](Self::Up).
Down(String),
/// Key up. Releases a key an earlier [`Down`](Self::Down) held.
Up(String),
/// Sleep this many milliseconds. Sends no key.
Wait(u64),
}
/// One thing that must be true of the running panel.
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Check {
/// Stable name for this one check, so a failure can be re-run alone.
///
/// The group is too coarse for that: chasing one fix meant re-running its
/// neighbours every time, and each run drives the real app. `what` is prose
/// and changes when the wording improves, so it cannot be the handle.
/// This is the handle - `ps-qa qa rename-opens-editor`.
pub id: String,
/// Group, so a failing area can be re-run alone.
pub group: String,
/// What this proves, in the words you would use to report it.
pub what: String,
/// Load a URL in the standing document before opening a surface.
///
/// Relative URLs resolve against the document that is up. Use this when a
/// route must load as a fresh document, such as reloading a signed-in
/// account page that client-side navigation cannot reach.
#[serde(default)]
pub navigate: Option<String>,
/// Painted marker that must arrive after [`navigate`](Self::navigate).
///
/// Arrival currently falls through to [`subject`](Self::subject) when no
/// opener is declared. A negative `Absent` subject is then treated as the
/// thing that must paint, so a correct destination cannot complete setup.
/// Set this to a positive marker the destination actually paints. The
/// assertion is unchanged and still runs after that arrival.
#[serde(default)]
pub arrival_subject: Option<String>,
/// Activate this after [`navigate`](Self::navigate), when set, to reach the
/// surface the check is about.
///
/// Checks run in sequence against one instance and start wherever the app
/// opens, so anything not on that first surface is unreachable without a
/// navigation step. A control that lives on only one surface fails with
/// "no visible, enabled, sized button" when the check never got there,
/// which reads as a missing control rather than a missing navigation.
pub open: Option<String>,
/// Activate this semantic control after navigation and before measuring
/// the action baseline.
///
/// This gives a check an explicit state precondition without making it
/// depend on a preceding check. For example, select one tab here, then
/// activate another and require its selected state to change.
#[serde(default)]
pub prepare: Option<String>,
/// Skip [`prepare`](Self::prepare) when this rendered target already paints.
///
/// Component sweeps intentionally reuse one native host per component for
/// speed. An earlier outcome may therefore leave a menu open. Activating
/// its trigger again would close the menu and turn shared-host execution
/// into a false failure, while omitting preparation would make the same
/// check impossible to run by id against a fresh host. This selector makes
/// the precondition idempotent in both cases.
#[serde(default)]
pub prepare_unless: Option<String>,
/// Use a real pointer press for [`prepare`](Self::prepare).
///
/// Focus-sensitive popovers can legitimately distinguish a human press
/// from a bare semantic activation. Keep this separate from `press`, since
/// the prepared trigger and measured action may have different roles.
#[serde(default)]
pub prepare_press: bool,
/// Send this key to [`prepare`](Self::prepare) instead of activating it.
///
/// This keeps focus-sensitive controls self-contained: a select check can
/// open its listbox with the component's authored keyboard contract, then
/// measure an option selection without depending on an earlier check.
#[serde(default)]
pub prepare_key: Option<String>,
/// Deliberate interval between [`prepare`](Self::prepare) and the measured action.
///
/// This is for contracts whose subject is an interaction during a known
/// intermediate state, such as choosing another carousel page while its
/// first transition is active. It is not an outcome timeout and is not a
/// substitute for waiting on a rendered precondition.
#[serde(default)]
pub prepare_wait_ms: u64,
/// Rendered target that must arrive after [`prepare`](Self::prepare).
///
/// Use this when the preparation starts a state change and the measured
/// action must be timed from that state, rather than from delivery of its
/// input event.
#[serde(default)]
pub prepare_until: Option<String>,
/// Hover this node first, if the control is revealed on hover.
///
/// Either a name, or a name and a count: `hover: Some("Trigger")` enters
/// once, `hover: Some(("Trigger", 5))` enters five times, leaving between
/// each.
///
/// The count is how a check reaches the defects a single hover cannot see.
/// A pill whose hover appends a shadow layer and never removes it looks
/// correct the first time and accumulates from the second, so it is
/// invisible both to a check that hovers once and to anyone who does not
/// happen to hover twice by hand. Leaving between entries is the part that
/// matters: hovering the same node twice with no departure is one hover as
/// far as the renderer is concerned, and the defect lives in the
/// enter/leave pair.
///
/// When the count is greater than one, the harness compares the tree after
/// the first completed entry with the tree after the last. Comparing equal
/// hover states separates retained nodes from a legitimate hover affordance,
/// and a single entry does not mistake unrelated asynchronous rendering for
/// accumulation.
pub hover: Option<Hover>,
/// Skip [`hover`](Self::hover) when this rendered target already paints.
///
/// A preceding check may intentionally leave the dialog or row action that
/// hover would reveal open. Re-hovering the covered row is impossible and
/// unnecessary; an isolated rerun still performs the hover when the target
/// is absent.
#[serde(default)]
pub hover_unless: Option<String>,
/// Repeatedly hover this node after [`prepare`](Self::prepare).
///
/// Menus do not expose their items until their trigger has opened them, so
/// the ordinary pre-prepare hover cannot exercise pointer-driven retained
/// painting inside an overlay. This action exists for that ordering and
/// leaves between entries exactly like [`hover`](Self::hover).
#[serde(default)]
pub after_prepare_hover: Option<Hover>,
/// Scroll this semantic region into view before a rendered baseline.
///
/// Deferred application sections commonly expose a header before their
/// body. Revealing that header is an observation/precondition, not a fake
/// click, and it lets the app mount the subject before its first hover.
#[serde(default)]
pub reveal_before_capture: Option<String>,
/// Focus this field and enter [`setup_text`](Self::setup_text) after
/// navigation, before preparation and the measured action.
///
/// This makes multi-step checks independent of state left by earlier
/// checks. A filtered list can establish its query here, then click a row
/// action and measure the editor outcome with `type_into`/`key`.
#[serde(default)]
pub setup_type_into: Option<String>,
/// Literal value entered into [`setup_type_into`](Self::setup_type_into).
#[serde(default)]
pub setup_text: Option<String>,
/// RunPlan binding that supplies nonsecret text for this setup input.
///
/// The binding is resolved in memory from a declared Assertion environment
/// value before the check runs; the environment variable name stays in the
/// RON plan and the supplied value stays out of it.
#[serde(default)]
pub setup_text_env: Option<String>,
/// Session credential entered into [`setup_type_into`](Self::setup_type_into).
///
/// Only the typed reference is read from RON. The value is resolved from
/// the active run-plan session and errors redact it.
#[serde(default)]
pub setup_secret: Option<SecretInput>,
/// Click this node, if the check is about an action.
pub click: Option<String>,
/// Focus this named text field and enter [`text`](Self::text).
pub type_into: Option<String>,
/// Literal text to enter after the click step.
pub text: Option<String>,
/// A final named key or chord such as Enter, Escape, or Meta+2, sent to
/// `type_into`.
pub key: Option<String>,
/// Focus this named semantic control before sending `key`.
///
/// Unlike `type_into`, this accepts any value-bearing role, including a
/// slider. Name resolution produces a node id before the action is sent.
pub key_on: Option<String>,
/// Timed key sequence, sent after [`key`](Self::key) and before
/// [`scroll_over`](Self::scroll_over).
///
/// A single chord is [`key`](Self::key). This is for a page that reacts to
/// a key staying down, or to down and up as separate phases. Each step is
/// delivered to the focused element, or to the document when nothing is
/// focused. Empty means the check sends no sequence.
#[serde(default)]
pub keys: Vec<KeyStep>,
/// Move over this semantic node and send real wheel input after other actions.
#[serde(default)]
pub scroll_over: Option<String>,
/// Number of wheel events for [`scroll_over`](Self::scroll_over).
#[serde(default)]
pub scroll_ticks: usize,
/// Vertical pixels per wheel event. Negative scrolls down.
#[serde(default)]
pub scroll_delta: f64,
/// The second named node for a relative-position expectation.
pub compare: Option<String>,
/// Target size for [`Measures`](Expect::Measures), as `WxH`.
///
/// Either side may be empty to leave that axis unasserted: `x24` asserts
/// height alone, which is the common case for a control whose width is
/// content-driven.
#[serde(default)]
pub expect_size: Option<String>,
/// Exact family size for [`Expect::Count`].
#[serde(default)]
pub expect_count: Option<usize>,
/// Exact semantic value for [`Expect::ValueIs`].
///
/// `aria-valuetext` when the control has one, otherwise `aria-valuenow`,
/// otherwise the control's own value.
#[serde(default)]
pub expect_value: Option<String>,
/// Additional controls covered by this same rendered contract.
///
/// Use this only for a repeated family produced from one component and
/// one data array, such as every `Offer {model}` checkbox. The action and
/// verdict still address one exact semantic node; these selectors let the
/// inventory credit its identical siblings without pretending a substring
/// chosen for activation is itself an outcome.
#[serde(default)]
pub covers: Vec<String>,
/// Opt into generic coordinate-pointer activation instead of semantic
/// node activation. Application suites omit this unless they explicitly
/// intend to test hit-testing.
#[serde(default)]
pub press: bool,
/// Drag a control through real pointer input, optionally cancelling it.
#[serde(default)]
pub pointer_drag: Option<PointerDrag>,
/// Optional unmeasured quiet window after this verdict.
///
/// Use this only when an application paints optimistically and then begins
/// durable work that temporarily occupies its control transport. The
/// rendered action still has to pass the one-second budget.
#[serde(default)]
pub settle_after_ms: u64,
/// Deadline for this check's [`navigate`](Self::navigate) and
/// [`open`](Self::open) steps.
///
/// Navigation is not the interaction contract. `navigate` loads a document,
/// and `open` can activate a route that fetches before it paints. A live
/// network round trip can exceed the 900ms default, so the route can declare
/// its arrival budget without weakening every other check.
///
/// Use this only for a route known to fetch. Without it, the failure reads
/// as a missing control rather than as a deadline.
#[serde(default)]
pub open_timeout_ms: u64,
/// Deadline for this check's rendered outcome.
///
/// Ordinary interactions keep the 900ms contract. A declared backend or
/// network round trip may opt into a larger explicit budget without
/// weakening every button in the sweep.
#[serde(default)]
pub outcome_timeout_ms: u64,
/// Require the successful rendered outcome to remain present while the
/// complete live semantic snapshot stays unchanged for this long.
///
/// Navigation can expose a heading in its first partial frame and mount
/// the rest of the page afterward. A name-only outcome then measures tab
/// activation rather than a usable page. This window is part of outcome
/// latency: every later tree change restarts it, so staged content cannot
/// be reported as a fast completed render.
#[serde(default)]
pub stable_for_ms: u64,
/// Also require the semantic tree's visibility flag, not geometry alone.
///
/// [`Paints`](Expect::Paints), [`PaintsNamed`](Expect::PaintsNamed),
/// [`PaintsMore`](Expect::PaintsMore) and [`Count`](Expect::Count) judge on
/// boxes, for the reason written on the `paints` predicate: the flag and
/// the renderer disagree, and trusting the flag once reported a screen full
/// of icons as painting nothing.
///
/// That leaves a whole class of component unprovable in one direction. An
/// Accordion, a Collapsible, a Tabs panel and anything else that hides by
/// flipping `hidden` while keeping its box satisfies every geometry
/// assertion whether it is open or closed. [`Vanishes`](Expect::Vanishes)
/// reads the flag and so can prove such a thing closed; nothing could prove
/// it open, which caps what a suite can assert about disclosure on every
/// site that has one.
///
/// So this is opt-in and per check. A check that declares it is saying "for
/// this subject the flag is the honest signal", which is true exactly where
/// the box does not move. Leave it off for anything with a box of its own:
/// there the geometry question is stronger and it does not depend on a flag
/// that walks ancestors.
///
/// With `Count`, only members that are shown are counted, which is what
/// makes an exact count of open panels expressible at all.
#[serde(default)]
pub require_visible: bool,
/// The subject's box comes from its text, so judge its input state on the
/// flag and layout alone.
///
/// [`Enabled`](Expect::Enabled) and [`Disabled`](Expect::Disabled) ask two
/// questions at once: the tree says this control accepts input, *and* it has
/// a box a person could aim at. That second half is the same font question
/// [`Present`](Expect::Present) exists for, and it is unanswerable on the
/// host that matters most. CI runs without a font catalogue; text lays out
/// at zero there, so a control sized by its own label measures nothing.
/// Measured on a `w-full` primary call to action: `0x44`, `enabled=true`
/// in the very tree the check reads, and both verdicts refused it. Two
/// sites hit this within a day of each other, one rewriting two checks to
/// assert what the button *gates* instead of the button, the other
/// dropping to [`Present`](Expect::Present) and losing the state assertion
/// entirely.
///
/// So this is opt-in and per check, exactly like
/// [`require_visible`](Self::require_visible), and for the same reason: the
/// default meaning of an existing check must not change under it. A check
/// that declares this is saying "this subject is sized by its glyphs", and
/// gives up only the box, never the state. The node must still exist and
/// must still have been laid out, which is the floor
/// [`Present`](Expect::Present) already holds, so a control the document
/// never produced still fails.
///
/// It is rejected on any other expectation. For the geometry axis the
/// vocabulary already has an answer, and it is
/// [`Present`](Expect::Present).
#[serde(default)]
pub text_sized: bool,
/// Run this check only after every ordinary shared-instance outcome.
///
/// A destructive sequence may deliberately remove fixture state that
/// controls on another surface still need. Surface affinity cannot order
/// that safely: it groups by mount cost, so a project reset would otherwise
/// precede later Settings and Home checks. The runner keeps destructive
/// checks ordered, but moves their whole sequence to the final tail.
#[serde(default)]
pub destructive: bool,
/// `localStorage` entries installed before any page script runs.
///
/// Values are arbitrary strings, often several kilobytes of JSON under one
/// key. A `qa-hosted` run writes the map as a JSON object and restarts the
/// host with `QA_INSPECT_STORAGE` set to that file, so the page boots with
/// the entries already present. The next check with an empty map restarts
/// without the variable. Empty leaves the standing host alone.
#[serde(default)]
pub storage: std::collections::BTreeMap<String, String>,
/// The node the assertion is about.
pub subject: String,
/// RunPlan binding that supplies a nonsecret assertion subject.
///
/// The literal `subject` remains the fallback for ordinary QA commands;
/// RunPlan resolves this binding before checking the plan-selected suite.
#[serde(default)]
pub subject_env: Option<String>,
/// Runtime session credential used as the assertion subject.
///
/// This supports checks that verify a submitted password was not rendered
/// back into the page. The value is resolved only for an authenticated
/// RunPlan session and is redacted from the report.
#[serde(default)]
pub subject_secret: Option<SecretInput>,
pub expect: Expect,
/// Accept the primary outcome or any one of these explicit alternatives.
///
/// This is for state that is valid in more than one observable form, such
/// as an existing chat history or its documented empty state. It does not
/// combine actions or turn several independent checks into an OR.
#[serde(default)]
pub any_of: Vec<OutcomeAlternative>,
}
/// Every check, in the order they run, read from the application's own files.
///
/// # Why these are not compiled in
///
/// They used to be Rust, in a `tests/ps-qa/` module inside this crate, which was
/// wrong twice over. It put one product's promises - its control names, its
/// section labels, its fixture names - inside a general harness, so pointing
/// this binary at a second application meant editing the harness.
/// And it made changing a selector a recompile: correcting one hardcoded
/// fixture name after a profile rebuild touched 15 references across 6 files
/// and needed a build to try.
///
/// A check is data. It is a precondition, an action and an assertion, with no
/// behaviour of its own, so it belongs in a file the application owns and
/// anybody can edit between runs.
///
/// Read from `<dir>/*.ron`, where `<dir>` is `--checks <path>` or `tests/ps-qa/`
/// under the working directory. Files are read in name order and concatenated,
/// so the group order is the filename order.
pub fn default_checks_path() -> std::path::PathBuf {
std::path::PathBuf::from("tests/ps-qa")
}
pub fn checks(dir: Option<&std::path::Path>) -> Result<Vec<Check>, String> {
let path = dir
.map(std::path::Path::to_path_buf)
.unwrap_or_else(default_checks_path);
checks_from_paths(&[path])
}
/// Load one or more application-owned check files/directories as one outcome
/// manifest. Sorting and duplicate-ID validation span every supplied path.
pub fn checks_from_paths(paths: &[std::path::PathBuf]) -> Result<Vec<Check>, String> {
let mut files = Vec::new();
for dir in paths {
if !dir.is_dir() && !dir.is_file() {
return Err(format!(
"no checks at {}. Point --checks at the application's check file or directory.",
dir.display()
));
}
if dir.is_file() {
if !dir.extension().is_some_and(|ext| ext == "ron") {
return Err(format!(
"check file must have a .ron extension: {}",
dir.display()
));
}
files.push(dir.clone());
} else {
files.extend(
std::fs::read_dir(dir)
.map_err(|error| format!("could not read {}: {error}", dir.display()))?
.filter_map(Result::ok)
.map(|entry| entry.path())
.filter(|path| path.extension().is_some_and(|ext| ext == "ron"))
// The application profile is not a check group.
.filter(|path| path.file_name().is_some_and(|name| name != "ps-qa.ron")),
);
}
}
// File-name order, so combining directories behaves like one manifest and
// is not dependent on either filesystem enumeration or directory order.
files.sort_by(|left, right| {
left.file_name()
.cmp(&right.file_name())
.then_with(|| left.cmp(right))
});
let mut all = Vec::new();
let mut ids = HashMap::new();
// The last surface any file asked for, and which file asked. A check with
// no `open` runs on whatever the previous check left in front of it, which
// is a fine and deliberate way to write a sequence *inside* one file. See
// below for why it stops there.
let mut established: Option<(std::path::PathBuf, String)> = None;
for file in files {
let text = std::fs::read_to_string(&file)
.map_err(|error| format!("could not read {}: {error}", file.display()))?;
let group: Vec<Check> = ron::from_str(&text)
.map_err(|error| format!("could not parse {}: {error}", file.display()))?;
for (index, check) in group.iter().enumerate() {
validate_check(check, &file, &mut ids)?;
/*
* A file may not inherit another file's surface in silence.
*
* Files are separate documents, read in name order, and a reader of
* one has no reason to know which surface the file before it left
* open. A first check with no `open` therefore runs against a
* screen nobody in this file chose: one site's checks measured a
* page they had never navigated to and passed, which is the worst
* possible outcome for a check.
*
* Inside a file the same inheritance is how a sequence is written
* and is left alone.
*/
if index == 0
&& check.open.is_none()
&& check.navigate.is_none()
&& let Some((previous_file, opener)) = &established
{
return Err(format!(
concat!(
"{}: check {:?} is the first in its file and declares neither `navigate` nor ",
"`open`, so it would run on {:?}, which {} navigated to. Declare how this ",
"file establishes its starting surface."
),
file.display(),
check.id,
opener,
previous_file.display(),
));
}
if let Some(opener) = check.open.as_deref().or(check.navigate.as_deref()) {
established = Some((file.to_path_buf(), opener.to_owned()));
}
}
all.extend(group);
}
Ok(all)
}
fn validate_check(
check: &Check,
file: &std::path::Path,
ids: &mut HashMap<String, std::path::PathBuf>,
) -> Result<(), String> {
if let Some(previous) = ids.insert(check.id.clone(), file.to_path_buf()) {
return Err(format!(
"duplicate check id {:?} in {} (already declared in {})",
check.id,
file.display(),
previous.display()
));
}
if check.expect == Expect::Vanishes
&& check.prepare_key.is_some()
&& check.prepare_unless.as_deref() == Some(check.subject.as_str())
&& check.click.is_none()
&& check.key.is_none()
&& check.keys.is_empty()
&& check.type_into.is_none()
{
return Err(format!(
concat!(
"{}: check {:?} can pass without opening {:?}: prepare_key replaces prepare ",
"activation and is skipped when prepare_unless already paints; open with ",
"prepare, then send the dismiss key with key and key_on"
),
file.display(),
check.id,
check.subject
));
}
if check.prepare_wait_ms > 0 && check.prepare.is_none() {
return Err(format!(
"{}: check {:?} declares prepare_wait_ms without a prepare action",
file.display(),
check.id
));
}
if check.prepare_wait_ms > 0 && check.prepare_until.is_none() {
return Err(format!(
"{}: check {:?} declares prepare_wait_ms without a rendered prepare_until marker",
file.display(),
check.id
));
}
if check.prepare_until.is_some() && check.prepare.is_none() {
return Err(format!(
"{}: check {:?} declares prepare_until without a prepare action",
file.display(),
check.id
));
}
let setup_value_count = (if check.setup_text.is_some() { 1 } else { 0 })
+ (if check.setup_text_env.is_some() { 1 } else { 0 })
+ (if check.setup_secret.is_some() { 1 } else { 0 });
if (check.setup_type_into.is_some() && setup_value_count != 1)
|| (check.setup_type_into.is_none() && setup_value_count != 0)
{
let rule = if check.setup_secret.is_some() {
"must declare setup_type_into and exactly one of setup_text, setup_text_env, or setup_secret"
} else if check.setup_text_env.is_some() {
"must declare setup_type_into and setup_text_env together"
} else {
"must declare setup_type_into and setup_text together"
};
return Err(format!("{}: check {:?} {rule}", file.display(), check.id));
}
if !check.any_of.is_empty() {
let supported = |expect| {
matches!(
expect,
Expect::Present | Expect::Paints | Expect::PaintsNamed | Expect::Absent
)
};
if check.any_of.len() > 16
|| check.subject.trim().is_empty()
|| !supported(check.expect)
|| check.any_of.iter().any(|alternative| {
alternative.subject.trim().is_empty() || !supported(alternative.expect)
})
{
return Err(format!(
"{}: check {:?} has an invalid any_of outcome",
file.display(),
check.id
));
}
}
if check.subject_env.is_some() && check.subject_secret.is_some() {
return Err(format!(
"{}: check {:?} cannot bind its subject from both an assertion and a secret",
file.display(),
check.id
));
}
if check
.arrival_subject
.as_deref()
.is_some_and(|value| value.trim().is_empty())
{
return Err(format!(
"{}: check {:?} declares an empty arrival_subject",
file.display(),
check.id
));
}
if check.navigate.is_some() && check.expect == Expect::Absent {
let arrival = check
.arrival_subject
.as_deref()
.or(check.open.as_deref())
.or_else(|| check.hover.as_ref().map(Hover::target))
.or(check.prepare.as_deref())
.or(check.click.as_deref())
.or(check.type_into.as_deref())
.or(check.key_on.as_deref())
.unwrap_or(check.subject.as_str());
if arrival == check.subject.as_str() {
return Err(format!(
"{}: check {:?} navigates to an Absent subject and must declare a positive arrival_subject",
file.display(),
check.id
));
}
}
/*
* A setup value cannot be the thing a check proves.
*
* `setup_type_into` establishes a precondition before the baseline, so the
* only honest reading of a change expectation on that same field is "the
* measured action changed what setup put there". With no measured action
* there is nothing between the two observations but the harness's own
* typing: the check either compares the setup value with itself, or, if
* the baseline wins the race with the runtime, reports the setup's own
* effect as the outcome. Neither says anything about the application.
*/
if matches!(
check.expect,
Expect::ValueChanges | Expect::NameChanges | Expect::SelectionChanges | Expect::FocusMoves
) && check.setup_type_into.as_deref() == Some(check.subject.as_str())
&& check.click.is_none()
&& check.text.is_none()
&& check.key.is_none()
&& check.keys.is_empty()
&& check.scroll_over.is_none()
{
return Err(format!(
concat!(
"{}: check {:?} asserts {:?} on {:?}, which is the field its own setup value ",
"was typed into, and drives no action; declare the action that is supposed to ",
"change it, or assert the value with a different subject"
),
file.display(),
check.id,
check.expect,
check.subject,
));
}
if check.scroll_over.is_some() && (check.scroll_ticks == 0 || check.scroll_delta == 0.0) {
return Err(format!(
"{}: check {:?} must declare non-zero scroll_ticks and scroll_delta with scroll_over",
file.display(),
check.id,
));
}
if let Some(drag) = &check.pointer_drag
&& let Some(to) = &drag.to
&& (to.is_empty() || drag.dx != 0.0 || drag.dy != 0.0)
{
return Err(format!(
"{}: check {:?} must use either a non-empty pointer drag destination or dx/dy offsets",
file.display(),
check.id,
));
}
/*
* A weakening that does nothing must not look like it did something.
*
* `text_sized` trades a box for a layout, and only the two input-state
* verdicts ask for a box on the subject's own behalf. Accepted silently
* anywhere else it would read as "this check tolerates a fontless host"
* while the geometry it actually depends on was never relaxed, which is
* the sort of thing a suite discovers on the CI run it was written for.
*/
if check.text_sized && !matches!(check.expect, Expect::Enabled | Expect::Disabled) {
return Err(format!(
concat!(
"{}: check {:?} declares text_sized with {:?}, which does not judge the ",
"subject's box on its own. text_sized applies to Enabled and Disabled; for a ",
"geometry assertion on a fontless host the expectation is Present"
),
file.display(),
check.id,
check.expect,
));
}
if check.expect == Expect::GpuHasResource
&& !check.subject.split_once(':').is_some_and(|(kind, _)| {
matches!(
kind,
"buffer"
| "texture"
| "sampler"
| "shader-module"
| "render-pipeline"
| "compute-pipeline"
| "bind-group"
| "bind-group-layout"
| "pipeline-layout"
)
})
{
return Err(format!(
"{}: check {:?} must use kind:label with GpuHasResource",
file.display(),
check.id,
));
}
if matches!(check.expect, Expect::GpuDraws(_)) && check.subject.is_empty() {
return Err(format!(
"{}: check {:?} must name a GPU target with GpuDraws",
file.display(),
check.id,
));
}
if check.expect == Expect::GpuTextureInk {
let labelled = check
.subject
.strip_prefix("texture:")
.is_some_and(|label| !label.is_empty());
let canvas = check
.subject
.strip_prefix("canvas:#")
.is_some_and(|id| !id.is_empty() && !id.chars().any(char::is_whitespace));
if !labelled && !canvas {
return Err(format!(
"{}: check {:?} must name texture:<label> or canvas:#id with GpuTextureInk",
file.display(),
check.id,
));
}
}
if check.expect == Expect::Count && check.expect_count.is_none() {
return Err(format!(
"{}: check {:?} must declare expect_count with Count",
file.display(),
check.id,
));
}
if check.expect == Expect::ValueIs && check.expect_value.is_none() {
return Err(format!(
"{}: check {:?} must declare expect_value with ValueIs",
file.display(),
check.id,
));
}
if check.expect != Expect::ValueIs && check.expect_value.is_some() {
return Err(format!(
"{}: check {:?} declares expect_value without ValueIs",
file.display(),
check.id,
));
}
Ok(())
}
pub(crate) fn matching<'a>(nodes: &'a [SemanticNode], want: &str) -> Vec<&'a SemanticNode> {
nodes
.iter()
.filter(|node| selector_matches_node(node, want))
.collect()
}
/// Whether a node is on screen with a box worth painting.
///
/// A zero-area box is the failure this exists to catch: present in the tree,
/// absent from the window.
pub(crate) fn paints(node: &SemanticNode) -> bool {
/*
* Geometry alone, because `visible` and the renderer disagree.
*
* Measured on one node at one instant: `paint` reported the rename editor
* `300.0x21.1 at 87,236 opacity=1.00 Visible` while the semantic tree
* reported that same id `HIDDEN`. `visible` walks ancestors for
* `display:none` and `aria-hidden`, and a wrapper whose class no longer
* says `hidden` was still carrying it in the style tree while its subtree
* laid out and drew.
*
* Trusting the flag called controls dead that a person can see and use -
* the icons group reported "246 exist, none paints" for an app visibly
* full of icons. A non-zero box at a real position is what can be checked
* honestly from here; `ps-qa paint` is the tool for the pixels themselves.
*/
node.bounds.is_some_and(|b| b[2] > 0.0 && b[3] > 0.0)
}
/// Whether a node counts as shown, under this check's declared strictness.
///
/// Geometry is the default and stays the default for the reason written on
/// [`paints`]. [`Check::require_visible`] is how a check that needs the flag as
/// well says so, for the components geometry alone cannot judge.
fn shows(check: &Check, node: &SemanticNode) -> bool {
paints(node) && (!check.require_visible || node.visible)
}
/// Whether this check may read the subject's input state off this node.
///
/// A box is the default evidence that the control is on a screen, and stays
/// the default. [`Check::text_sized`] trades it for the weaker thing that
/// survives a fontless host: the node was laid out. That is the same floor
/// [`Expect::Present`] holds, and it is still falsifiable - a node the document
/// never created is not here, and one that never reached layout has no bounds.
fn state_readable(check: &Check, node: &SemanticNode) -> bool {
if check.text_sized {
node.bounds.is_some()
} else {
paints(node)
}
}
/// The verdict for one check, given the tree before and after its action.
pub fn verdict(
check: &Check,
before: &[SemanticNode],
after: &[SemanticNode],
) -> Result<(), String> {
if !check.any_of.is_empty() {
let mut failures = Vec::with_capacity(check.any_of.len() + 1);
let mut outcomes = Vec::with_capacity(check.any_of.len() + 1);
outcomes.push((check.subject.as_str(), check.expect));
outcomes.extend(
check
.any_of
.iter()
.map(|alternative| (alternative.subject.as_str(), alternative.expect)),
);
for (subject, expect) in outcomes {
let mut alternative = check.clone();
alternative.subject = subject.to_owned();
alternative.expect = expect;
alternative.any_of.clear();
match verdict(&alternative, before, after) {
Ok(()) => return Ok(()),
Err(error) => failures.push(error),
}
}
return Err(format!(
"none of the declared rendered outcomes matched: {}",
failures.join("; ")
));
}
let found = matching(after, &check.subject);
match check.expect {
Expect::Vanishes => {
/*
* Both signals, because neither answers this alone.
*
* `paints` is geometry only, and deliberately so: `visible` walks
* ancestors for `display:none` and `aria-hidden` and reported a
* screen full of icons as painting nothing. But a closed overlay
* keeps its box. Measured on Select: Escape closes the listbox
* correctly and both options stay in the tree at 1170x36, now
* hidden, so geometry alone called a working component broken.
*
* `Paints` still asks about geometry, where trusting `visible`
* would reintroduce the false negative. Only this arm, which asks
* whether something went away, needs to hear that it did.
*/
/*
* And a position, because a box is not a place on the screen.
*
* A responsive composition routinely carries two copies of the same
* control: the desktop one, and a narrow duplicate the layout parks
* outside the window rather than removing. The parked copy is
* `visible`, has a full-size box, and is at x=-1180. Judging it by
* geometry alone reported every dialog with such a mirror as "still
* on screen; it did not close" no matter how correctly it closed,
* which made this expectation unusable for the whole pattern.
*
* `offscreen` is the predicate the driving side already uses to
* decide that pressing a control would land on nothing. A control
* nothing can be aimed at is not on screen for this verdict either.
*/
let on_screen: Vec<&SemanticNode> = found
.iter()
.copied()
.filter(|node| {
node.visible
&& paints(node)
&& !node.bounds.is_some_and(|bounds| {
crate::target::offscreen(
bounds,
crate::target::viewport_for_node_in(after, node.id),
)
})
})
.collect();
if let Some(node) = on_screen.first() {
let b = node.bounds.unwrap_or([0.0; 4]);
return Err(format!(
"{:?} is still on screen at {:.0}x{:.0} at {:.0},{:.0}; it did not close",
check.subject, b[2], b[3], b[0], b[1]
));
}
}
Expect::Paints => {
if found.is_empty() {
return Err(format!("no node matching {:?} exists", check.subject));
}
let broken: Vec<_> = found
.iter()
.copied()
.filter(|node| !shows(check, node))
.collect();
if !broken.is_empty() {
/*
* Say which half of "paints" failed.
*
* Hidden-but-sized and visible-but-zero-area are different
* bugs: the first is a node the panel deliberately keeps
* offscreen, the second is a control the user is meant to see
* and cannot. Reporting them as one message sent me looking at
* the wrong one.
*/
let hidden = broken.iter().filter(|node| !node.visible).count();
let zero = broken
.iter()
.filter(|node| {
node.visible && !node.bounds.is_some_and(|b| b[2] > 0.0 && b[3] > 0.0)
})
.count();
let boxes: Vec<String> = broken
.iter()
.take(3)
.map(|node| {
let size = node
.bounds
.map(|b| format!("{:.0}x{:.0}", b[2], b[3]))
.unwrap_or_else(|| "no box".into());
format!("{size}{}", if node.visible { "" } else { " hidden" })
})
.collect();
return Err(format!(
"{} of {} node(s) matching {:?} do not paint: \
{hidden} hidden, {zero} visible with no area ({})",
broken.len(),
found.len(),
check.subject,
boxes.join(", ")
));
}
}
Expect::Enabled | Expect::Disabled => {
let wanted = check.expect == Expect::Enabled;
let word = if wanted { "enabled" } else { "disabled" };
if found
.iter()
.any(|node| state_readable(check, node) && node.enabled == wanted)
{
return Ok(());
}
/*
* Say when the state was right and only the box was empty.
*
* "no painted, enabled node" sends the reader looking for a
* missing control, and on a fontless host the control is there
* with the flag the check asked for. That is a one-word fix in the
* check file, so name the word rather than making the next person
* measure the tree to find it.
*/
let text_sized_would_pass = !check.text_sized
&& found
.iter()
.any(|node| node.bounds.is_some() && node.enabled == wanted);
let states = found
.iter()
.take(3)
.map(|node| {
format!(
"id={} role={:?} name={:?} enabled={} bounds={:?}",
node.id, node.role, node.name, node.enabled, node.bounds
)
})
.collect::<Vec<_>>();
let hint = if text_sized_would_pass {
format!(
"; a laid-out node is already {word} with an empty box, which is what a \
control sized by its own label measures on a host with no fonts. Declare \
text_sized: true to judge the flag there"
)
} else {
String::new()
};
return Err(format!(
"no {}, {word} node matching {:?} ({}){hint}",
if check.text_sized {
"laid out"
} else {
"painted"
},
check.subject,
states.join(", ")
));
}
Expect::Absent => {
if !found.is_empty() {
return Err(format!(
"{} node(s) matching {:?} should not exist",
found.len(),
check.subject
));
}
}
Expect::Present => {
if found.is_empty() {
let near = after
.iter()
.filter(|node| {
check
.subject
.split_once(':')
.is_some_and(|(role, _)| node.role.eq_ignore_ascii_case(role))
})
.take(3)
.map(|node| format!("{}:{}", node.role, node.name))
.collect::<Vec<_>>()
.join(", ");
let near = if near.is_empty() {
"none".to_owned()
} else {
near
};
return Err(format!(
"no node matching {:?} exists in the tree; same role present: {near}",
check.subject
));
}
if !found.iter().any(|node| node.bounds.is_some()) {
let state = found
.iter()
.map(|node| {
format!(
"id={} parent={:?} visible={}",
node.id, node.parent, node.visible
)
})
.collect::<Vec<_>>()
.join("; ");
return Err(format!(
"node(s) matching {:?} exist but none was laid out ({state})",
check.subject
));
}
}
Expect::PaintsNamed => {
if !found.iter().any(|node| {
shows(check, node)
&& !node.bounds.is_some_and(|bounds| {
crate::target::offscreen(
bounds,
crate::target::viewport_for_node_in(after, node.id),
)
})
}) {
let state = found
.iter()
.map(|node| {
format!(
"id={} parent={:?} visible={} bounds={:?}",
node.id, node.parent, node.visible, node.bounds
)
})
.collect::<Vec<_>>()
.join("; ");
let other_painted = check
.subject
.split_once(':')
.map(|(role, name)| {
after
.iter()
.filter(|node| {
!node.role.eq_ignore_ascii_case(role)
&& crate::target::name_matches(&node.name, name)
&& paints(node)
})
.take(3)
.map(|node| format!("{} id={}", node.role, node.id))
.collect::<Vec<_>>()
.join(", ")
})
.unwrap_or_default();
let other_painted = if other_painted.is_empty() {
"none".to_owned()
} else {
other_painted
};
return Err(format!(
"no painted node matching {:?} has a box ({} in the tree: {state}); \
other painted matches: {other_painted}",
check.subject,
found.len(),
));
}
}
Expect::DistinctPositions => {
let painted: Vec<_> = found.iter().copied().filter(|node| paints(node)).collect();
if painted.len() < 2 {
return Err(format!(
"{:?} has {} painted match(es); expected a positioned family",
check.subject,
painted.len()
));
}
let positions: std::collections::HashSet<(i64, i64)> = painted
.iter()
.map(|node| {
let bounds = node.bounds.expect("painted nodes have bounds");
(
((bounds[0] + bounds[2] / 2.0) * 10.0).round() as i64,
((bounds[1] + bounds[3] / 2.0) * 10.0).round() as i64,
)
})
.collect();
if positions.len() != painted.len() {
return Err(format!(
"{} painted node(s) matching {:?} occupy only {} distinct position(s)",
painted.len(),
check.subject,
positions.len()
));
}
}
Expect::ContainedBy => {
let compare = check
.compare
.as_deref()
.ok_or_else(|| "ContainedBy requires compare".to_owned())?;
let painted: Vec<_> = found.iter().copied().filter(|node| paints(node)).collect();
if painted.is_empty() {
return Err(format!("no painted node matching {:?}", check.subject));
}
let container = matching(after, compare)
.into_iter()
.filter(|node| !painted.iter().any(|subject| subject.id == node.id))
.find_map(|node| paints(node).then_some(node.bounds).flatten())
.ok_or_else(|| format!("no painted comparison node matching {compare:?}"))?;
const SLACK: f64 = 1.0;
for node in painted {
let bounds = node.bounds.expect("painted nodes have bounds");
let inside = bounds[0] >= container[0] - SLACK
&& bounds[1] >= container[1] - SLACK
&& bounds[0] + bounds[2] <= container[0] + container[2] + SLACK
&& bounds[1] + bounds[3] <= container[1] + container[3] + SLACK;
if !inside {
return Err(format!(
"{:?} id={} at {:.0},{:.0} {:.0}x{:.0} escapes {compare:?} at \
{:.0},{:.0} {:.0}x{:.0}",
check.subject,
node.id,
bounds[0],
bounds[1],
bounds[2],
bounds[3],
container[0],
container[1],
container[2],
container[3]
));
}
}
}
Expect::TargetPaints => {
return Err("TargetPaints must be resolved by the live QA runner".to_owned());
}
Expect::Measures => {
let want = check
.expect_size
.as_deref()
.ok_or_else(|| "Measures requires expect_size".to_owned())?;
let painted = found
.iter()
.copied()
.filter(|node| paints(node))
.collect::<Vec<_>>();
if painted.is_empty() {
return Err(format!("no painted node matching {:?}", check.subject));
}
let (want_w, want_h) = want.split_once('x').ok_or_else(|| {
format!("expect_size {want:?} is not WxH; use `190x24`, `x24` or `190x`")
})?;
for node in painted {
let box_ = node.bounds.expect("painted nodes have bounds");
for (axis, spec, actual) in
[("width", want_w, box_[2]), ("height", want_h, box_[3])]
{
let spec = spec.trim();
if spec.is_empty() {
continue;
}
// A pixel of slack, because layout rounds and a control that
// asks for 24 can legitimately resolve to 23.6.
const SLACK: f64 = 1.0;
let (compare, number) = match spec.strip_prefix("<=") {
Some(rest) => ("at most", rest),
None => match spec.strip_prefix('=') {
Some(rest) => ("exactly", rest),
None => ("at least", spec),
},
};
let target: f64 = number
.trim()
.parse()
.map_err(|_| format!("expect_size {axis} {number:?} is not a number"))?;
let ok = match compare {
"at most" => actual <= target + SLACK,
"exactly" => (actual - target).abs() <= SLACK,
_ => actual >= target - SLACK,
};
if !ok {
return Err(format!(
"{:?} id={} is {actual:.0}px {axis}, expected {compare} {target:.0}",
check.subject, node.id
));
}
}
}
}
Expect::Above => {
let compare = check
.compare
.as_deref()
.ok_or_else(|| "Above requires compare".to_owned())?;
if found.is_empty() {
return Err(format!("no node matching {:?}", check.subject));
}
let others: Vec<_> = matching(after, compare)
.into_iter()
.filter(|node| paints(node))
.collect();
if others.is_empty() {
return Err(format!("no painted comparison node matching {compare:?}"));
}
for subject_node in &found {
if !paints(subject_node) {
return Err(format!(
"{:?} id={} does not paint",
check.subject, subject_node.id
));
}
let subject = subject_node.bounds.expect("painted nodes have bounds");
if !others.iter().any(|other| {
other.id != subject_node.id
&& other.bounds.is_some_and(|bounds| subject[1] < bounds[1])
}) {
return Err(format!(
"{:?} id={} is at y={:.0}, not above any {compare:?}",
check.subject, subject_node.id, subject[1]
));
}
}
}
Expect::RightOf => {
let compare = check
.compare
.as_deref()
.ok_or_else(|| "RightOf requires compare".to_owned())?;
if found.is_empty() {
return Err(format!("no node matching {:?}", check.subject));
}
let others: Vec<_> = matching(after, compare)
.into_iter()
.filter(|node| paints(node))
.collect();
if others.is_empty() {
return Err(format!("no painted comparison node matching {compare:?}"));
}
const SLACK: f64 = 1.0;
for subject_node in &found {
if !paints(subject_node) {
return Err(format!(
"{:?} id={} does not paint",
check.subject, subject_node.id
));
}
let subject = subject_node.bounds.expect("painted nodes have bounds");
if !others.iter().any(|other| {
other.id != subject_node.id
&& other
.bounds
.is_some_and(|bounds| subject[0] >= bounds[0] + bounds[2] - SLACK)
}) {
return Err(format!(
"{:?} id={} starts at x={:.0}, not right of any {compare:?}",
check.subject, subject_node.id, subject[0]
));
}
}
}
Expect::CenterAlignedY => {
let compare = check
.compare
.as_deref()
.ok_or_else(|| "CenterAlignedY requires compare".to_owned())?;
if found.is_empty() {
return Err(format!("no node matching {:?}", check.subject));
}
let others: Vec<_> = matching(after, compare)
.into_iter()
.filter(|node| paints(node))
.collect();
if others.is_empty() {
return Err(format!("no painted comparison node matching {compare:?}"));
}
const SLACK: f64 = 2.0;
for subject_node in &found {
if !paints(subject_node) {
return Err(format!(
"{:?} id={} does not paint",
check.subject, subject_node.id
));
}
let subject = subject_node.bounds.expect("painted nodes have bounds");
let subject_center = subject[1] + subject[3] / 2.0;
if !others.iter().any(|other| {
other.id != subject_node.id
&& other.bounds.is_some_and(|bounds| {
let other_center = bounds[1] + bounds[3] / 2.0;
(subject_center - other_center).abs() <= SLACK
})
}) {
return Err(format!(
"{:?} id={} is centered at y={subject_center:.0}, not aligned with any {compare:?}",
check.subject, subject_node.id
));
}
}
}
Expect::GpuNoErrors
| Expect::GpuHasResource
| Expect::GpuDraws(_)
| Expect::GpuTextureInk => {
return Err("GPU expectations must be resolved by the live QA runner".to_owned());
}
Expect::PixelsHold
| Expect::PixelsHoldAfterHover
| Expect::PixelsChange
| Expect::VisibleInk
| Expect::InteriorInk
| Expect::OpaqueBackground
| Expect::TransparentBackground
| Expect::FullOpacity
| Expect::TransparentWindowTint
| Expect::Contrast
| Expect::FontSizeGrows => {
return Err("paint expectations must be resolved by the live QA runner".to_owned());
}
Expect::PaintsMore => {
let was = matching(before, &check.subject)
.into_iter()
.filter(|node| shows(check, node))
.count();
let now = found.iter().filter(|node| shows(check, node)).count();
if now <= was {
return Err(format!(
"{:?} on screen went {was} -> {now}, expected one more",
check.subject
));
}
}
Expect::FamilyChanges => {
let family = |nodes: &[SemanticNode]| {
matching(nodes, &check.subject)
.into_iter()
.filter(|node| paints(node))
.map(|node| (node.id, node.name.clone()))
.collect::<std::collections::HashSet<_>>()
};
let was = family(before);
let now = family(after);
if now.is_empty() {
return Err(format!(
"no painted node matching {:?} after pagination",
check.subject
));
}
if now == was {
return Err(format!(
"{:?} kept the same {} rendered member(s)",
check.subject,
now.len()
));
}
}
Expect::Grows => {
let was = matching(before, &check.subject).len();
let now = found.len();
if now <= was {
return Err(format!(
"{:?} went {was} -> {now}, expected more",
check.subject
));
}
}
Expect::Holds => {
let was = matching(before, &check.subject).len();
let now = found.len();
if now != was {
return Err(format!(
"{:?} went {was} -> {now}, expected no change",
check.subject
));
}
}
Expect::Count => {
let want = check
.expect_count
.ok_or_else(|| "Count requires expect_count".to_owned())?;
// Tree membership by default, so an exact family size keeps
// counting the members a retained pane legitimately holds. A check
// that declared `require_visible` is asking about the ones a person
// can see, and counts only those.
let counted: Vec<&&SemanticNode> = found
.iter()
.filter(|node| !check.require_visible || shows(check, node))
.collect();
if counted.len() != want {
return Err(format!(
"{:?} has {} member(s), expected {want}",
check.subject,
counted.len()
));
}
}
Expect::ValueChanges => {
let before_node = matching(before, &check.subject)
.into_iter()
.find(|node| paints(node))
.ok_or_else(|| {
format!("no painted node matching {:?} before action", check.subject)
})?;
value_changed(before_node.id, before, after)?;
}
Expect::ValueIs => {
let want = check
.expect_value
.as_deref()
.ok_or_else(|| "ValueIs requires expect_value".to_owned())?;
if found
.iter()
.any(|node| state_readable(check, node) && node.value.as_deref() == Some(want))
{
return Ok(());
}
let seen = found.iter().rev().find_map(|node| {
if state_readable(check, node) {
node.value.as_deref()
} else {
None
}
});
return Err(match seen {
Some(value) => format!("value was {value:?}, expected {want:?}"),
None => "no value".to_owned(),
});
}
Expect::SelectionChanges => {
let before_node = matching(before, &check.subject)
.into_iter()
.find(|node| paints(node))
.ok_or_else(|| {
format!("no painted node matching {:?} before action", check.subject)
})?;
selection_changed(before_node.id, before, after)?;
}
Expect::FocusMoves => {
return Err(
"FocusMoves is evaluated by the live runner with snapshot focus state".to_owned(),
);
}
Expect::NameChanges => {
let before_node = matching(before, &check.subject)
.into_iter()
.find(|node| paints(node))
.ok_or_else(|| {
format!("no painted node matching {:?} before action", check.subject)
})?;
name_changed(before_node.id, before, after)?;
}
}
Ok(())
}
/// Assert that one exact semantic node changed its exposed value.
///
/// The live runner uses this after a named action has already resolved to an
/// id. Re-resolving by name here would let a neighbouring same-name row decide
/// the verdict instead of the control that was actually activated.
pub fn value_changed(
node_id: u64,
before: &[SemanticNode],
after: &[SemanticNode],
) -> Result<(), String> {
let before_node = before
.iter()
.find(|node| node.id == node_id)
.ok_or_else(|| format!("node {node_id} was absent before action"))?;
let after_node = after
.iter()
.find(|node| node.id == node_id)
.ok_or_else(|| format!("node {node_id} disappeared after action"))?;
let old = before_node
.value
.as_deref()
.ok_or_else(|| format!("node {node_id} has no semantic value before action"))?;
let new = after_node
.value
.as_deref()
.ok_or_else(|| format!("node {node_id} has no semantic value after action"))?;
if old == new {
return Err(format!("semantic value for node {node_id} stayed {old:?}"));
}
Ok(())
}
/// Assert that one exact semantic node changed selected/pressed state.
pub fn selection_changed(
node_id: u64,
before: &[SemanticNode],
after: &[SemanticNode],
) -> Result<(), String> {
let before_node = before
.iter()
.find(|node| node.id == node_id)
.ok_or_else(|| format!("node {node_id} was absent before action"))?;
let after_node = after
.iter()
.find(|node| node.id == node_id)
.ok_or_else(|| format!("node {node_id} disappeared after action"))?;
if before_node.selected == after_node.selected {
return Err(format!(
"selected state for node {node_id} stayed {}",
before_node.selected
));
}
Ok(())
}
/// Assert that one exact semantic node changed its accessible name.
pub fn name_changed(
node_id: u64,
before: &[SemanticNode],
after: &[SemanticNode],
) -> Result<(), String> {
let before_node = before
.iter()
.find(|node| node.id == node_id)
.ok_or_else(|| format!("node {node_id} was absent before action"))?;
let after_node = after
.iter()
.find(|node| node.id == node_id)
.ok_or_else(|| format!("node {node_id} disappeared after action"))?;
if before_node.name == after_node.name {
return Err(format!(
"accessible name for node {node_id} stayed {:?}",
before_node.name
));
}
Ok(())
}
/// Every check, grouped, with what it drives and what it asserts.
///
/// Printed by `ps-qa list`, and generated from [`checks`] rather than written
/// down, so it cannot drift from what actually runs. This is the inventory: it
/// answers "what is covered" without launching the app, which is the question
/// that had no answer while the audit was a list of button names in a handover.
pub fn manifest(dir: Option<&std::path::Path>) -> Result<String, String> {
let all = checks(dir)?;
let mut out = String::new();
let mut current = String::new();
for check in &all {
if check.group != current {
current = check.group.clone();
out.push_str(&format!("\n{current}\n"));
}
let action = action_description(check);
out.push_str(&format!(
" {:<26} {}\n{:<29}{} -> {:?} {:?}\n",
check.id, check.what, "", action, check.expect, check.subject
));
if !check.covers.is_empty() {
out.push_str(&format!("{:<29}covers {:?}\n", "", check.covers));
}
}
out.push_str(&format!("\n{} checks in {} groups\n", all.len(), {
all.iter()
.map(|check| check.group.as_str())
.collect::<std::collections::HashSet<_>>()
.len()
}));
Ok(out)
}
fn action_description(check: &Check) -> String {
let mut action = match (&check.hover, &check.click, check.press) {
(Some(h), Some(c), true) => format!("hover {h:?}, press {c:?}"),
(Some(h), Some(c), false) => format!("hover {h:?}, activate {c:?}"),
(Some(h), None, _) => format!("hover {h:?}"),
(None, Some(c), true) => format!("press {c:?}"),
(None, Some(c), false) => format!("activate {c:?}"),
(None, None, _) => "observe only".to_owned(),
};
if let Some(prepare) = check.prepare.as_deref() {
let preparation = if let Some(key) = check.prepare_key.as_deref() {
format!("prepare-key {key:?} on {prepare:?}")
} else if check.prepare_press {
format!("prepare-press {prepare:?}")
} else {
format!("prepare {prepare:?}")
};
action = format!("{preparation}, {action}");
}
if let (Some(field), Some(value)) = (
check.setup_type_into.as_deref(),
check.setup_text.as_deref(),
) {
action = format!("setup {value:?} in {field:?}, {action}");
}
if let Some(field) = check.type_into.as_deref() {
let typed = check.text.as_deref().map_or_else(
|| format!("focus {field:?}"),
|value| format!("type {value:?} into {field:?}"),
);
if action == "observe only" {
action = typed;
} else {
action.push_str(&format!(", {typed}"));
}
}
if let Some(drag) = &check.pointer_drag {
let description = format!(
"drag {:?} {} in {} steps{}",
drag.from,
drag.to.as_ref().map_or_else(
|| format!("by {},{}", drag.dx, drag.dy),
|to| format!("to {to:?}"),
),
drag.steps,
if drag.cancel {
" and cancel"
} else {
" and release"
}
);
if action == "observe only" {
action = description;
} else {
action.push_str(&format!(", {description}"));
}
}
if let (Some(key), Some(target)) = (
&check.key,
check.key_on.as_ref().or(check.type_into.as_ref()),
) {
action.push_str(&format!(", key {key:?} on {target:?}"));
}
if !check.keys.is_empty() {
let description = format!("keys {:?}", check.keys);
if action == "observe only" {
action = description;
} else {
action.push_str(&format!(", {description}"));
}
}
if let Some(target) = check.scroll_over.as_deref() {
action.push_str(&format!(
", scroll {} x {:.0} over {target:?}",
check.scroll_ticks, check.scroll_delta
));
}
action
}
/// Count matching nodes per group, for the summary line.
pub fn tally<'a>(results: &[(&'a Check, Result<(), String>)]) -> HashMap<&'a str, (usize, usize)> {
let mut by_group: HashMap<&str, (usize, usize)> = HashMap::new();
for (check, outcome) in results {
let entry = by_group.entry(check.group.as_str()).or_insert((0, 0));
entry.1 += 1;
if outcome.is_ok() {
entry.0 += 1;
}
}
by_group
}
#[cfg(test)]
mod tests {
use super::{
Check, Expect, action_description, checks, name_changed, selection_changed, validate_check,
value_changed, verdict,
};
use blitz_control_protocol::SemanticNode;
use std::collections::HashMap;
use std::path::Path;
fn parse(extra: &str) -> Check {
let ron = format!(
"(id:\"action\",group:\"group\",what:\"outcome\",open:None,hover:None,\
click:Some(\"Save\"),{extra}subject:\"Saved\",expect:Paints)"
);
ron::from_str(&ron).expect("check parses")
}
#[test]
fn navigate_is_optional_and_read_from_check_files() {
assert_eq!(parse("").navigate, None);
assert_eq!(
parse("navigate:Some(\"/account\"),").navigate.as_deref(),
Some("/account")
);
}
fn painted_node(id: u64, name: &str, width: f64, height: f64) -> SemanticNode {
SemanticNode {
dom_id: None,
id,
parent: None,
role: "generic".into(),
name: name.into(),
value: None,
enabled: true,
focusable: false,
viewport_fixed: false,
visible: true,
selected: false,
bounds: Some([0.0, 0.0, width, height]),
slot: None,
}
}
/// A disclosure that keeps its box can be proven closed but never open.
///
/// This is the false pass: the geometry assertion is satisfied by the
/// *closed* panel, so it says nothing at all about the control it names. No
/// spelling available before `require_visible` could tell the two states
/// apart, which is why disclosure coverage stopped at "it closes".
#[test]
fn a_panel_that_hides_by_flag_alone_needs_the_flag_to_be_read() {
let panel = |visible: bool| SemanticNode {
visible,
bounds: Some([0.0, 120.0, 400.0, 200.0]),
..painted_node(2, "Advanced options", 400.0, 200.0)
};
let closed = [
painted_node(1, "Advanced options", 180.0, 30.0),
panel(false),
];
let open = [
painted_node(1, "Advanced options", 180.0, 30.0),
panel(true),
];
let mut geometry = parse("");
geometry.click = Some("Advanced options".into());
geometry.subject = "Advanced options".into();
geometry.expect = Expect::Paints;
assert!(
verdict(&geometry, &closed, &closed).is_ok(),
"the closed panel already satisfies a geometry-only assertion"
);
let mut strict = geometry.clone();
strict.require_visible = true;
assert!(
verdict(&strict, &closed, &closed).is_err(),
"reading the flag distinguishes closed from open"
);
assert!(verdict(&strict, &closed, &open).is_ok());
// The same is true of the family assertions: nothing about the boxes
// moves when the panel opens.
let mut more = strict.clone();
more.expect = Expect::PaintsMore;
more.require_visible = false;
assert!(
verdict(&more, &closed, &open).is_err(),
"counting boxes cannot see a disclosure open"
);
more.require_visible = true;
assert!(verdict(&more, &closed, &open).is_ok());
let mut count = strict.clone();
count.expect = Expect::Count;
count.expect_count = Some(2);
count.require_visible = false;
assert!(
verdict(&count, &closed, &closed).is_ok(),
"counting tree membership cannot see a disclosure closed either"
);
count.require_visible = true;
assert!(
verdict(&count, &closed, &closed).is_err(),
"only the trigger is on screen while the panel is closed"
);
assert!(verdict(&count, &closed, &open).is_ok());
}
/// A hidden mirror copy must not keep a closed control "on screen".
///
/// The responsive pattern is one desktop control plus a narrow duplicate
/// the layout parks outside the window. The duplicate is `visible`, keeps a
/// full-size box, and sits at a negative x. Judging `Vanishes` on geometry
/// and the flag alone reported the dialog as never closing, whatever the
/// component did, so the expectation could not be used at all on any site
/// built that way.
#[test]
fn a_parked_duplicate_is_not_a_control_that_stayed_open() {
let mut check = parse("");
check.click = None;
check.expect = Expect::Vanishes;
check.subject = "Delete project".into();
let main = SemanticNode {
role: "main".into(),
bounds: Some([0.0, 58.0, 1280.0, 842.0]),
..painted_node(1, "", 1280.0, 842.0)
};
let closed = SemanticNode {
parent: Some(1),
visible: false,
bounds: Some([200.0, 200.0, 420.0, 180.0]),
..painted_node(2, "Delete project", 420.0, 180.0)
};
// The narrow duplicate: on the wire it is indistinguishable from the
// desktop dialog except for where the layout put it.
let parked = SemanticNode {
parent: Some(1),
bounds: Some([-1180.0, 200.0, 420.0, 180.0]),
..painted_node(3, "Delete project", 420.0, 180.0)
};
assert!(
verdict(&check, &[], &[main.clone(), closed.clone(), parked.clone()]).is_ok(),
"a control nothing can be aimed at is not on screen"
);
// The expectation still has teeth: the same dialog inside the window is
// a dialog that did not close.
let open = SemanticNode {
bounds: Some([200.0, 200.0, 420.0, 180.0]),
..parked
};
let error = verdict(&check, &[], &[main, closed, open])
.expect_err("a dialog in the window did not close");
assert!(error.contains("did not close"), "{error}");
assert!(
error.contains("at 200,200"),
"the position is reported: {error}"
);
}
#[test]
fn measures_rejects_any_matching_node_that_breaks_the_contract() {
let mut check = parse("");
check.click = None;
check.expect = Expect::Measures;
check.expect_size = Some("x<=24".into());
let compact = painted_node(1, "Saved", 80.0, 24.0);
let wrapped = painted_node(2, "Saved", 80.0, 52.0);
let error = verdict(&check, &[], &[compact.clone(), wrapped])
.expect_err("one valid representative cannot hide a wrapped sibling");
assert!(error.contains("id=2"));
assert!(error.contains("52px height"));
assert!(verdict(&check, &[], &[compact.clone(), compact]).is_ok());
}
#[test]
fn family_verdicts_reject_a_broken_sibling() {
let good = painted_node(1, "Saved", 20.0, 20.0);
let mut hidden = painted_node(2, "Saved", 20.0, 20.0);
hidden.visible = false;
hidden.bounds = Some([0.0, 0.0, 0.0, 0.0]);
let mut check = parse("");
check.click = None;
check.expect = Expect::Paints;
assert!(
verdict(&check, &[], &[good.clone(), hidden]).is_err(),
"one painted representative must not hide a broken sibling"
);
let comparison = SemanticNode {
id: 9,
name: "Anchor".into(),
bounds: Some([100.0, 100.0, 20.0, 20.0]),
..painted_node(9, "Anchor", 20.0, 20.0)
};
check.compare = Some("Anchor".into());
for (expect, valid_bounds, broken_bounds) in [
(
Expect::Above,
[100.0, 70.0, 20.0, 20.0],
[100.0, 130.0, 20.0, 20.0],
),
(
Expect::RightOf,
[130.0, 100.0, 20.0, 20.0],
[90.0, 100.0, 20.0, 20.0],
),
(
Expect::CenterAlignedY,
[130.0, 100.0, 20.0, 20.0],
[130.0, 130.0, 20.0, 20.0],
),
] {
let mut valid = good.clone();
valid.bounds = Some(valid_bounds);
let mut broken = good.clone();
broken.id = 2;
broken.bounds = Some(broken_bounds);
check.expect = expect;
assert!(
verdict(
&check,
&[],
&[valid.clone(), broken.clone(), comparison.clone()]
)
.is_err(),
"{expect:?} must validate every matching subject"
);
}
}
#[test]
fn checks_default_to_semantic_actions_and_can_opt_into_pointer_press() {
assert!(!parse("").press);
assert!(parse("press:true,").press);
}
#[test]
fn destructive_checks_are_explicit_and_default_to_the_shared_body() {
assert!(!parse("").destructive);
assert!(parse("destructive:true,").destructive);
}
#[test]
fn checks_can_prepare_a_semantic_state_before_the_measured_action() {
let check = parse("prepare:Some(\"Draft\"),");
assert_eq!(check.prepare.as_deref(), Some("Draft"));
assert_eq!(
action_description(&check),
"prepare \"Draft\", activate \"Save\""
);
}
#[test]
fn checks_can_time_an_action_inside_a_prepared_intermediate_state() {
let check = parse(
"prepare:Some(\"Page 6\"),prepare_until:Some(\"region:Page 6\"),prepare_wait_ms:50,",
);
assert_eq!(check.prepare_wait_ms, 50);
assert_eq!(check.prepare_until.as_deref(), Some("region:Page 6"));
let invalid = parse("prepare_wait_ms:50,");
let error = validate_check(&invalid, Path::new("carousel.ron"), &mut HashMap::new())
.expect_err("a preparation interval requires a preparation action");
assert!(error.contains("prepare_wait_ms without a prepare action"));
let invalid = parse("prepare:Some(\"Page 6\"),prepare_wait_ms:50,");
let error = validate_check(&invalid, Path::new("carousel.ron"), &mut HashMap::new())
.expect_err("a timed preparation requires an observed state");
assert!(error.contains("without a rendered prepare_until marker"));
let invalid = parse("prepare_until:Some(\"Page 6\"),");
let error = validate_check(&invalid, Path::new("carousel.ron"), &mut HashMap::new())
.expect_err("a preparation target requires a preparation action");
assert!(error.contains("prepare_until without a prepare action"));
}
#[test]
fn checks_can_make_preparation_idempotent() {
let check = parse("prepare:Some(\"Menu\"),prepare_unless:Some(\"menuitem:First\"),");
assert_eq!(check.prepare.as_deref(), Some("Menu"));
assert_eq!(check.prepare_unless.as_deref(), Some("menuitem:First"));
}
#[test]
fn checks_can_make_hover_idempotent() {
let check = parse("hover_unless:Some(\"Dialog\"),");
assert_eq!(check.hover_unless.as_deref(), Some("Dialog"));
}
#[test]
fn checks_can_prepare_with_a_real_pointer_without_changing_the_action_mode() {
let check = parse("prepare:Some(\"Draft\"),prepare_press:true,");
assert!(check.prepare_press);
assert!(!check.press);
assert_eq!(
action_description(&check),
"prepare-press \"Draft\", activate \"Save\""
);
}
#[test]
fn a_drag_can_name_its_painted_destination() {
let mut check =
parse("pointer_drag:Some((from:\"button:Piece\",to:Some(\"#target\"),steps:12)),");
check.click = None;
let drag = check.pointer_drag.as_ref().expect("drag is configured");
assert_eq!(drag.to.as_deref(), Some("#target"));
assert_eq!(drag.dx, 0.0);
assert_eq!(drag.dy, 0.0);
assert!(action_description(&check).contains("drag \"button:Piece\" to \"#target\""));
let mut invalid = check.clone();
invalid.pointer_drag.as_mut().unwrap().dx = 20.0;
let error = validate_check(&invalid, Path::new("drag.ron"), &mut HashMap::new())
.expect_err("a named destination and displacement are ambiguous");
assert!(error.contains("either a non-empty pointer drag destination or dx/dy"));
}
#[test]
fn checks_can_prepare_with_a_key_without_changing_the_measured_action() {
let check = parse("prepare:Some(\"Menu\"),prepare_key:Some(\"ArrowDown\"),");
assert_eq!(check.prepare_key.as_deref(), Some("ArrowDown"));
assert!(!check.press);
assert_eq!(
action_description(&check),
"prepare-key \"ArrowDown\" on \"Menu\", activate \"Save\""
);
}
#[test]
fn duplicate_check_ids_are_rejected_before_a_run() {
let check = parse("");
let mut ids = HashMap::new();
validate_check(&check, Path::new("first.ron"), &mut ids).expect("first id is unique");
let error = validate_check(&check, Path::new("second.ron"), &mut ids)
.expect_err("duplicate id must fail");
assert!(error.contains("duplicate check id \"action\""));
assert!(error.contains("first.ron"));
assert!(error.contains("second.ron"));
}
#[test]
fn a_dismissal_cannot_pass_by_sending_prepare_key_to_a_closed_subject() {
let mut check = parse(
"prepare:Some(\"Menu\"),prepare_unless:Some(\"menuitem:First\"),\
prepare_key:Some(\"Escape\"),",
);
check.click = None;
check.subject = "menuitem:First".into();
check.expect = Expect::Vanishes;
let error = validate_check(&check, Path::new("menu.ron"), &mut HashMap::new())
.expect_err("closed-menu false green must fail validation");
assert!(error.contains("can pass without opening"));
assert!(error.contains("key and key_on"));
}
#[test]
fn checks_can_repeat_hover_after_preparation() {
let check = parse("after_prepare_hover:Some((\"menuitem:low\",5)),");
let hover = check.after_prepare_hover.expect("post-prepare hover");
assert_eq!(hover.target(), "menuitem:low");
assert_eq!(hover.times(), 5);
}
#[test]
fn checks_can_reveal_a_region_before_their_first_capture() {
let check = parse("reveal_before_capture:Some(\"heading:Appearance\"),");
assert_eq!(
check.reveal_before_capture.as_deref(),
Some("heading:Appearance")
);
}
#[test]
fn checks_can_establish_typed_state_before_the_measured_action() {
let check = parse("setup_type_into:Some(\"Search projects\"),setup_text:Some(\"theta\"),");
assert_eq!(
action_description(&check),
"setup \"theta\" in \"Search projects\", activate \"Save\""
);
validate_check(&check, Path::new("search.ron"), &mut HashMap::new())
.expect("paired setup input is valid");
}
#[test]
fn typed_setup_requires_both_the_field_and_value() {
let check = parse("setup_type_into:Some(\"Search projects\"),");
let error = validate_check(&check, Path::new("search.ron"), &mut HashMap::new())
.expect_err("an incomplete setup must fail validation");
assert!(error.contains("setup_type_into and setup_text together"));
}
#[test]
fn checks_can_describe_literal_semantic_input() {
let check = parse(
"type_into:Some(\"New record\"),text:Some(\"latest fixture\"),\
key:Some(\"Enter\"),compare:Some(\"older\"),\
covers:[\"button:Save row \"],settle_after_ms:1200,",
);
assert_eq!(check.type_into.as_deref(), Some("New record"));
assert_eq!(check.text.as_deref(), Some("latest fixture"));
assert_eq!(check.key.as_deref(), Some("Enter"));
assert_eq!(check.compare.as_deref(), Some("older"));
assert_eq!(check.covers, ["button:Save row "]);
assert_eq!(check.settle_after_ms, 1200);
assert_eq!(check.stable_for_ms, 0);
assert_eq!(
action_description(&check),
"activate \"Save\", type \"latest fixture\" into \"New record\", key \"Enter\" on \"New record\""
);
}
#[test]
fn checks_can_describe_real_wheel_input() {
let check = parse("scroll_over:Some(\"listitem:\"),scroll_ticks:4,scroll_delta:-300.0,");
assert_eq!(check.scroll_over.as_deref(), Some("listitem:"));
assert_eq!(check.scroll_ticks, 4);
assert_eq!(check.scroll_delta, -300.0);
assert_eq!(
action_description(&check),
"activate \"Save\", scroll 4 x -300 over \"listitem:\""
);
}
/// A file may not start on a surface another file navigated to.
///
/// Inheriting the previous check's screen is how a sequence is written
/// inside one file. Across files it is a dependency nobody declared and
/// nobody reading either file can see, and it is how one site's checks came
/// to measure a page they had never navigated to and pass.
#[test]
fn a_file_may_not_inherit_the_surface_another_file_opened() {
let directory = std::env::temp_dir().join(format!(
"ps-qa-check-files-{}-{}",
std::process::id(),
std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.expect("system clock is after the epoch")
.as_nanos()
));
std::fs::create_dir(&directory).expect("create check directory");
let check = |id: &str, open: &str| {
format!(
"(id:\"{id}\",group:\"g\",what:\"w\",open:{open},hover:None,\
click:Some(\"Act\"),subject:\"Result\",expect:Paints)"
)
};
std::fs::write(
directory.join("a-settings.ron"),
format!(
"[{},{}]",
check("settings-open", "Some(\"Settings\")"),
check("settings-edit", "None")
),
)
.expect("write the first file");
std::fs::write(
directory.join("b-registry.ron"),
format!("[{}]", check("registry-publish", "None")),
)
.expect("write the second file");
let error = checks(Some(&directory)).expect_err("the second file declares no surface");
assert!(error.contains("registry-publish"), "{error}");
assert!(
error.contains("Settings"),
"the inherited surface is named: {error}"
);
assert!(
error.contains("a-settings.ron"),
"so is the file that set it: {error}"
);
// Declaring the surface is the fix, and the whole directory then loads.
std::fs::write(
directory.join("b-registry.ron"),
format!("[{}]", check("registry-publish", "Some(\"Registry\")")),
)
.expect("rewrite the second file");
let loaded = checks(Some(&directory)).expect("both files declare where they start");
assert_eq!(loaded.len(), 3);
std::fs::remove_dir_all(&directory).expect("remove check directory");
}
#[test]
fn a_change_expectation_on_the_setup_field_needs_an_action() {
let mut check = parse("setup_type_into:Some(\"Filter\"),setup_text:Some(\"acme\"),");
check.click = None;
check.subject = "Filter".into();
check.expect = Expect::ValueChanges;
let error = validate_check(&check, Path::new("filter.ron"), &mut HashMap::new())
.expect_err("nothing but the harness's own typing happens between the observations");
assert!(error.contains("setup value"), "{error}");
// The ordinary shape is still valid: setup establishes the value and a
// declared action is what has to change it.
check.click = Some("Clear".into());
validate_check(&check, Path::new("filter.ron"), &mut HashMap::new())
.expect("an action between the two observations is the point");
}
#[test]
fn count_checks_require_an_exact_count() {
let mut check = parse("");
check.expect = Expect::Count;
let error = validate_check(&check, Path::new("count.ron"), &mut HashMap::new())
.expect_err("Count without an exact value is ambiguous");
assert!(error.contains("expect_count"));
check.expect_count = Some(12);
validate_check(&check, Path::new("count.ron"), &mut HashMap::new())
.expect("an exact count is valid");
}
#[test]
fn a_value_check_follows_the_same_node_id() {
let check = Check {
id: "slider".into(),
group: "settings".into(),
what: "the slider moves".into(),
open: None,
navigate: None,
arrival_subject: None,
prepare: None,
prepare_unless: None,
prepare_press: false,
prepare_key: None,
prepare_wait_ms: 0,
prepare_until: None,
hover: None,
hover_unless: None,
after_prepare_hover: None,
reveal_before_capture: None,
setup_type_into: None,
setup_text: None,
setup_text_env: None,
setup_secret: None,
click: None,
storage: Default::default(),
type_into: None,
text: None,
key: Some("Right".into()),
key_on: Some("Output level".into()),
keys: Vec::new(),
scroll_over: None,
scroll_ticks: 0,
scroll_delta: 0.0,
compare: None,
expect_size: None,
expect_count: None,
expect_value: None,
covers: Vec::new(),
press: false,
pointer_drag: None,
settle_after_ms: 0,
open_timeout_ms: 0,
outcome_timeout_ms: 0,
stable_for_ms: 0,
require_visible: false,
text_sized: false,
destructive: false,
subject: "Output level".into(),
subject_env: None,
subject_secret: None,
expect: Expect::ValueChanges,
any_of: Vec::new(),
};
let node = |id, value: &str| SemanticNode {
dom_id: None,
id,
parent: None,
role: "slider".into(),
name: "Output level".into(),
value: Some(value.into()),
enabled: true,
focusable: false,
viewport_fixed: false,
visible: true,
selected: false,
bounds: Some([0.0, 0.0, 100.0, 20.0]),
slot: None,
};
assert!(verdict(&check, &[node(7, "0")], &[node(7, "1")]).is_ok());
assert!(verdict(&check, &[node(7, "0")], &[node(7, "0")]).is_err());
assert!(
verdict(&check, &[node(7, "0")], &[node(7, "0"), node(8, "1")],).is_err(),
"a neighbouring repeated control cannot satisfy the check"
);
assert!(
value_changed(
8,
&[node(7, "0"), node(8, "0")],
&[node(7, "1"), node(8, "0")],
)
.is_err(),
"the exact activated id cannot be replaced by a same-name neighbour"
);
}
#[test]
fn a_virtualized_family_can_advance_without_growing() {
let node = |id, name: &str| SemanticNode {
dom_id: None,
id,
parent: None,
role: "button".into(),
name: name.into(),
value: None,
enabled: true,
focusable: false,
viewport_fixed: false,
visible: true,
selected: false,
bounds: Some([0.0, 0.0, 100.0, 24.0]),
slot: None,
};
let first = node(1, "Rename project alpha");
let mut second = node(2, "Rename project beta");
let mut check = parse("");
check.subject = "button:Rename project ".into();
check.expect = Expect::FamilyChanges;
assert!(
verdict(
&check,
std::slice::from_ref(&first),
std::slice::from_ref(&second)
)
.is_ok()
);
assert!(
verdict(
&check,
std::slice::from_ref(&first),
std::slice::from_ref(&first)
)
.is_err()
);
second.bounds = Some([0.0, 0.0, 0.0, 0.0]);
assert!(verdict(&check, &[first], &[second]).is_err());
}
#[test]
fn a_selection_check_follows_the_same_node_id() {
let before = SemanticNode {
dom_id: None,
id: 7,
parent: None,
role: "radio".into(),
name: "Theme colour".into(),
value: None,
enabled: true,
focusable: false,
viewport_fixed: false,
visible: true,
selected: false,
bounds: Some([0.0, 0.0, 20.0, 20.0]),
slot: None,
};
let mut after = before.clone();
after.selected = true;
assert!(
selection_changed(
7,
std::slice::from_ref(&before),
std::slice::from_ref(&after),
)
.is_ok()
);
assert!(
selection_changed(
7,
std::slice::from_ref(&before),
std::slice::from_ref(&before),
)
.is_err()
);
}
#[test]
fn a_name_check_follows_the_same_node_id() {
let node = |id, name: &str| SemanticNode {
dom_id: None,
id,
parent: None,
role: "status".into(),
name: name.into(),
value: None,
enabled: true,
focusable: false,
viewport_fixed: false,
visible: true,
selected: false,
bounds: Some([0.0, 0.0, 100.0, 20.0]),
slot: None,
};
assert!(name_changed(7, &[node(7, "Refreshed 1")], &[node(7, "Refreshed 2")]).is_ok());
assert!(name_changed(7, &[node(7, "Refreshed 1")], &[node(7, "Refreshed 1")]).is_err());
assert!(
name_changed(
7,
&[node(7, "Refreshed 1")],
&[node(7, "Refreshed 1"), node(8, "Refreshed 2")],
)
.is_err(),
"a neighbouring status node cannot satisfy the check"
);
}
#[test]
fn a_named_paint_failure_reports_a_still_painted_activator() {
let mut check = parse("");
check.subject = "textbox:Rename project".into();
check.expect = Expect::PaintsNamed;
let node = |id, role: &str, bounds: Option<[f64; 4]>| SemanticNode {
dom_id: None,
id,
parent: None,
role: role.into(),
name: "Rename project".into(),
value: None,
enabled: true,
focusable: false,
viewport_fixed: false,
visible: bounds.is_some(),
selected: false,
bounds,
slot: None,
};
let error = verdict(
&check,
&[],
&[
node(7, "textbox", Some([0.0, 0.0, 0.0, 0.0])),
node(8, "button", Some([10.0, 10.0, 20.0, 20.0])),
],
)
.expect_err("the textbox does not paint");
assert!(error.contains("other painted matches: button id=8"));
}
#[test]
fn paints_named_uses_the_shared_selector_language() {
let node = SemanticNode {
dom_id: Some("project-rename".into()),
id: 7,
parent: None,
role: "textbox".into(),
name: "Rename project".into(),
value: None,
enabled: true,
focusable: false,
viewport_fixed: false,
visible: true,
selected: false,
bounds: Some([10.0, 10.0, 100.0, 20.0]),
slot: Some("inline-edit".into()),
};
let mut check = parse("");
check.expect = Expect::PaintsNamed;
for selector in [
"TEXTBOX:*PROJECT",
"rename proj*",
"#project-rename",
"@inline-edit",
] {
check.subject = selector.into();
verdict(&check, &[], std::slice::from_ref(&node)).unwrap_or_else(|error| {
panic!("{selector:?} did not use shared semantics: {error}")
});
}
}
#[test]
fn paints_named_rejects_a_box_translated_outside_the_viewport() {
let node = SemanticNode {
dom_id: None,
id: 7,
parent: None,
role: "heading".into(),
name: "Drawer outcome".into(),
value: None,
enabled: true,
focusable: false,
viewport_fixed: false,
visible: true,
selected: false,
bounds: Some([-384.0, 40.0, 336.0, 24.0]),
slot: None,
};
let mut check = parse("");
check.subject = "heading:Drawer outcome".into();
check.expect = Expect::PaintsNamed;
assert!(verdict(&check, &[], std::slice::from_ref(&node)).is_err());
let mut onscreen = node;
onscreen.bounds = Some([24.0, 40.0, 336.0, 24.0]);
assert!(verdict(&check, &[], &[onscreen]).is_ok());
}
#[test]
fn a_positioned_family_rejects_stacked_controls() {
let mut check = parse("");
check.subject = "radio:Theme color".into();
check.expect = Expect::DistinctPositions;
let node = |id, x, y| SemanticNode {
dom_id: None,
id,
parent: None,
role: "radio".into(),
name: format!("Theme color {id}"),
value: None,
enabled: true,
focusable: false,
viewport_fixed: false,
visible: true,
selected: false,
bounds: Some([x, y, 20.0, 20.0]),
slot: None,
};
assert!(verdict(&check, &[], &[node(1, 10.0, 10.0), node(2, 40.0, 10.0)]).is_ok());
let error = verdict(&check, &[], &[node(1, 10.0, 10.0), node(2, 10.0, 10.0)])
.expect_err("stacked controls are not a positioned family");
assert!(error.contains("only 1 distinct position"));
}
#[test]
fn a_rendered_family_must_stay_inside_its_comparison_box() {
let mut check = parse("compare:Some(\"group:Surface colour\"),");
check.subject = "radio:Theme color".into();
check.expect = Expect::ContainedBy;
let child = |id, x, y| SemanticNode {
dom_id: None,
id,
parent: Some(1),
role: "radio".into(),
name: format!("Theme color {id}"),
value: None,
enabled: true,
focusable: false,
viewport_fixed: false,
visible: true,
selected: false,
bounds: Some([x, y, 20.0, 20.0]),
slot: None,
};
let container = SemanticNode {
dom_id: None,
id: 1,
parent: None,
role: "group".into(),
name: "Surface colour".into(),
value: None,
enabled: true,
focusable: false,
viewport_fixed: false,
visible: true,
selected: false,
bounds: Some([10.0, 10.0, 190.0, 190.0]),
slot: None,
};
assert!(
verdict(
&check,
&[],
&[
container.clone(),
child(2, 20.0, 20.0),
child(3, 160.0, 160.0)
]
)
.is_ok()
);
let error = verdict(
&check,
&[],
&[container, child(2, 20.0, 20.0), child(3, 195.0, 195.0)],
)
.expect_err("a detached petal must fail containment");
assert!(error.contains("escapes \"group:Surface colour\""));
}
#[test]
fn vertical_center_alignment_compares_rendered_boxes() {
let mut check = parse("compare:Some(\"@adjustments\"),");
check.subject = "@color-wheel-flower".into();
check.expect = Expect::CenterAlignedY;
let node = |id, slot: &str, bounds| SemanticNode {
dom_id: None,
id,
parent: None,
role: "generic".into(),
name: String::new(),
value: None,
enabled: true,
focusable: false,
viewport_fixed: false,
visible: true,
selected: false,
bounds: Some(bounds),
slot: Some(slot.into()),
};
let wheel = node(1, "color-wheel-flower", [10.0, 110.0, 190.0, 190.0]);
let aligned = node(2, "adjustments", [220.0, 20.0, 400.0, 370.0]);
assert!(verdict(&check, &[], &[wheel.clone(), aligned]).is_ok());
let pinned_to_top = node(2, "adjustments", [220.0, 110.0, 400.0, 370.0]);
let error = verdict(&check, &[], &[wheel, pinned_to_top])
.expect_err("top-pinned wheel must fail vertical centering");
assert!(error.contains("not aligned"));
}
#[test]
fn enabled_requires_the_control_to_paint_and_accept_input() {
let mut check = parse("");
check.subject = "Save".into();
check.expect = Expect::Enabled;
let node = |enabled, bounds| SemanticNode {
dom_id: None,
id: 7,
parent: None,
role: "button".into(),
name: "Save".into(),
value: None,
enabled,
focusable: true,
viewport_fixed: false,
visible: true,
selected: false,
bounds,
slot: None,
};
assert!(verdict(&check, &[], &[node(true, Some([0.0, 0.0, 20.0, 20.0]))]).is_ok());
assert!(verdict(&check, &[], &[node(false, Some([0.0, 0.0, 20.0, 20.0]))]).is_err());
assert!(verdict(&check, &[], &[node(true, Some([0.0, 0.0, 0.0, 0.0]))]).is_err());
check.expect = Expect::Disabled;
assert!(verdict(&check, &[], &[node(false, Some([0.0, 0.0, 20.0, 20.0]))]).is_ok());
assert!(verdict(&check, &[], &[node(true, Some([0.0, 0.0, 20.0, 20.0]))]).is_err());
assert!(verdict(&check, &[], &[node(false, Some([0.0, 0.0, 0.0, 0.0]))]).is_err());
}
/// A primary call to action is unassertable on the host CI actually runs.
///
/// This is the shape both sites measured: a `w-full` button whose width
/// collapses to its label, so with no font catalogue it lays out `0x44`
/// while the very tree the check reads carries `enabled=true`. `Enabled`
/// and `Disabled` both refuse it on the box, so the state nobody disputes
/// cannot be asserted at all. One suite rewrote two checks to assert what
/// the button gates; another dropped to `Present` and lost the state.
#[test]
fn a_control_sized_by_its_label_can_still_be_judged_on_a_fontless_host() {
let cta = |enabled: bool, bounds| SemanticNode {
dom_id: None,
id: 41,
parent: None,
role: "button".into(),
name: "Continue".into(),
value: None,
enabled,
focusable: true,
viewport_fixed: false,
visible: true,
selected: false,
bounds,
slot: None,
};
// What a host with no font catalogue reports for that button.
let fontless = [cta(true, Some([24.0, 612.0, 0.0, 44.0]))];
let mut check = parse("");
check.subject = "button:Continue".into();
check.expect = Expect::Enabled;
let error = verdict(&check, &[], &fontless)
.expect_err("this is the gap: the flag is right and the box is empty");
assert!(
error.contains("text_sized"),
"the failure has to name the one-word fix, got {error:?}"
);
check.text_sized = true;
verdict(&check, &[], &fontless).expect("the tree carries the state the check asks about");
// And it still fails everywhere it should. A subject the document
// never produced is the case that matters most: an expectation that
// passes for a node which does not exist is worse than no expectation.
assert!(
verdict(&check, &[], &[]).is_err(),
"an absent control must still fail"
);
assert!(
verdict(&check, &[], &[cta(true, None)]).is_err(),
"a node that never reached layout must still fail"
);
assert!(
verdict(&check, &[], &[cta(false, Some([24.0, 612.0, 0.0, 44.0]))]).is_err(),
"only the box is given up, never the state"
);
// The same subject on a fonted host is unaffected either way.
let fonted = [cta(true, Some([24.0, 612.0, 328.0, 44.0]))];
verdict(&check, &[], &fonted).expect("a real box satisfies the weaker box test too");
check.text_sized = false;
verdict(&check, &[], &fonted).expect("the default meaning of Enabled has not moved");
// Disabled reads the flag on the same terms.
check.expect = Expect::Disabled;
check.text_sized = true;
verdict(&check, &[], &[cta(false, Some([24.0, 612.0, 0.0, 44.0]))])
.expect("a disabled text-sized control is assertable too");
assert!(verdict(&check, &[], &fontless).is_err());
}
/// The weakening is scoped to the verdicts it weakens.
///
/// Declared from a check file, so this also pins the spelling a suite
/// writes.
#[test]
fn text_sized_is_refused_where_it_would_relax_nothing() {
let mut check = parse("text_sized:true,");
assert!(check.text_sized, "the field is read from the check file");
check.expect = Expect::Paints;
let error = validate_check(&check, Path::new("cta.ron"), &mut HashMap::new())
.expect_err("Paints does not consult text_sized");
assert!(
error.contains("Present"),
"point at the answer, got {error:?}"
);
check.expect = Expect::Enabled;
validate_check(&check, Path::new("cta.ron"), &mut HashMap::new())
.expect("Enabled is one of the two verdicts it applies to");
}
#[test]
fn verdict_subjects_honor_role_qualified_names() {
let mut check = parse("");
check.subject = "button:Send".into();
check.expect = Expect::Disabled;
let node = |role: &str| SemanticNode {
dom_id: None,
id: 7,
parent: None,
role: role.into(),
name: "Send".into(),
value: None,
enabled: false,
focusable: false,
viewport_fixed: false,
visible: true,
selected: false,
bounds: Some([0.0, 0.0, 20.0, 20.0]),
slot: None,
};
assert!(verdict(&check, &[], &[node("button")]).is_ok());
assert!(verdict(&check, &[], &[node("textbox")]).is_err());
}
}