@@ -30,6 +30,7 @@ test('Show and clear', async ({ page }) => {
3030 scrollState : SCROLL_NONE ,
3131 scrollStart : false ,
3232 scrollEnd : false ,
33+ hasClientPreedit : true ,
3334 } } )
3435 await expect ( candidateBar . locator ( '.fcitx-keyboard-candidate' ) ) . toHaveCount ( 2 )
3536 await expect ( toolbar ) . not . toBeVisible ( )
@@ -52,6 +53,7 @@ test('Select', async ({ page }) => {
5253 scrollState : SCROLL_NONE ,
5354 scrollStart : false ,
5455 scrollEnd : false ,
56+ hasClientPreedit : true ,
5557 } } )
5658
5759 const firstCandidate = candidateBar . locator ( '.fcitx-keyboard-candidate' ) . first ( )
@@ -71,6 +73,7 @@ test('Overflow', async ({ page }) => {
7173 scrollState : SCROLL_NONE ,
7274 scrollStart : false ,
7375 scrollEnd : false ,
76+ hasClientPreedit : true ,
7477 } }
7578 const candidate = getCandidateBar ( page ) . locator ( '.fcitx-keyboard-candidate' )
7679 await sendSystemEvent ( page , event )
@@ -95,6 +98,7 @@ test('Actions', async ({ page }) => {
9598 scrollState : SCROLL_NONE ,
9699 scrollStart : false ,
97100 scrollEnd : false ,
101+ hasClientPreedit : true ,
98102 } } )
99103 const candidate = page . locator ( '.fcitx-keyboard-candidate' )
100104 await longPress ( candidate )
@@ -121,6 +125,7 @@ test('Actions disappear on clear', async ({ page }) => {
121125 scrollState : SCROLL_NONE ,
122126 scrollStart : false ,
123127 scrollEnd : false ,
128+ hasClientPreedit : true ,
124129 } } )
125130 await sendSystemEvent ( page , { type : 'CANDIDATE_ACTIONS' , data : {
126131 index : 0 ,
@@ -153,6 +158,7 @@ test('Preedit', async ({ page }) => {
153158 scrollState : SCROLL_NONE ,
154159 scrollStart : false ,
155160 scrollEnd : false ,
161+ hasClientPreedit : true ,
156162 } } )
157163 const newBox = ( await preedit . boundingBox ( ) ) !
158164 expect ( newBox , 'No layout shift' ) . toEqual ( box )
@@ -213,6 +219,7 @@ test('Horizontal scroll', async ({ page }) => {
213219 scrollState : SCROLLING ,
214220 scrollStart : true ,
215221 scrollEnd : false ,
222+ hasClientPreedit : true ,
216223 } } )
217224 const candidates = page . locator ( '.fcitx-keyboard-candidates' )
218225 await candidates . evaluate ( element => element . scrollBy ( element . lastElementChild ! . getBoundingClientRect ( ) . right , 0 ) )
@@ -230,6 +237,7 @@ test('Horizontal scroll', async ({ page }) => {
230237 scrollState : SCROLLING ,
231238 scrollStart : false ,
232239 scrollEnd : true ,
240+ hasClientPreedit : true ,
233241 } } )
234242 const candidate = candidates . locator ( '.fcitx-keyboard-candidate' )
235243 await expect ( candidate ) . toHaveCount ( 30 )
@@ -258,6 +266,7 @@ test('Expand/collapse', async ({ page }) => {
258266 scrollState : SCROLLING ,
259267 scrollStart : true ,
260268 scrollEnd : false ,
269+ hasClientPreedit : true ,
261270 } } )
262271 const c29 = page . getByText ( '词29' )
263272 await expect ( c29 ) . not . toBeInViewport ( )
@@ -277,6 +286,32 @@ test('Expand/collapse', async ({ page }) => {
277286 await expect ( c29 ) . not . toBeInViewport ( )
278287} )
279288
289+ test ( 'Auto collapse if no preedit' , async ( { page } ) => {
290+ await init ( page )
291+ const container = page . locator ( '.fcitx-keyboard-container' )
292+
293+ function setCandidates ( hasClientPreedit : boolean ) {
294+ return sendSystemEvent ( page , { type : 'CANDIDATES' , data : {
295+ candidates : generateCandidates ( 0 , 10 ) ,
296+ highlighted : 0 ,
297+ scrollState : SCROLLING ,
298+ scrollStart : true ,
299+ scrollEnd : false ,
300+ hasClientPreedit,
301+ } } )
302+ }
303+
304+ await setCandidates ( true )
305+ await expandOrCollapse ( page )
306+ await expect ( container ) . toContainClass ( 'fcitx-keyboard-expanded' )
307+
308+ await setCandidates ( true )
309+ await expect ( container ) . toContainClass ( 'fcitx-keyboard-expanded' )
310+
311+ await setCandidates ( false )
312+ await expect ( container ) . not . toContainClass ( 'fcitx-keyboard-expanded' )
313+ } )
314+
280315test ( 'Vertical scroll' , async ( { page } ) => {
281316 await init ( page )
282317
@@ -286,6 +321,7 @@ test('Vertical scroll', async ({ page }) => {
286321 scrollState : SCROLLING ,
287322 scrollStart : true ,
288323 scrollEnd : false ,
324+ hasClientPreedit : true ,
289325 } } )
290326 await expandOrCollapse ( page )
291327
@@ -308,6 +344,7 @@ test('Paging button', async ({ page }) => {
308344 scrollState : SCROLLING ,
309345 scrollStart : true ,
310346 scrollEnd : true ,
347+ hasClientPreedit : true ,
311348 } } )
312349 await expandOrCollapse ( page )
313350 const top = ( await page . getByText ( '词0' ) . boundingBox ( ) ) ! . y
0 commit comments