@@ -21,12 +21,22 @@ story("shows a running automatic compaction as one Compacting divider", async ({
2121 await expect ( message . locator ( '[data-component="text-part"]' ) ) . toHaveCount ( 0 )
2222} )
2323
24- story ( "opens a finished automatic compaction's summary from its divider" , async ( { mount } ) => {
24+ story ( "opens a finished automatic compaction's summary from its divider" , async ( { mount, page } ) => {
2525 const timeline = await mount ( `${ rows } --compaction-and-continuation` )
2626 const message = timeline . locator ( '[data-component="session-compaction-message"]' )
2727 const divider = message . locator ( '[data-slot="session-compaction-divider"]' )
2828 const summary = message . locator ( '[data-slot="session-compaction-summary"]' )
2929
30+ // The stem Compacting and Compacted share, then the ending that differs.
31+ const colors = ( ) =>
32+ message . locator ( '[data-slot="session-compaction-label"]' ) . evaluate ( ( label ) =>
33+ [ label . firstElementChild , label . querySelector ( '[data-slot="session-compaction-done"]' ) ] . map ( ( part ) => {
34+ if ( ! part ) throw new Error ( "Expected the label's stem and ending" )
35+
36+ return getComputedStyle ( part ) . color
37+ } ) ,
38+ )
39+
3040 // Loaded with the history, so it is already there rather than fading in.
3141 await expect ( message ) . not . toHaveAttribute ( "data-enter" )
3242 await expect ( divider ) . toHaveAttribute ( "data-state" , "done" )
@@ -35,12 +45,22 @@ story("opens a finished automatic compaction's summary from its divider", async
3545 await expect ( divider ) . toHaveAttribute ( "aria-expanded" , "false" )
3646 await expect ( divider ) . not . toHaveAttribute ( "aria-controls" )
3747 await expect ( summary ) . toHaveCount ( 0 )
48+ const [ rest ] = await colors ( )
49+
50+ // Hovering lights the whole word, not only the ending.
51+ await divider . hover ( )
52+ await expect . poll ( async ( ) => ( await colors ( ) ) [ 0 ] ) . not . toBe ( rest )
53+ await expect . poll ( async ( ) => new Set ( await colors ( ) ) . size ) . toBe ( 1 )
3854
3955 await divider . click ( )
4056 await expect ( divider ) . toHaveAttribute ( "aria-expanded" , "true" )
4157 await expect ( summary ) . toContainText ( "The Session timeline now consumes current nested assistant content." )
4258 await expect ( summary ) . toContainText ( "11.9K in · 508 out" )
4359 await expect ( divider ) . toHaveAttribute ( "aria-controls" , ( await summary . getAttribute ( "id" ) ) ?? "" )
60+ // An open divider keeps the whole word lit once the pointer leaves.
61+ await page . mouse . move ( 0 , 0 )
62+ await expect . poll ( async ( ) => ( await colors ( ) ) [ 0 ] ) . not . toBe ( rest )
63+ await expect . poll ( async ( ) => new Set ( await colors ( ) ) . size ) . toBe ( 1 )
4464
4565 await divider . click ( )
4666 await expect ( divider ) . toHaveAttribute ( "aria-expanded" , "false" )
@@ -127,6 +147,46 @@ story("warms the label only once the gathering light reaches it", async ({ mount
127147 expect ( cooled ) . toEqual ( [ 0 , 0 ] )
128148} )
129149
150+ story ( "splits a translated label between whole characters" , async ( { mount } ) => {
151+ // Bengali's two words part at a vowel sign, which draws a dotted circle when it is cut from its consonant.
152+ const timeline = await mount ( `${ rows } --compaction-and-continuation` , { globals : { locale : "bn" } } )
153+ const message = timeline . locator ( '[data-component="session-compaction-message"]' )
154+
155+ await expect ( message . locator ( '[data-slot="session-compaction-divider"]' ) ) . toHaveAccessibleName ( "সংকুচিত হয়েছে" )
156+ await expect ( message . locator ( '[data-slot="session-compaction-done"]' ) ) . toHaveText ( / ^ \P{ M} / u)
157+ } )
158+
159+ story ( "keeps the space where a translated label splits" , async ( { mount, page } ) => {
160+ // Hindi's two phrases part after a space, which a label split into boxes drops unless it keeps its white space.
161+ const timeline = await mount ( `${ rows } --compaction-and-continuation` , { globals : { locale : "hi" } } )
162+ const label = timeline . locator ( '[data-slot="session-compaction-label"]' )
163+ await expect ( timeline . locator ( '[data-slot="session-compaction-divider"]' ) ) . toHaveAccessibleName ( "संक्षिप्त किया गया" )
164+ await page . evaluate ( ( ) => document . fonts . ready . then ( ( ) => undefined ) )
165+
166+ // The label's two parts against the same phrase set as one run of text beside it.
167+ const [ split , whole ] = await label . evaluate ( ( element ) => {
168+ const stem = element . firstElementChild
169+ const ending = element . querySelector ( '[data-slot="session-compaction-done"]' )
170+ const copy = element . cloneNode ( false )
171+
172+ if ( ! stem || ! ending || ! ( copy instanceof HTMLElement ) ) throw new Error ( "Expected the label's stem and ending" )
173+ copy . textContent = element . closest ( "button" ) ?. getAttribute ( "aria-label" ) ?? ""
174+ element . after ( copy )
175+
176+ const widths = [
177+ stem . getBoundingClientRect ( ) . width + ending . getBoundingClientRect ( ) . width ,
178+ copy . getBoundingClientRect ( ) . width ,
179+ ]
180+
181+ copy . remove ( )
182+
183+ return widths
184+ } )
185+
186+ expect ( whole ) . toBeGreaterThan ( 0 )
187+ expect ( Math . abs ( split - whole ) ) . toBeLessThan ( 1 )
188+ } )
189+
130190story ( "keeps the full record for a manual compaction" , async ( { mount } ) => {
131191 const timeline = await mount ( `${ rows } --compaction-manual` )
132192 const message = timeline . locator ( '[data-component="session-compaction-message"]' )
0 commit comments