@@ -2,90 +2,110 @@ import {test, expect} from '@playwright/test'
22import { visit } from '../test-helpers/storybook'
33import { themes } from '../test-helpers/themes'
44
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
22-
235test . 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 ,
33- primer_react_css_modules_team : true ,
34- } ,
35- } )
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+ } )
3616
37- // Default state
38- expect ( await page . screenshot ( ) ) . toMatchSnapshot ( `BranchName.${ story . title } .${ theme } .png` )
17+ // Default state
18+ expect ( await page . screenshot ( ) ) . toMatchSnapshot ( `BranchName.Default .${ theme } .png` )
3919
40- // Focus state
41- if ( story . focus ) {
42- await page . keyboard . press ( 'Tab' )
43- expect ( await page . screenshot ( ) ) . toMatchSnapshot ( `BranchName.${ story . title } .${ theme } .focus.png` )
44- }
45- } )
20+ // Focus state
21+ await page . keyboard . press ( 'Tab' )
22+ expect ( await page . screenshot ( ) ) . toMatchSnapshot ( `BranchName.Default.${ theme } .focus.png` )
23+ } )
4624
47- test ( 'default (styled-components) @vrt' , async ( { page} ) => {
48- await visit ( page , {
49- id : story . id ,
50- globals : {
51- colorScheme : theme ,
52- primer_react_css_modules_team : false ,
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' ,
5336 } ,
54- } )
55-
56- // Default state
57- expect ( await page . screenshot ( ) ) . toMatchSnapshot ( `BranchName.${ story . title } .${ theme } .png` )
37+ } ,
38+ } )
39+ } )
40+ } )
41+ }
42+ } )
5843
59- // Focus state
60- if ( story . focus ) {
61- await page . keyboard . press ( 'Tab' )
62- expect ( await page . screenshot ( ) ) . toMatchSnapshot ( `BranchName.${ story . title } .${ theme } .focus.png` )
63- }
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+ } ,
6453 } )
6554
66- test ( 'axe @aat' , async ( { page} ) => {
67- await visit ( page , {
68- id : story . id ,
69- globals : {
70- colorScheme : theme ,
71- primer_react_css_modules_team : true ,
55+ // Default state
56+ expect ( await page . screenshot ( ) ) . toMatchSnapshot ( `BranchName.Not A Link.${ theme } .png` )
57+ } )
58+
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' ,
7270 } ,
73- } )
74- await expect ( page ) . toHaveNoViolations ( )
71+ } ,
7572 } )
73+ } )
74+ } )
75+ }
76+ } )
7677
77- test ( 'axe (styled-components) @aat' , async ( { page} ) => {
78- await visit ( page , {
79- id : story . id ,
80- globals : {
81- colorScheme : theme ,
82- primer_react_css_modules_team : false ,
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+ } ,
87+ } )
88+
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' ,
83104 } ,
84- } )
85- await expect ( page ) . toHaveNoViolations ( )
105+ } ,
86106 } )
87107 } )
88- }
89- } )
90- }
108+ } )
109+ }
110+ } )
91111} )
0 commit comments