@@ -3,10 +3,9 @@ import { describe, expect, it } from "vite-plus/test";
33import "~/index.css" ;
44import { applyAppearanceFontVariables } from "./appearanceFonts" ;
55
6- function composerFontSize ( ) : string {
6+ function renderedFontSize ( style : ( probe : HTMLElement ) => void ) : string {
77 const probe = document . createElement ( "div" ) ;
8- // The composer editor's own size class.
9- probe . className = "text-(length:--font-size-prompt,var(--text-sm))" ;
8+ style ( probe ) ;
109 document . body . append ( probe ) ;
1110 try {
1211 return getComputedStyle ( probe ) . fontSize ;
@@ -15,6 +14,17 @@ function composerFontSize(): string {
1514 }
1615}
1716
17+ const composerFontSize = ( ) =>
18+ renderedFontSize ( ( probe ) => {
19+ // The composer editor's own size class.
20+ probe . className = "text-(length:--font-size-prompt,var(--text-sm))" ;
21+ } ) ;
22+
23+ const touchComposerFontSize = ( ) =>
24+ renderedFontSize ( ( probe ) => {
25+ probe . style . fontSize = "var(--font-size-prompt-touch)" ;
26+ } ) ;
27+
1828describe ( "applyAppearanceFontVariables" , ( ) => {
1929 it ( "sizes the composer from the interface size until fonts are set separately" , ( ) => {
2030 const root = document . documentElement ;
@@ -31,9 +41,12 @@ describe("applyAppearanceFontVariables", () => {
3141 try {
3242 applyAppearanceFontVariables ( root , { ...preferences , separate : false } ) ;
3343 expect ( composerFontSize ( ) ) . toBe ( "17.5px" ) ;
44+ expect ( touchComposerFontSize ( ) ) . toBe ( "17.5px" ) ;
3445
3546 applyAppearanceFontVariables ( root , { ...preferences , separate : true } ) ;
3647 expect ( composerFontSize ( ) ) . toBe ( "14px" ) ;
48+ // iOS zooms into inputs under 16px.
49+ expect ( touchComposerFontSize ( ) ) . toBe ( "16px" ) ;
3750 } finally {
3851 if ( style === null ) root . removeAttribute ( "style" ) ;
3952 else root . setAttribute ( "style" , style ) ;
0 commit comments