@@ -10,73 +10,106 @@ import {
1010const suite = createChatFlowE2eSuite ( ) ;
1111
1212suite . define ( ( ) => {
13- it . each ( [
14- {
15- name : "explicit lines" ,
16- text : Array . from ( { length : 8 } , ( _ , index ) => `Prompt line ${ index + 1 } ` ) . join ( "\n" ) ,
13+ it ( "keeps seven short lines fully visible" , async ( ) => {
14+ const text = [
15+ "please re-review these:" ,
16+ "#127818" ,
17+ "#127826" ,
18+ "#127844" ,
19+ "#127881" ,
20+ "" ,
21+ "rerun the same session we had for these" ,
22+ ] . join ( "\n" ) ;
23+ const context = await suite . newBrowserContext ( {
24+ locale : "en-US" ,
25+ serviceWorkers : "block" ,
1726 viewport : { height : 900 , width : 1280 } ,
18- } ,
19- {
20- name : "soft-wrapped text" ,
21- text : `${ "This prompt remains mounted while its narrow visual preview is clamped. " . repeat ( 7 ) } Final prompt tail.` ,
22- viewport : { height : 844 , width : 390 } ,
23- } ,
24- ] as const ) (
25- "clamps $name to five lines and toggles the complete prompt" ,
26- async ( { name, text, viewport } ) => {
27- const context = await suite . newBrowserContext ( {
28- locale : "en-US" ,
29- serviceWorkers : "block" ,
30- viewport,
31- } ) ;
32- const page = await context . newPage ( ) ;
33- await installMockGateway ( page , {
34- historyMessages : [ { role : "user" , content : [ { type : "text" , text } ] , timestamp : 1 } ] ,
35- } ) ;
27+ } ) ;
28+ const page = await context . newPage ( ) ;
29+ await installMockGateway ( page , {
30+ historyMessages : [ { role : "user" , content : [ { type : "text" , text } ] , timestamp : 1 } ] ,
31+ } ) ;
3632
37- try {
38- await page . goto ( `${ suite . server . baseUrl } chat` ) ;
39- const bubble = page . locator ( ".chat-group.user .chat-bubble" ) ;
40- await bubble . waitFor ( { state : "visible" , timeout : 10_000 } ) ;
41- const content = bubble . locator ( ".chat-message-disclosure__content" ) ;
42- const toggle = bubble . getByRole ( "button" , { name : "Show more" } ) ;
33+ try {
34+ await page . goto ( `${ suite . server . baseUrl } chat` ) ;
35+ const bubble = page . locator ( ".chat-group.user .chat-bubble" ) ;
36+ await bubble . waitFor ( { state : "visible" , timeout : 10_000 } ) ;
37+ const proofDir = path . join (
38+ process . cwd ( ) ,
39+ ".artifacts" ,
40+ "control-ui-e2e" ,
41+ "user-bubble-clamp" ,
42+ ) ;
43+ if ( captureUiProofEnabled ) {
44+ await mkdir ( proofDir , { recursive : true } ) ;
45+ await bubble . screenshot ( { path : path . join ( proofDir , "short-message.png" ) } ) ;
46+ }
4347
44- expect ( await toggle . getAttribute ( "aria-expanded" ) ) . toBe ( "false" ) ;
45- expect ( await content . evaluate ( ( element ) => getComputedStyle ( element ) . webkitLineClamp ) ) . toBe (
46- "5" ,
47- ) ;
48- expect ( await content . textContent ( ) ) . toContain ( text . slice ( - 18 ) ) ;
49- const collapsedHeight = await content . evaluate ( ( element ) => element . clientHeight ) ;
50- expect (
51- await content . evaluate ( ( element ) => element . scrollHeight > element . clientHeight ) ,
52- ) . toBe ( true ) ;
53- const proofDir = path . join (
54- process . cwd ( ) ,
55- ".artifacts" ,
56- "control-ui-e2e" ,
57- "user-bubble-disclosure" ,
58- ) ;
59- const proofName = name . replaceAll ( " " , "-" ) ;
60- if ( captureUiProofEnabled ) {
61- await mkdir ( proofDir , { recursive : true } ) ;
62- await bubble . screenshot ( { path : path . join ( proofDir , `${ proofName } -collapsed.png` ) } ) ;
63- }
48+ expect ( await bubble . getByRole ( "button" , { name : "Show more" } ) . count ( ) ) . toBe ( 0 ) ;
49+ expect ( await bubble . locator ( ".chat-message-disclosure" ) . count ( ) ) . toBe ( 0 ) ;
50+ const bubbleText = await bubble . textContent ( ) ;
51+ for ( const line of text . split ( "\n" ) . filter ( Boolean ) ) {
52+ expect ( bubbleText ) . toContain ( line ) ;
53+ }
54+ } finally {
55+ await suite . closeBrowserContext ( context ) ;
56+ }
57+ } ) ;
6458
65- await toggle . click ( ) ;
66- const collapse = bubble . getByRole ( "button" , { name : "Show less" } ) ;
67- expect ( await collapse . getAttribute ( "aria-expanded" ) ) . toBe ( "true" ) ;
68- expect ( await content . evaluate ( ( element ) => getComputedStyle ( element ) . webkitLineClamp ) ) . toBe (
69- "none" ,
70- ) ;
71- expect ( await content . evaluate ( ( element ) => element . clientHeight ) ) . toBeGreaterThan (
72- collapsedHeight ,
73- ) ;
74- if ( captureUiProofEnabled ) {
75- await bubble . screenshot ( { path : path . join ( proofDir , `${ proofName } -expanded.png` ) } ) ;
76- }
77- } finally {
78- await suite . closeBrowserContext ( context ) ;
59+ it ( "clamps a 1300-character prompt to five lines and toggles the complete prompt" , async ( ) => {
60+ const text =
61+ `${ "This long prompt stays mounted while its preview is clamped. " . repeat ( 22 ) } Final prompt tail.` . slice (
62+ 0 ,
63+ 1_300 ,
64+ ) ;
65+ const context = await suite . newBrowserContext ( {
66+ locale : "en-US" ,
67+ serviceWorkers : "block" ,
68+ viewport : { height : 844 , width : 390 } ,
69+ } ) ;
70+ const page = await context . newPage ( ) ;
71+ await installMockGateway ( page , {
72+ historyMessages : [ { role : "user" , content : [ { type : "text" , text } ] , timestamp : 1 } ] ,
73+ } ) ;
74+
75+ try {
76+ await page . goto ( `${ suite . server . baseUrl } chat` ) ;
77+ const bubble = page . locator ( ".chat-group.user .chat-bubble" ) ;
78+ await bubble . waitFor ( { state : "visible" , timeout : 10_000 } ) ;
79+ const content = bubble . locator ( ".chat-message-disclosure__content" ) ;
80+ const toggle = bubble . getByRole ( "button" , { name : "Show more" } ) ;
81+
82+ expect ( await toggle . getAttribute ( "aria-expanded" ) ) . toBe ( "false" ) ;
83+ expect ( await content . evaluate ( ( element ) => getComputedStyle ( element ) . webkitLineClamp ) ) . toBe (
84+ "5" ,
85+ ) ;
86+ expect ( await content . textContent ( ) ) . toContain ( text . slice ( - 18 ) ) ;
87+ const collapsedHeight = await content . evaluate ( ( element ) => element . clientHeight ) ;
88+ expect ( await content . evaluate ( ( element ) => element . scrollHeight > element . clientHeight ) ) . toBe (
89+ true ,
90+ ) ;
91+ const proofDir = path . join (
92+ process . cwd ( ) ,
93+ ".artifacts" ,
94+ "control-ui-e2e" ,
95+ "user-bubble-clamp" ,
96+ ) ;
97+ if ( captureUiProofEnabled ) {
98+ await mkdir ( proofDir , { recursive : true } ) ;
99+ await bubble . screenshot ( { path : path . join ( proofDir , "long-message-collapsed.png" ) } ) ;
79100 }
80- } ,
81- ) ;
101+
102+ await toggle . click ( ) ;
103+ const collapse = bubble . getByRole ( "button" , { name : "Show less" } ) ;
104+ expect ( await collapse . getAttribute ( "aria-expanded" ) ) . toBe ( "true" ) ;
105+ expect ( await content . evaluate ( ( element ) => getComputedStyle ( element ) . webkitLineClamp ) ) . toBe (
106+ "none" ,
107+ ) ;
108+ expect ( await content . evaluate ( ( element ) => element . clientHeight ) ) . toBeGreaterThan (
109+ collapsedHeight ,
110+ ) ;
111+ } finally {
112+ await suite . closeBrowserContext ( context ) ;
113+ }
114+ } ) ;
82115} ) ;
0 commit comments