11// @vitest -environment node
2- import { readFileSync } from "node:fs" ;
2+ import { mkdtempSync , readFileSync , rmSync , writeFileSync } from "node:fs" ;
3+ import { join } from "node:path" ;
34import { build } from "vite" ;
45import { describe , expect , it } from "vitest" ;
56
@@ -130,38 +131,51 @@ function getLastRuleBlock(selector: string) {
130131}
131132
132133async function buildRuntimeStylesheet ( ) {
133- const output = await build ( {
134- configFile : false ,
135- root : process . cwd ( ) ,
136- plugins : [ ] ,
137- build : {
138- write : false ,
139- outDir : "dist-test" ,
140- cssCodeSplit : true ,
141- rollupOptions : {
142- input : `${ process . cwd ( ) } /src/main.tsx` ,
143- } ,
144- } ,
145- resolve : {
146- alias : {
147- "@" : `${ process . cwd ( ) } /src` ,
134+ const tempDir = mkdtempSync ( join ( process . cwd ( ) , ".vite-style-build-" ) ) ;
135+ const entryFile = join ( tempDir , "runtime-entry.ts" ) ;
136+
137+ writeFileSync (
138+ entryFile ,
139+ [
140+ 'import buttonStyles from "../src/components/ui/button/index.module.css";' ,
141+ 'import tabsStyles from "../src/components/ui/tabs/index.module.css";' ,
142+ "void [buttonStyles.btn, tabsStyles.tab];" ,
143+ ] . join ( "\n" ) ,
144+ "utf8"
145+ ) ;
146+
147+ try {
148+ const output = await build ( {
149+ configFile : false ,
150+ root : process . cwd ( ) ,
151+ plugins : [ ] ,
152+ build : {
153+ write : false ,
154+ outDir : join ( tempDir , "dist" ) ,
155+ cssCodeSplit : true ,
156+ lib : {
157+ entry : entryFile ,
158+ formats : [ "es" ] ,
159+ } ,
148160 } ,
149- } ,
150- } ) ;
161+ } ) ;
151162
152- const bundle = Array . isArray ( output ) ? output [ 0 ] : output ;
153- const chunks = "output" in bundle ? bundle . output : [ ] ;
154- const cssAssets = chunks . filter (
155- ( chunk ) : chunk is { type : "asset" ; fileName : string ; source : string | Uint8Array } =>
156- chunk . type === "asset" && chunk . fileName . endsWith ( ".css" )
157- ) ;
163+ const bundle = Array . isArray ( output ) ? output [ 0 ] : output ;
164+ const chunks = "output" in bundle ? bundle . output : [ ] ;
165+ const cssAssets = chunks . filter (
166+ ( chunk ) : chunk is { type : "asset" ; fileName : string ; source : string | Uint8Array } =>
167+ chunk . type === "asset" && chunk . fileName . endsWith ( ".css" )
168+ ) ;
158169
159- expect ( cssAssets . length , "expected built CSS asset" ) . toBeGreaterThan ( 0 ) ;
160- return cssAssets
161- . map ( ( asset ) =>
162- typeof asset . source === "string" ? asset . source : Buffer . from ( asset . source ) . toString ( "utf8" )
163- )
164- . join ( "\n" ) ;
170+ expect ( cssAssets . length , "expected built CSS asset" ) . toBeGreaterThan ( 0 ) ;
171+ return cssAssets
172+ . map ( ( asset ) =>
173+ typeof asset . source === "string" ? asset . source : Buffer . from ( asset . source ) . toString ( "utf8" )
174+ )
175+ . join ( "\n" ) ;
176+ } finally {
177+ rmSync ( tempDir , { recursive : true , force : true } ) ;
178+ }
165179}
166180
167181describe ( "components.css theme-sensitive surfaces" , ( ) => {
@@ -447,10 +461,10 @@ describe("components.css theme-sensitive surfaces", () => {
447461 const sessionCard = getLastRuleBlock ( ".session-card" ) ;
448462 const activeSessionCard = getLastRuleBlock ( ".session-card.session-card--active" ) ;
449463 const activeSessionHeader = getLastRuleBlock (
450- ".session-card.session-card--active .session -header"
464+ ".session-card.session-card--active > .panel -header"
451465 ) ;
452466 const activeSessionTitle = getLastRuleBlock (
453- ".session-card.session-card--active .session-title "
467+ ".session-card.session-card--active > .panel-header .panel-header__title "
454468 ) ;
455469 const statusBar = getLastRuleBlock ( ".workspace-status-bar" ) ;
456470 const agentPanes = getLastRuleBlock ( ".workspace-main-stage > .agent-panes" ) ;
@@ -1725,6 +1739,7 @@ describe("components.css theme-sensitive surfaces", () => {
17251739 const progress = getLastRuleBlock ( ".mobile-shell__agent-stage .session-progress" ) ;
17261740 const header = getLastRuleBlock ( ".mobile-shell__agent-stage > .session-card > .panel-header" ) ;
17271741 const titleRow = getLastRuleBlock ( ".mobile-shell__agent-stage .session-title-row" ) ;
1742+ const headerRight = getLastRuleBlock ( ".mobile-shell__agent-stage .session-header-right" ) ;
17281743 const badges = getLastGroupedRuleBlock (
17291744 / \. m o b i l e - s h e l l _ _ a g e n t - s t a g e \. s e s s i o n - p r o v i d e r - b a d g e , \s * \. m o b i l e - s h e l l _ _ a g e n t - s t a g e \. s e s s i o n - s t a t e - b a d g e \s * \{ ( [ ^ } ] * ) \} / g
17301745 ) ;
@@ -1745,12 +1760,15 @@ describe("components.css theme-sensitive surfaces", () => {
17451760 expect ( header ) . toContain ( "border-bottom:" ) ;
17461761 expect ( header ) . not . toContain ( "linear-gradient(" ) ;
17471762 expect ( titleRow ) . toContain ( "gap: 6px" ) ;
1763+ expect ( headerRight ) . toContain ( "max-width: 100%" ) ;
1764+ expect ( headerRight ) . not . toContain ( "max-width: min(48%, 220px)" ) ;
17481765 expect ( hasRuleBlock ( ".mobile-shell__agent-stage .session-header" ) ) . toBe ( false ) ;
17491766 expect ( hasRuleBlock ( ".mobile-shell__agent-stage .session-header-left" ) ) . toBe ( false ) ;
17501767 expect ( hasRuleBlock ( ".mobile-shell__agent-stage .session-title" ) ) . toBe ( false ) ;
17511768 expect ( badges ) . toContain ( "height: 15px" ) ;
17521769 expect ( badges ) . toContain ( "border-radius: 3px" ) ;
17531770 expect ( supervisorBadge ) . toContain ( "min-height: 26px" ) ;
1771+ expect ( supervisorBadge ) . not . toContain ( "width: max-content" ) ;
17541772 expect ( supervisorBadge ) . toContain ( "border-radius: 4px" ) ;
17551773 expect ( supervisorBadge ) . not . toContain ( "border-radius: var(--radius-lg)" ) ;
17561774 expect ( supervisorLabel ) . toContain ( "font-size: var(--type-kicker-size)" ) ;
0 commit comments