@lullabot/playwright-testing 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/bin/github-a11y-summary +2 -2
  2. package/bin/github-failure-summary +4 -4
  3. package/lib/accessibility-baseline-file.d.ts +6 -6
  4. package/lib/accessibility-baseline-file.js +29 -23
  5. package/lib/accessibility-baseline.js +5 -3
  6. package/lib/accessible-screenshot.d.ts +4 -4
  7. package/lib/accessible-screenshot.js +110 -88
  8. package/lib/focus.js +4 -1
  9. package/lib/frames.js +4 -4
  10. package/lib/github/a11y-summary.js +74 -79
  11. package/lib/github/attachments.d.ts +1 -1
  12. package/lib/github/attachments.js +36 -34
  13. package/lib/github/failure-summary.d.ts +4 -4
  14. package/lib/github/failure-summary.js +140 -108
  15. package/lib/github/index.d.ts +6 -6
  16. package/lib/github/report-paths.js +17 -9
  17. package/lib/hover.js +17 -17
  18. package/lib/images.js +15 -12
  19. package/lib/index.d.ts +13 -13
  20. package/lib/interaction-states.d.ts +2 -2
  21. package/lib/interaction-states.js +7 -7
  22. package/lib/mock/index.d.ts +1 -1
  23. package/lib/mock/youtube.d.ts +1 -1
  24. package/lib/mock/youtube.js +1 -1
  25. package/lib/pseudo-state.d.ts +2 -2
  26. package/lib/pseudo-state.js +15 -7
  27. package/lib/videos.js +21 -10
  28. package/lib/visualdiff.d.ts +4 -4
  29. package/lib/visualdiff.js +35 -27
  30. package/package.json +3 -3
  31. package/src/accessibility-baseline-file.test.ts +190 -154
  32. package/src/accessibility-baseline-file.ts +107 -83
  33. package/src/accessibility-baseline.test.ts +869 -433
  34. package/src/accessibility-baseline.ts +41 -21
  35. package/src/accessible-screenshot.test.ts +551 -423
  36. package/src/accessible-screenshot.ts +358 -251
  37. package/src/focus.test.ts +23 -23
  38. package/src/focus.ts +7 -2
  39. package/src/fonts.test.ts +13 -13
  40. package/src/fonts.ts +1 -1
  41. package/src/frames.test.ts +10 -8
  42. package/src/frames.ts +5 -5
  43. package/src/github/a11y-summary.test.ts +436 -332
  44. package/src/github/a11y-summary.ts +189 -179
  45. package/src/github/attachments.test.ts +228 -167
  46. package/src/github/attachments.ts +144 -121
  47. package/src/github/failure-summary.test.ts +660 -445
  48. package/src/github/failure-summary.ts +376 -274
  49. package/src/github/index.test.ts +14 -14
  50. package/src/github/index.ts +6 -6
  51. package/src/github/report-paths.test.ts +211 -156
  52. package/src/github/report-paths.ts +75 -61
  53. package/src/hover.test.ts +50 -46
  54. package/src/hover.ts +18 -18
  55. package/src/images.test.ts +251 -206
  56. package/src/images.ts +52 -43
  57. package/src/index.ts +13 -13
  58. package/src/interaction-states.test.ts +72 -42
  59. package/src/interaction-states.ts +43 -29
  60. package/src/mock/index.ts +1 -1
  61. package/src/mock/youtube.test.ts +26 -26
  62. package/src/mock/youtube.ts +4 -6
  63. package/src/pseudo-state.test.ts +58 -51
  64. package/src/pseudo-state.ts +32 -27
  65. package/src/videos.test.ts +559 -399
  66. package/src/videos.ts +68 -44
  67. package/src/visualdiff.test.ts +416 -315
  68. package/src/visualdiff.ts +140 -99
@@ -1,19 +1,21 @@
1
1
  export interface AccessibilityBaselineEntry {
2
2
  /** axe rule ID (e.g. 'color-contrast') */
3
- rule: string
3
+ rule: string;
4
4
  /** CSS selectors for the elements with this violation */
5
- targets: string[]
5
+ targets: string[];
6
6
  /** Why this violation is accepted */
7
- reason: string
7
+ reason: string;
8
8
  /** Link to tracking ticket */
9
- willBeFixedIn: string
9
+ willBeFixedIn: string;
10
10
  }
11
11
 
12
- export type AccessibilityBaseline = AccessibilityBaselineEntry[]
12
+ export type AccessibilityBaseline = AccessibilityBaselineEntry[];
13
13
 
14
- export function defineAccessibilityBaseline(entries: AccessibilityBaseline): AccessibilityBaseline {
15
- validateAccessibilityBaseline(entries)
16
- return entries
14
+ export function defineAccessibilityBaseline(
15
+ entries: AccessibilityBaseline,
16
+ ): AccessibilityBaseline {
17
+ validateAccessibilityBaseline(entries);
18
+ return entries;
17
19
  }
18
20
 
19
21
  /**
@@ -22,29 +24,47 @@ export function defineAccessibilityBaseline(entries: AccessibilityBaseline): Acc
22
24
  * Seed files deliberately contain TODO placeholders, so callers validate only
23
25
  * committed/in-code baselines, not a seed during the local creation run.
24
26
  */
25
- export function validateAccessibilityBaseline(entries: AccessibilityBaseline): void {
26
- const seen = new Set<string>()
27
+ export function validateAccessibilityBaseline(
28
+ entries: AccessibilityBaseline,
29
+ ): void {
30
+ const seen = new Set<string>();
27
31
 
28
32
  entries.forEach((entry, index) => {
29
33
  if (!entry.rule.trim()) {
30
- throw new Error(`Accessibility baseline entry ${index + 1} requires a rule.`)
34
+ throw new Error(
35
+ `Accessibility baseline entry ${index + 1} requires a rule.`,
36
+ );
31
37
  }
32
- if (entry.targets.length === 0 || entry.targets.some(target => !target.trim())) {
33
- throw new Error(`Accessibility baseline entry ${index + 1} requires at least one non-empty target.`)
38
+ if (
39
+ entry.targets.length === 0 ||
40
+ entry.targets.some((target) => !target.trim())
41
+ ) {
42
+ throw new Error(
43
+ `Accessibility baseline entry ${index + 1} requires at least one non-empty target.`,
44
+ );
34
45
  }
35
- if (!entry.reason.trim() || entry.reason.trim().toUpperCase() === 'TODO') {
36
- throw new Error(`Accessibility baseline entry ${index + 1} requires a reason.`)
46
+ if (!entry.reason.trim() || entry.reason.trim().toUpperCase() === "TODO") {
47
+ throw new Error(
48
+ `Accessibility baseline entry ${index + 1} requires a reason.`,
49
+ );
37
50
  }
38
- if (!entry.willBeFixedIn.trim() || entry.willBeFixedIn.trim().toUpperCase() === 'TODO') {
39
- throw new Error(`Accessibility baseline entry ${index + 1} requires a willBeFixedIn tracking reference.`)
51
+ if (
52
+ !entry.willBeFixedIn.trim() ||
53
+ entry.willBeFixedIn.trim().toUpperCase() === "TODO"
54
+ ) {
55
+ throw new Error(
56
+ `Accessibility baseline entry ${index + 1} requires a willBeFixedIn tracking reference.`,
57
+ );
40
58
  }
41
59
 
42
60
  for (const target of new Set(entry.targets)) {
43
- const key = JSON.stringify([entry.rule, target])
61
+ const key = JSON.stringify([entry.rule, target]);
44
62
  if (seen.has(key)) {
45
- throw new Error(`Accessibility baseline contains a duplicate waiver for ${entry.rule} on ${target}.`)
63
+ throw new Error(
64
+ `Accessibility baseline contains a duplicate waiver for ${entry.rule} on ${target}.`,
65
+ );
46
66
  }
47
- seen.add(key)
67
+ seen.add(key);
48
68
  }
49
- })
69
+ });
50
70
  }