11import { expect , test } from '@playwright/test' ;
22
3- import { createDoc , randomName , verifyDocName } from './utils-common' ;
3+ import { createDoc , verifyDocName } from './utils-common' ;
44import { createRootSubPage } from './utils-sub-pages' ;
55
66test . beforeEach ( async ( { page } ) => {
@@ -163,20 +163,12 @@ test.describe('Document search', () => {
163163 await verifyDocName ( page , firstDocTitle ) ;
164164
165165 // Create a new doc - for the moment without children
166- await page . getByRole ( 'button' , { name : 'New doc' } ) . click ( ) ;
167- await verifyDocName ( page , '' ) ;
168- await page . getByRole ( 'textbox' , { name : 'doc title input' } ) . click ( ) ;
169- await page
170- . getByRole ( 'textbox' , { name : 'doc title input' } )
171- . press ( 'ControlOrMeta+a' ) ;
172- const [ secondDocTitle ] = randomName (
166+ const [ secondDocTitle ] = await createDoc (
167+ page ,
173168 'My second sub page search' ,
174169 browserName ,
175170 1 ,
176171 ) ;
177- await page
178- . getByRole ( 'textbox' , { name : 'doc title input' } )
179- . fill ( secondDocTitle ) ;
180172
181173 const searchButton = page
182174 . getByTestId ( 'left-panel-desktop' )
@@ -199,16 +191,23 @@ test.describe('Document search', () => {
199191 await page . getByRole ( 'button' , { name : 'close' } ) . click ( ) ;
200192
201193 // Create a sub page
202- await createRootSubPage ( page , browserName , secondDocTitle ) ;
194+ const { name : secondChildDocTitle } = await createRootSubPage (
195+ page ,
196+ browserName ,
197+ 'second - Child doc' ,
198+ ) ;
203199 await searchButton . click ( ) ;
204200 await page
205201 . getByRole ( 'combobox' , { name : 'Quick search input' } )
206- . fill ( 'sub page search ' ) ;
202+ . fill ( 'second ' ) ;
207203
208204 // Now there is a sub page - expect to have the focus on the current doc
209205 await expect (
210206 page . getByRole ( 'presentation' ) . getByLabel ( secondDocTitle ) ,
211207 ) . toBeVisible ( ) ;
208+ await expect (
209+ page . getByRole ( 'presentation' ) . getByLabel ( secondChildDocTitle ) ,
210+ ) . toBeVisible ( ) ;
212211 await expect (
213212 page . getByRole ( 'presentation' ) . getByLabel ( firstDocTitle ) ,
214213 ) . toBeHidden ( ) ;
0 commit comments