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 99 mockedInvitations ,
1010 verifyDocName ,
1111} from './common' ;
12+ import { createRootSubPage } from './sub-pages-utils' ;
1213
1314test . beforeEach ( async ( { page } ) => {
1415 await page . goto ( '/' ) ;
@@ -456,6 +457,32 @@ test.describe('Doc Header', () => {
456457 await page . getByText ( duplicateDuplicateTitle ) . click ( ) ;
457458 await expect ( page . getByText ( 'Hello Duplicated World' ) ) . toBeVisible ( ) ;
458459 } ) ;
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+ } ) ;
459486} ) ;
460487
461488test . describe ( 'Documents Header mobile' , ( ) => {
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import * as Y from 'yjs';
77
88import { APIError , errorCauses , fetchAPI } from '@/api' ;
99import { toBase64 } from '@/docs/doc-editor' ;
10+ import { KEY_DOC_TREE } from '@/docs/doc-tree' ;
1011import { KEY_LIST_DOC_VERSIONS } from '@/docs/doc-versioning' ;
1112
1213import { useProviderStore } from '../stores' ;
@@ -85,6 +86,9 @@ export function useDuplicateDoc(options: DuplicateDocOptions) {
8586 void queryClient . resetQueries ( {
8687 queryKey : [ KEY_LIST_DOC ] ,
8788 } ) ;
89+ void queryClient . resetQueries ( {
90+ queryKey : [ KEY_DOC_TREE ] ,
91+ } ) ;
8892 void options . onSuccess ?.( data , variables , context ) ;
8993 } ,
9094 } ) ;
Original file line number Diff line number Diff line change 11export * from './useCreateChildren' ;
22export * from './useDocChildren' ;
3+ export * from './useDocTree' ;
34export * from './useMove' ;
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ export const getDocTree = async ({ docId }: DocsTreeParams): Promise<Doc> => {
2525 return response . json ( ) as Promise < Doc > ;
2626} ;
2727
28- export const KEY_LIST_DOC_CHILDREN = 'doc-tree' ;
28+ export const KEY_DOC_TREE = 'doc-tree' ;
2929
3030export function useDocTree (
3131 params : DocsTreeParams ,
@@ -35,7 +35,7 @@ export function useDocTree(
3535 > ,
3636) {
3737 return useQuery < Doc , APIError , Doc > ( {
38- queryKey : [ KEY_LIST_DOC_CHILDREN , params ] ,
38+ queryKey : [ KEY_DOC_TREE , params ] ,
3939 queryFn : ( ) => getDocTree ( params ) ,
4040 staleTime : 0 ,
4141 refetchOnWindowFocus : false ,
You can’t perform that action at this time.
0 commit comments