@@ -2,7 +2,7 @@ import { test, expect, settingsKey } from "../fixtures"
22import { closeDialog , openSettings } from "../actions"
33import {
44 settingsColorSchemeSelector ,
5- settingsFontSelector ,
5+ settingsCodeFontSelector ,
66 settingsLanguageSelectSelector ,
77 settingsNotificationsAgentSelector ,
88 settingsNotificationsErrorsSelector ,
@@ -12,6 +12,7 @@ import {
1212 settingsSoundsErrorsSelector ,
1313 settingsSoundsPermissionsSelector ,
1414 settingsThemeSelector ,
15+ settingsUIFontSelector ,
1516 settingsUpdatesStartupSelector ,
1617} from "../selectors"
1718
@@ -152,39 +153,199 @@ test("legacy oc-1 theme migrates to oc-2", async ({ page, gotoSession }) => {
152153 . toBeNull ( )
153154} )
154155
155- test ( "changing font persists in localStorage and updates CSS variable" , async ( { page, gotoSession } ) => {
156+ test ( "typing a code font with spaces persists and updates CSS variable" , async ( { page, gotoSession } ) => {
156157 await gotoSession ( )
157158
158159 const dialog = await openSettings ( page )
159- const select = dialog . locator ( settingsFontSelector )
160- await expect ( select ) . toBeVisible ( )
161-
162- const initialFontFamily = await page . evaluate ( ( ) => {
163- return getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-mono" )
164- } )
160+ const input = dialog . locator ( settingsCodeFontSelector )
161+ await expect ( input ) . toBeVisible ( )
162+ await expect ( input ) . toHaveAttribute ( "placeholder" , "IBM Plex Mono" )
163+
164+ const initialFontFamily = await page . evaluate ( ( ) =>
165+ getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-mono" ) . trim ( ) ,
166+ )
167+ const initialUIFamily = await page . evaluate ( ( ) =>
168+ getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-sans" ) . trim ( ) ,
169+ )
165170 expect ( initialFontFamily ) . toContain ( "IBM Plex Mono" )
166171
167- await select . locator ( '[data-slot="select-select-trigger"]' ) . click ( )
172+ const next = "Test Mono"
168173
169- const items = page . locator ( '[data-slot="select-select-item"]' )
170- await items . nth ( 2 ) . click ( )
174+ await input . click ( )
175+ await input . clear ( )
176+ await input . pressSequentially ( next )
177+ await expect ( input ) . toHaveValue ( next )
171178
172- await page . waitForTimeout ( 100 )
179+ await expect
180+ . poll ( async ( ) => {
181+ return await page . evaluate ( ( key ) => {
182+ const raw = localStorage . getItem ( key )
183+ return raw ? JSON . parse ( raw ) : null
184+ } , settingsKey )
185+ } )
186+ . toMatchObject ( {
187+ appearance : {
188+ font : next ,
189+ } ,
190+ } )
173191
174- const stored = await page . evaluate ( ( key ) => {
175- const raw = localStorage . getItem ( key )
176- return raw ? JSON . parse ( raw ) : null
177- } , settingsKey )
192+ const newFontFamily = await page . evaluate ( ( ) =>
193+ getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-mono" ) . trim ( ) ,
194+ )
195+ const newUIFamily = await page . evaluate ( ( ) =>
196+ getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-sans" ) . trim ( ) ,
197+ )
198+ expect ( newFontFamily ) . toContain ( next )
199+ expect ( newFontFamily ) . not . toBe ( initialFontFamily )
200+ expect ( newUIFamily ) . toBe ( initialUIFamily )
201+ } )
178202
179- expect ( stored ?. appearance ?. font ) . not . toBe ( "ibm-plex-mono" )
203+ test ( "typing a UI font with spaces persists and updates CSS variable" , async ( { page, gotoSession } ) => {
204+ await gotoSession ( )
180205
181- const newFontFamily = await page . evaluate ( ( ) => {
182- return getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-mono" )
183- } )
206+ const dialog = await openSettings ( page )
207+ const input = dialog . locator ( settingsUIFontSelector )
208+ await expect ( input ) . toBeVisible ( )
209+ await expect ( input ) . toHaveAttribute ( "placeholder" , "Inter" )
210+
211+ const initialFontFamily = await page . evaluate ( ( ) =>
212+ getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-sans" ) . trim ( ) ,
213+ )
214+ const initialCodeFamily = await page . evaluate ( ( ) =>
215+ getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-mono" ) . trim ( ) ,
216+ )
217+ expect ( initialFontFamily ) . toContain ( "Inter" )
218+
219+ const next = "Test Sans"
220+
221+ await input . click ( )
222+ await input . clear ( )
223+ await input . pressSequentially ( next )
224+ await expect ( input ) . toHaveValue ( next )
225+
226+ await expect
227+ . poll ( async ( ) => {
228+ return await page . evaluate ( ( key ) => {
229+ const raw = localStorage . getItem ( key )
230+ return raw ? JSON . parse ( raw ) : null
231+ } , settingsKey )
232+ } )
233+ . toMatchObject ( {
234+ appearance : {
235+ uiFont : next ,
236+ } ,
237+ } )
238+
239+ const newFontFamily = await page . evaluate ( ( ) =>
240+ getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-sans" ) . trim ( ) ,
241+ )
242+ const newCodeFamily = await page . evaluate ( ( ) =>
243+ getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-mono" ) . trim ( ) ,
244+ )
245+ expect ( newFontFamily ) . toContain ( next )
184246 expect ( newFontFamily ) . not . toBe ( initialFontFamily )
247+ expect ( newCodeFamily ) . toBe ( initialCodeFamily )
185248} )
186249
187- test ( "color scheme and font rehydrate after reload" , async ( { page, gotoSession } ) => {
250+ test ( "clearing the code font field restores the default placeholder and stack" , async ( { page, gotoSession } ) => {
251+ await gotoSession ( )
252+
253+ const dialog = await openSettings ( page )
254+ const input = dialog . locator ( settingsCodeFontSelector )
255+ await expect ( input ) . toBeVisible ( )
256+
257+ await input . click ( )
258+ await input . clear ( )
259+ await input . pressSequentially ( "Reset Mono" )
260+
261+ await expect
262+ . poll ( async ( ) => {
263+ return await page . evaluate ( ( key ) => {
264+ const raw = localStorage . getItem ( key )
265+ return raw ? JSON . parse ( raw ) : null
266+ } , settingsKey )
267+ } )
268+ . toMatchObject ( {
269+ appearance : {
270+ font : "Reset Mono" ,
271+ } ,
272+ } )
273+
274+ await input . clear ( )
275+ await input . press ( "Space" )
276+ await expect ( input ) . toHaveValue ( "" )
277+ await expect ( input ) . toHaveAttribute ( "placeholder" , "IBM Plex Mono" )
278+
279+ await expect
280+ . poll ( async ( ) => {
281+ return await page . evaluate ( ( key ) => {
282+ const raw = localStorage . getItem ( key )
283+ return raw ? JSON . parse ( raw ) : null
284+ } , settingsKey )
285+ } )
286+ . toMatchObject ( {
287+ appearance : {
288+ font : "" ,
289+ } ,
290+ } )
291+
292+ const fontFamily = await page . evaluate ( ( ) =>
293+ getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-mono" ) . trim ( ) ,
294+ )
295+ expect ( fontFamily ) . toContain ( "IBM Plex Mono" )
296+ expect ( fontFamily ) . not . toContain ( "Reset Mono" )
297+ } )
298+
299+ test ( "clearing the UI font field restores the default placeholder and stack" , async ( { page, gotoSession } ) => {
300+ await gotoSession ( )
301+
302+ const dialog = await openSettings ( page )
303+ const input = dialog . locator ( settingsUIFontSelector )
304+ await expect ( input ) . toBeVisible ( )
305+
306+ await input . click ( )
307+ await input . clear ( )
308+ await input . pressSequentially ( "Reset Sans" )
309+
310+ await expect
311+ . poll ( async ( ) => {
312+ return await page . evaluate ( ( key ) => {
313+ const raw = localStorage . getItem ( key )
314+ return raw ? JSON . parse ( raw ) : null
315+ } , settingsKey )
316+ } )
317+ . toMatchObject ( {
318+ appearance : {
319+ uiFont : "Reset Sans" ,
320+ } ,
321+ } )
322+
323+ await input . clear ( )
324+ await input . press ( "Space" )
325+ await expect ( input ) . toHaveValue ( "" )
326+ await expect ( input ) . toHaveAttribute ( "placeholder" , "Inter" )
327+
328+ await expect
329+ . poll ( async ( ) => {
330+ return await page . evaluate ( ( key ) => {
331+ const raw = localStorage . getItem ( key )
332+ return raw ? JSON . parse ( raw ) : null
333+ } , settingsKey )
334+ } )
335+ . toMatchObject ( {
336+ appearance : {
337+ uiFont : "" ,
338+ } ,
339+ } )
340+
341+ const fontFamily = await page . evaluate ( ( ) =>
342+ getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-sans" ) . trim ( ) ,
343+ )
344+ expect ( fontFamily ) . toContain ( "Inter" )
345+ expect ( fontFamily ) . not . toContain ( "Reset Sans" )
346+ } )
347+
348+ test ( "color scheme, code font, and UI font rehydrate after reload" , async ( { page, gotoSession } ) => {
188349 await gotoSession ( )
189350
190351 const dialog = await openSettings ( page )
@@ -195,31 +356,35 @@ test("color scheme and font rehydrate after reload", async ({ page, gotoSession
195356 await page . locator ( '[data-slot="select-select-item"]' ) . filter ( { hasText : "Dark" } ) . click ( )
196357 await expect ( page . locator ( "html" ) ) . toHaveAttribute ( "data-color-scheme" , "dark" )
197358
198- const fontSelect = dialog . locator ( settingsFontSelector )
199- await expect ( fontSelect ) . toBeVisible ( )
359+ const code = dialog . locator ( settingsCodeFontSelector )
360+ const ui = dialog . locator ( settingsUIFontSelector )
361+ await expect ( code ) . toBeVisible ( )
362+ await expect ( ui ) . toBeVisible ( )
200363
201- const initialFontFamily = await page . evaluate ( ( ) => {
202- return getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-mono" ) . trim ( )
203- } )
364+ const initialMono = await page . evaluate ( ( ) =>
365+ getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-mono" ) . trim ( ) ,
366+ )
367+ const initialSans = await page . evaluate ( ( ) =>
368+ getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-sans" ) . trim ( ) ,
369+ )
204370
205371 const initialSettings = await page . evaluate ( ( key ) => {
206372 const raw = localStorage . getItem ( key )
207373 return raw ? JSON . parse ( raw ) : null
208374 } , settingsKey )
209375
210- const currentFont =
211- ( await fontSelect . locator ( '[data-slot="select-select-trigger-value"]' ) . textContent ( ) ) ?. trim ( ) ?? ""
212- await fontSelect . locator ( '[data-slot="select-select-trigger"]' ) . click ( )
376+ const mono = initialSettings ?. appearance ?. font === "Reload Mono" ? "Reload Mono 2" : "Reload Mono"
377+ const sans = initialSettings ?. appearance ?. uiFont === "Reload Sans" ? "Reload Sans 2" : "Reload Sans"
213378
214- const fontItems = page . locator ( '[data-slot="select-select-item"]' )
215- expect ( await fontItems . count ( ) ) . toBeGreaterThan ( 1 )
379+ await code . click ( )
380+ await code . clear ( )
381+ await code . pressSequentially ( mono )
382+ await expect ( code ) . toHaveValue ( mono )
216383
217- if ( currentFont ) {
218- await fontItems . filter ( { hasNotText : currentFont } ) . first ( ) . click ( )
219- }
220- if ( ! currentFont ) {
221- await fontItems . nth ( 1 ) . click ( )
222- }
384+ await ui . click ( )
385+ await ui . clear ( )
386+ await ui . pressSequentially ( sans )
387+ await expect ( ui ) . toHaveValue ( sans )
223388
224389 await expect
225390 . poll ( async ( ) => {
@@ -230,7 +395,8 @@ test("color scheme and font rehydrate after reload", async ({ page, gotoSession
230395 } )
231396 . toMatchObject ( {
232397 appearance : {
233- font : expect . any ( String ) ,
398+ font : mono ,
399+ uiFont : sans ,
234400 } ,
235401 } )
236402
@@ -239,11 +405,18 @@ test("color scheme and font rehydrate after reload", async ({ page, gotoSession
239405 return raw ? JSON . parse ( raw ) : null
240406 } , settingsKey )
241407
242- const updatedFontFamily = await page . evaluate ( ( ) => {
243- return getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-mono" ) . trim ( )
244- } )
245- expect ( updatedFontFamily ) . not . toBe ( initialFontFamily )
246- expect ( updatedSettings ?. appearance ?. font ) . not . toBe ( initialSettings ?. appearance ?. font )
408+ const updatedMono = await page . evaluate ( ( ) =>
409+ getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-mono" ) . trim ( ) ,
410+ )
411+ const updatedSans = await page . evaluate ( ( ) =>
412+ getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-sans" ) . trim ( ) ,
413+ )
414+ expect ( updatedMono ) . toContain ( mono )
415+ expect ( updatedMono ) . not . toBe ( initialMono )
416+ expect ( updatedSans ) . toContain ( sans )
417+ expect ( updatedSans ) . not . toBe ( initialSans )
418+ expect ( updatedSettings ?. appearance ?. font ) . toBe ( mono )
419+ expect ( updatedSettings ?. appearance ?. uiFont ) . toBe ( sans )
247420
248421 await closeDialog ( page , dialog )
249422 await page . reload ( )
@@ -259,7 +432,8 @@ test("color scheme and font rehydrate after reload", async ({ page, gotoSession
259432 } )
260433 . toMatchObject ( {
261434 appearance : {
262- font : updatedSettings ?. appearance ?. font ,
435+ font : mono ,
436+ uiFont : sans ,
263437 } ,
264438 } )
265439
@@ -270,17 +444,32 @@ test("color scheme and font rehydrate after reload", async ({ page, gotoSession
270444
271445 await expect
272446 . poll ( async ( ) => {
273- return await page . evaluate ( ( ) => {
274- return getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-mono" ) . trim ( )
275- } )
447+ return await page . evaluate ( ( ) =>
448+ getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-mono" ) . trim ( ) ,
449+ )
276450 } )
277- . not . toBe ( initialFontFamily )
451+ . toContain ( mono )
278452
279- const rehydratedFontFamily = await page . evaluate ( ( ) => {
280- return getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-mono" ) . trim ( )
281- } )
282- expect ( rehydratedFontFamily ) . not . toBe ( initialFontFamily )
283- expect ( rehydratedSettings ?. appearance ?. font ) . toBe ( updatedSettings ?. appearance ?. font )
453+ await expect
454+ . poll ( async ( ) => {
455+ return await page . evaluate ( ( ) =>
456+ getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-sans" ) . trim ( ) ,
457+ )
458+ } )
459+ . toContain ( sans )
460+
461+ const rehydratedMono = await page . evaluate ( ( ) =>
462+ getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-mono" ) . trim ( ) ,
463+ )
464+ const rehydratedSans = await page . evaluate ( ( ) =>
465+ getComputedStyle ( document . documentElement ) . getPropertyValue ( "--font-family-sans" ) . trim ( ) ,
466+ )
467+ expect ( rehydratedMono ) . toContain ( mono )
468+ expect ( rehydratedMono ) . not . toBe ( initialMono )
469+ expect ( rehydratedSans ) . toContain ( sans )
470+ expect ( rehydratedSans ) . not . toBe ( initialSans )
471+ expect ( rehydratedSettings ?. appearance ?. font ) . toBe ( mono )
472+ expect ( rehydratedSettings ?. appearance ?. uiFont ) . toBe ( sans )
284473} )
285474
286475test ( "toggling notification agent switch updates localStorage" , async ( { page, gotoSession } ) => {
0 commit comments