@@ -188,7 +188,26 @@ export const goToGridDoc = async (
188
188
return docTitle as string ;
189
189
} ;
190
190
191
- export const mockedDocument = async ( page : Page , json : object ) => {
191
+ export const updateDocTitle = async ( page : Page , title : string ) => {
192
+ const input = page . getByLabel ( 'doc title input' ) ;
193
+ await expect ( input ) . toBeVisible ( ) ;
194
+ await expect ( input ) . toHaveText ( '' ) ;
195
+ await input . click ( ) ;
196
+ await input . fill ( title ) ;
197
+ await input . click ( ) ;
198
+ await verifyDocName ( page , title ) ;
199
+ } ;
200
+
201
+ export const getWaitForCreateDoc = ( page : Page ) => {
202
+ return page . waitForResponse (
203
+ ( response ) =>
204
+ response . url ( ) . includes ( '/documents/' ) &&
205
+ response . url ( ) . includes ( '/children/' ) &&
206
+ response . request ( ) . method ( ) === 'POST' ,
207
+ ) ;
208
+ } ;
209
+
210
+ export const mockedDocument = async ( page : Page , data : object ) => {
192
211
await page . route ( '**/documents/**/' , async ( route ) => {
193
212
const request = route . request ( ) ;
194
213
if (
@@ -203,7 +222,7 @@ export const mockedDocument = async (page: Page, json: object) => {
203
222
id : 'mocked-document-id' ,
204
223
content : '' ,
205
224
title : 'Mocked document' ,
206
- accesses : [ ] ,
225
+ path : '000000' ,
207
226
abilities : {
208
227
destroy : false , // Means not owner
209
228
link_configuration : false ,
@@ -214,11 +233,21 @@ export const mockedDocument = async (page: Page, json: object) => {
214
233
update : false ,
215
234
partial_update : false , // Means not editor
216
235
retrieve : true ,
236
+ link_select_options : {
237
+ public : [ 'reader' , 'editor' ] ,
238
+ authenticated : [ 'reader' , 'editor' ] ,
239
+ restricted : null ,
240
+ } ,
217
241
} ,
218
242
link_reach : 'restricted' ,
243
+ computed_link_reach : 'restricted' ,
244
+ computed_link_role : 'reader' ,
245
+ ancestors_link_reach : null ,
246
+ ancestors_link_role : null ,
219
247
created_at : '2021-09-01T09:00:00Z' ,
248
+ user_role : 'owner' ,
220
249
user_roles : [ 'owner' ] ,
221
- ...json ,
250
+ ...data ,
222
251
} ,
223
252
} ) ;
224
253
} else {
@@ -291,30 +320,32 @@ export const mockedAccesses = async (page: Page, json?: object) => {
291
320
request . url ( ) . includes ( 'page=' )
292
321
) {
293
322
await route . fulfill ( {
294
- json : {
295
- count : 1 ,
296
- next : null ,
297
- previous : null ,
298
- results : [
299
- {
300
- id : 'bc8bbbc5-a635-4f65-9817-fd1e9ec8ef87' ,
301
- user : {
302
- id : 'b4a21bb3-722e-426c-9f78-9d190eda641c' ,
303
-
304
- } ,
305
- team : '' ,
306
- role : 'reader' ,
307
- abilities : {
308
- destroy : true ,
309
- update : true ,
310
- partial_update : true ,
311
- retrieve : true ,
312
- set_role_to : [ 'administrator' , 'editor' ] ,
313
- } ,
314
- ...json ,
323
+ json : [
324
+ {
325
+ id : 'bc8bbbc5-a635-4f65-9817-fd1e9ec8ef87' ,
326
+ user : {
327
+ id : 'b4a21bb3-722e-426c-9f78-9d190eda641c' ,
328
+
315
329
} ,
316
- ] ,
317
- } ,
330
+ team : '' ,
331
+ max_ancestors_role : null ,
332
+ max_role : 'reader' ,
333
+ role : 'reader' ,
334
+ document : {
335
+ id : 'mocked-document-id' ,
336
+ path : '000000' ,
337
+ depth : 1 ,
338
+ } ,
339
+ abilities : {
340
+ destroy : true ,
341
+ update : true ,
342
+ partial_update : true ,
343
+ retrieve : true ,
344
+ set_role_to : [ 'administrator' , 'editor' ] ,
345
+ } ,
346
+ ...json ,
347
+ } ,
348
+ ] ,
318
349
} ) ;
319
350
} else {
320
351
await route . continue ( ) ;
0 commit comments