@@ -25,7 +25,6 @@ async function run() {
2525
2626 const extensionId = new URL ( serviceWorker . url ( ) ) . host ;
2727 const dashboardUrl = `chrome-extension://${ extensionId } /ui/dashboard.html` ;
28- const settingsUrl = `chrome-extension://${ extensionId } /ui/settings.html` ;
2928 const panelUrl = `chrome-extension://${ extensionId } /ui/panel.html` ;
3029
3130 const dashboardPage = await context . newPage ( ) ;
@@ -45,9 +44,51 @@ async function run() {
4544 await panelPage . goto ( panelUrl , { waitUntil : "domcontentloaded" } ) ;
4645 const panelViewCount = await panelPage . locator ( '[data-view]' ) . count ( ) ;
4746
48- const settingsPage = await context . newPage ( ) ;
49- await settingsPage . goto ( settingsUrl , { waitUntil : "domcontentloaded" } ) ;
50- const settingsHeading = await settingsPage . textContent ( "h1" ) ;
47+ await dashboardPage . click ( "#theme-toggle" ) ;
48+ await dashboardPage . waitForTimeout ( 250 ) ;
49+ const dashboardThemeAfterToggle = await dashboardPage . getAttribute ( "body" , "data-theme" ) ;
50+
51+ await dashboardPage . click ( "#open-settings" ) ;
52+ await dashboardPage . waitForURL ( ( url ) => url . toString ( ) . endsWith ( "/ui/settings.html" ) , { timeout : 5_000 } ) ;
53+ const settingsHeading = await dashboardPage . textContent ( "h1" ) ;
54+ const settingsOpenedInCurrentTab = dashboardPage . url ( ) . endsWith ( "/ui/settings.html" ) ;
55+ const settingsTheme = await dashboardPage . getAttribute ( "body" , "data-theme" ) ;
56+ const settingsThemeValue = await dashboardPage . inputValue ( "#theme" ) ;
57+ const themeSelectContrast = await dashboardPage . evaluate ( ( ) => {
58+ const select = document . querySelector ( "#theme" ) ;
59+ if ( ! select ) {
60+ return 0 ;
61+ }
62+
63+ const parseRgb = ( value ) => {
64+ const matches = String ( value ) . match ( / \d + ( \. \d + ) ? / g) ;
65+ if ( ! matches || matches . length < 3 ) {
66+ return [ 0 , 0 , 0 ] ;
67+ }
68+ return matches . slice ( 0 , 3 ) . map ( ( part ) => Number ( part ) ) ;
69+ } ;
70+
71+ const luminance = ( [ r , g , b ] ) => {
72+ const toLinear = ( channel ) => {
73+ const value = channel / 255 ;
74+ if ( value <= 0.03928 ) {
75+ return value / 12.92 ;
76+ }
77+ return ( ( value + 0.055 ) / 1.055 ) ** 2.4 ;
78+ } ;
79+
80+ return 0.2126 * toLinear ( r ) + 0.7152 * toLinear ( g ) + 0.0722 * toLinear ( b ) ;
81+ } ;
82+
83+ const styles = window . getComputedStyle ( select ) ;
84+ const fg = parseRgb ( styles . color ) ;
85+ const bg = parseRgb ( styles . backgroundColor ) ;
86+ const l1 = luminance ( fg ) ;
87+ const l2 = luminance ( bg ) ;
88+ const lighter = Math . max ( l1 , l2 ) ;
89+ const darker = Math . min ( l1 , l2 ) ;
90+ return Number ( ( ( lighter + 0.05 ) / ( darker + 0.05 ) ) . toFixed ( 2 ) ) ;
91+ } ) ;
5192
5293 const result = {
5394 extensionId,
@@ -61,7 +102,12 @@ async function run() {
61102 paused : status ?. paused ,
62103 sidePanelApiAvailable : status ?. sidePanelApiAvailable ,
63104 openPanelOnActionClick : status ?. openPanelOnActionClick ,
64- settingsHeading
105+ settingsHeading,
106+ settingsOpenedInCurrentTab,
107+ dashboardThemeAfterToggle,
108+ settingsTheme,
109+ settingsThemeValue,
110+ themeSelectContrast
65111 } ;
66112
67113 console . log ( JSON . stringify ( result , null , 2 ) ) ;
@@ -76,6 +122,11 @@ async function run() {
76122 result . runtimeStatusOk !== true ||
77123 result . sidePanelApiAvailable !== true ||
78124 result . openPanelOnActionClick !== true ||
125+ result . settingsOpenedInCurrentTab !== true ||
126+ result . dashboardThemeAfterToggle !== "light" ||
127+ result . settingsTheme !== "light" ||
128+ result . settingsThemeValue !== "light" ||
129+ Number ( result . themeSelectContrast || 0 ) < 4.5 ||
79130 result . settingsHeading !== "Settings"
80131 ) {
81132 process . exitCode = 1 ;
0 commit comments