@@ -2,110 +2,58 @@ import {test, expect} from '@playwright/test'
2
2
import { visit } from '../test-helpers/storybook'
3
3
import { themes } from '../test-helpers/themes'
4
4
5
- test . describe ( 'BranchName' , ( ) => {
6
- test . describe ( 'Default' , ( ) => {
7
- for ( const theme of themes ) {
8
- test . describe ( theme , ( ) => {
9
- test ( 'default @vrt' , async ( { page} ) => {
10
- await visit ( page , {
11
- id : 'components-branchname--default' ,
12
- globals : {
13
- colorScheme : theme ,
14
- } ,
15
- } )
16
-
17
- // Default state
18
- expect ( await page . screenshot ( ) ) . toMatchSnapshot ( `BranchName.Default.${ theme } .png` )
19
-
20
- // Focus state
21
- await page . keyboard . press ( 'Tab' )
22
- expect ( await page . screenshot ( ) ) . toMatchSnapshot ( `BranchName.Default.${ theme } .focus.png` )
23
- } )
5
+ const stories = [
6
+ {
7
+ title : 'Default' ,
8
+ id : 'components-branchname--default' ,
9
+ focus : true ,
10
+ } ,
11
+ {
12
+ title : 'Not A Link' ,
13
+ id : 'components-branchname-features--not-a-link' ,
14
+ focus : false ,
15
+ } ,
16
+ {
17
+ title : 'With A Branch Icon' ,
18
+ id : 'components-branchname-features--with-branch-icon' ,
19
+ focus : false ,
20
+ } ,
21
+ ] as const
24
22
25
- test ( 'axe @aat' , async ( { page} ) => {
26
- await visit ( page , {
27
- id : 'components-branchname--default' ,
28
- globals : {
29
- colorScheme : theme ,
30
- } ,
31
- } )
32
- await expect ( page ) . toHaveNoViolations ( {
33
- rules : {
34
- 'color-contrast' : {
35
- enabled : theme !== 'dark_dimmed' ,
23
+ test . describe ( 'BranchName' , ( ) => {
24
+ for ( const story of stories ) {
25
+ test . describe ( story . title , ( ) => {
26
+ for ( const theme of themes ) {
27
+ test . describe ( theme , ( ) => {
28
+ test ( 'default @vrt' , async ( { page} ) => {
29
+ await visit ( page , {
30
+ id : story . id ,
31
+ globals : {
32
+ colorScheme : theme ,
36
33
} ,
37
- } ,
38
- } )
39
- } )
40
- } )
41
- }
42
- } )
43
-
44
- test . describe ( 'Not A Link' , ( ) => {
45
- for ( const theme of themes ) {
46
- test . describe ( theme , ( ) => {
47
- test ( 'default @vrt' , async ( { page} ) => {
48
- await visit ( page , {
49
- id : 'components-branchname-features--not-a-link' ,
50
- globals : {
51
- colorScheme : theme ,
52
- } ,
53
- } )
54
-
55
- // Default state
56
- expect ( await page . screenshot ( ) ) . toMatchSnapshot ( `BranchName.Not A Link.${ theme } .png` )
57
- } )
34
+ } )
58
35
59
- test ( 'axe @aat' , async ( { page} ) => {
60
- await visit ( page , {
61
- id : 'components-branchname-features--not-a-link' ,
62
- globals : {
63
- colorScheme : theme ,
64
- } ,
65
- } )
66
- await expect ( page ) . toHaveNoViolations ( {
67
- rules : {
68
- 'color-contrast' : {
69
- enabled : theme !== 'dark_dimmed' ,
70
- } ,
71
- } ,
72
- } )
73
- } )
74
- } )
75
- }
76
- } )
36
+ // Default state
37
+ expect ( await page . screenshot ( ) ) . toMatchSnapshot ( `BranchName.${ story . title } .${ theme } .png` )
77
38
78
- test . describe ( 'With A Branch Icon' , ( ) => {
79
- for ( const theme of themes ) {
80
- test . describe ( theme , ( ) => {
81
- test ( 'default @vrt' , async ( { page} ) => {
82
- await visit ( page , {
83
- id : 'components-branchname-features--with-branch-icon' ,
84
- globals : {
85
- colorScheme : theme ,
86
- } ,
39
+ // Focus state
40
+ if ( story . focus ) {
41
+ await page . keyboard . press ( 'Tab' )
42
+ expect ( await page . screenshot ( ) ) . toMatchSnapshot ( `BranchName.${ story . title } .${ theme } .focus.png` )
43
+ }
87
44
} )
88
45
89
- // Default state
90
- expect ( await page . screenshot ( ) ) . toMatchSnapshot ( `BranchName.With A Branch Icon.${ theme } .png` )
91
- } )
92
-
93
- test ( 'axe @aat' , async ( { page} ) => {
94
- await visit ( page , {
95
- id : 'components-branchname-features--with-branch-icon' ,
96
- globals : {
97
- colorScheme : theme ,
98
- } ,
99
- } )
100
- await expect ( page ) . toHaveNoViolations ( {
101
- rules : {
102
- 'color-contrast' : {
103
- enabled : theme !== 'dark_dimmed' ,
46
+ test ( 'axe @aat' , async ( { page} ) => {
47
+ await visit ( page , {
48
+ id : story . id ,
49
+ globals : {
50
+ colorScheme : theme ,
104
51
} ,
105
- } ,
52
+ } )
53
+ await expect ( page ) . toHaveNoViolations ( )
106
54
} )
107
55
} )
108
- } )
109
- }
110
- } )
56
+ }
57
+ } )
58
+ }
111
59
} )
0 commit comments