File tree Expand file tree Collapse file tree 4 files changed +34
-2
lines changed
e2e/__tests__/app-impress
impress/src/features/docs Expand file tree Collapse file tree 4 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 9
9
mockedInvitations ,
10
10
verifyDocName ,
11
11
} from './common' ;
12
+ import { createRootSubPage } from './sub-pages-utils' ;
12
13
13
14
test . beforeEach ( async ( { page } ) => {
14
15
await page . goto ( '/' ) ;
@@ -456,6 +457,32 @@ test.describe('Doc Header', () => {
456
457
await page . getByText ( duplicateDuplicateTitle ) . click ( ) ;
457
458
await expect ( page . getByText ( 'Hello Duplicated World' ) ) . toBeVisible ( ) ;
458
459
} ) ;
460
+
461
+ test ( 'it duplicates a child document' , async ( { page, browserName } ) => {
462
+ await createDoc ( page , `Duplicate doc` , browserName ) ;
463
+
464
+ const { name : childTitle } = await createRootSubPage (
465
+ page ,
466
+ browserName ,
467
+ 'Duplicate doc - child' ,
468
+ ) ;
469
+
470
+ const editor = page . locator ( '.ProseMirror' ) ;
471
+ await editor . click ( ) ;
472
+ await editor . fill ( 'Hello Duplicated World' ) ;
473
+
474
+ await page . getByLabel ( 'Open the document options' ) . click ( ) ;
475
+
476
+ await page . getByRole ( 'menuitem' , { name : 'Duplicate' } ) . click ( ) ;
477
+ await expect (
478
+ page . getByText ( 'Document duplicated successfully!' ) ,
479
+ ) . toBeVisible ( ) ;
480
+
481
+ const duplicateDuplicateTitle = 'Copy of ' + childTitle ;
482
+ await expect (
483
+ page . getByTestId ( 'doc-tree' ) . getByText ( duplicateDuplicateTitle ) ,
484
+ ) . toBeVisible ( ) ;
485
+ } ) ;
459
486
} ) ;
460
487
461
488
test . describe ( 'Documents Header mobile' , ( ) => {
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import * as Y from 'yjs';
7
7
8
8
import { APIError , errorCauses , fetchAPI } from '@/api' ;
9
9
import { toBase64 } from '@/docs/doc-editor' ;
10
+ import { KEY_DOC_TREE } from '@/docs/doc-tree' ;
10
11
import { KEY_LIST_DOC_VERSIONS } from '@/docs/doc-versioning' ;
11
12
12
13
import { useProviderStore } from '../stores' ;
@@ -85,6 +86,9 @@ export function useDuplicateDoc(options: DuplicateDocOptions) {
85
86
void queryClient . resetQueries ( {
86
87
queryKey : [ KEY_LIST_DOC ] ,
87
88
} ) ;
89
+ void queryClient . resetQueries ( {
90
+ queryKey : [ KEY_DOC_TREE ] ,
91
+ } ) ;
88
92
void options . onSuccess ?.( data , variables , context ) ;
89
93
} ,
90
94
} ) ;
Original file line number Diff line number Diff line change 1
1
export * from './useCreateChildren' ;
2
2
export * from './useDocChildren' ;
3
+ export * from './useDocTree' ;
3
4
export * from './useMove' ;
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ export const getDocTree = async ({ docId }: DocsTreeParams): Promise<Doc> => {
25
25
return response . json ( ) as Promise < Doc > ;
26
26
} ;
27
27
28
- export const KEY_LIST_DOC_CHILDREN = 'doc-tree' ;
28
+ export const KEY_DOC_TREE = 'doc-tree' ;
29
29
30
30
export function useDocTree (
31
31
params : DocsTreeParams ,
@@ -35,7 +35,7 @@ export function useDocTree(
35
35
> ,
36
36
) {
37
37
return useQuery < Doc , APIError , Doc > ( {
38
- queryKey : [ KEY_LIST_DOC_CHILDREN , params ] ,
38
+ queryKey : [ KEY_DOC_TREE , params ] ,
39
39
queryFn : ( ) => getDocTree ( params ) ,
40
40
staleTime : 0 ,
41
41
refetchOnWindowFocus : false ,
You can’t perform that action at this time.
0 commit comments