@@ -8,9 +8,11 @@ for (const system of ['light', 'dark']) {
88 const toggle = page . getByRole ( 'button' , { name : 'Dark mode' , exact : true } ) ;
99 await expect ( page . locator ( 'html' ) ) . toHaveCSS ( 'color-scheme' , system ) ;
1010 await expect ( toggle ) . toHaveAttribute ( 'aria-pressed' , String ( system === 'dark' ) ) ;
11+ await expect ( page . locator ( '[data-favicon]' ) ) . toHaveAttribute ( 'href' , `assets/favicon${ system === 'dark' ? '-dark' : '' } -32.png?v=2` ) ;
1112
1213 await page . emulateMedia ( { colorScheme : other } ) ;
1314 await expect ( page . locator ( 'html' ) ) . toHaveCSS ( 'color-scheme' , other ) ;
15+ await expect ( page . locator ( '[data-favicon]' ) ) . toHaveAttribute ( 'href' , `assets/favicon${ other === 'dark' ? '-dark' : '' } -32.png?v=2` ) ;
1416 await page . emulateMedia ( { colorScheme : system } ) ;
1517 await expect ( page . locator ( 'html' ) ) . toHaveCSS ( 'color-scheme' , system ) ;
1618
@@ -24,6 +26,7 @@ for (const system of ['light', 'dark']) {
2426 await page . emulateMedia ( { colorScheme : system } ) ;
2527 await expect ( page . locator ( 'html' ) ) . toHaveCSS ( 'color-scheme' , other ) ;
2628 await expect ( page . locator ( 'meta[name="theme-color"]' ) ) . toHaveAttribute ( 'content' , other === 'dark' ? '#0d0f12' : '#ffffff' ) ;
29+ await expect ( page . locator ( '[data-favicon]' ) ) . toHaveAttribute ( 'href' , `assets/favicon${ system === 'dark' ? '-dark' : '' } -32.png?v=2` ) ;
2730 } ) ;
2831}
2932
@@ -59,7 +62,11 @@ test('approved products, sharing assets and responsive navigation work in both t
5962 expect ( await page . evaluate ( ( ) => document . documentElement . scrollWidth <= innerWidth ) ) . toBe ( true ) ;
6063 await expect ( page . getByRole ( 'button' , { name : 'Dark mode' , exact : true } ) ) . toBeInViewport ( ) ;
6164 }
62- await page . getByRole ( 'link' , { name : 'Find a tool' , exact : false } ) . click ( ) ;
65+ await expect ( page . locator ( '.hero' ) . getByRole ( 'link' ) ) . toHaveCount ( 1 ) ;
66+ await expect ( page . locator ( '.hero' ) . getByRole ( 'link' ) ) . toHaveAccessibleName ( 'View on GitHub' ) ;
67+ await expect ( page . locator ( '.hero' ) . getByRole ( 'link' ) ) . toHaveAttribute ( 'href' , 'https://github.com/sqlstack-io/sqlstack' ) ;
68+ await page . getByRole ( 'link' , { name : 'Skip to tools' , exact : true } ) . focus ( ) ;
69+ await page . keyboard . press ( 'Enter' ) ;
6370 await expect ( page ) . toHaveURL ( / # t o o l s $ / ) ;
6471 await page . keyboard . press ( 'Tab' ) ;
6572 await expect ( page . getByRole ( 'link' , { name : 'SQLBuild website' , exact : true } ) ) . toBeFocused ( ) ;
@@ -75,6 +82,7 @@ test('approved products, sharing assets and responsive navigation work in both t
7582 [ '/assets/og-sqlstack-dark.png' , 1200 , 630 ] ,
7683 [ '/assets/favicon-16.png' , 16 , 16 ] ,
7784 [ '/assets/favicon-32.png' , 32 , 32 ] ,
85+ [ '/assets/favicon-dark-32.png' , 32 , 32 ] ,
7886 [ '/assets/apple-touch-icon.png' , 180 , 180 ] ,
7987 ] ) {
8088 const response = await request . get ( path ) ;
@@ -90,4 +98,25 @@ test('approved products, sharing assets and responsive navigation work in both t
9098 expect ( ico . readUInt16LE ( 2 ) ) . toBe ( 1 ) ;
9199 expect ( ico . readUInt16LE ( 4 ) ) . toBe ( 3 ) ;
92100 expect ( [ ico [ 6 ] , ico [ 22 ] , ico [ 38 ] ] ) . toEqual ( [ 16 , 32 , 48 ] ) ;
101+
102+ for ( const path of [ '/assets/favicon-16.png' , '/assets/favicon-32.png' , '/assets/favicon-dark-32.png' , '/favicon.ico' ] ) {
103+ const pixels = await page . evaluate ( async ( src ) => {
104+ const image = new Image ( ) ;
105+ image . src = src ;
106+ await image . decode ( ) ;
107+ const canvas = document . createElement ( 'canvas' ) ;
108+ canvas . width = image . naturalWidth ;
109+ canvas . height = image . naturalHeight ;
110+ const context = canvas . getContext ( '2d' ) ;
111+ context . drawImage ( image , 0 , 0 ) ;
112+ const data = context . getImageData ( 0 , 0 , canvas . width , canvas . height ) . data ;
113+ const corners = [ 0 , canvas . width - 1 , canvas . width * ( canvas . height - 1 ) , canvas . width * canvas . height - 1 ] ;
114+ return {
115+ corners : corners . map ( ( pixel ) => data [ pixel * 4 + 3 ] ) ,
116+ opaquePixels : Array . from ( data ) . filter ( ( value , index ) => index % 4 === 3 && value === 255 ) . length ,
117+ } ;
118+ } , path ) ;
119+ expect ( pixels . corners , path ) . toEqual ( [ 0 , 0 , 0 , 0 ] ) ;
120+ expect ( pixels . opaquePixels , path ) . toBeGreaterThan ( 0 ) ;
121+ }
93122} ) ;
0 commit comments