diff --git a/src/admin/components/elements/DuplicateDocument/index.tsx b/src/admin/components/elements/DuplicateDocument/index.tsx index b1cc13513..93dad6ddf 100644 --- a/src/admin/components/elements/DuplicateDocument/index.tsx +++ b/src/admin/components/elements/DuplicateDocument/index.tsx @@ -32,9 +32,11 @@ const Duplicate: React.FC = ({ slug, collection, id }) => { return; } - const create = async (locale?: string): Promise => { - const localeParam = locale ? `locale=${locale}` : ''; - const response = await requests.get(`${serverURL}${api}/${slug}/${id}?${localeParam}`); + const create = async (locale = ''): Promise => { + const response = await requests.get(`${serverURL}${api}/${slug}/${id}`, { + locale, + depth: 0, + }); const data = await response.json(); const result = await requests.post(`${serverURL}${api}/${slug}`, { headers: { @@ -59,7 +61,10 @@ const Duplicate: React.FC = ({ slug, collection, id }) => { .filter((locale) => locale !== localization.defaultLocale) .forEach(async (locale) => { if (!abort) { - const res = await requests.get(`${serverURL}${api}/${slug}/${id}?locale=${locale}`); + const res = await requests.get(`${serverURL}${api}/${slug}/${id}`, { + locale, + depth: 0, + }); const localizedDoc = await res.json(); const patchResult = await requests.patch(`${serverURL}${api}/${slug}/${duplicateID}?locale=${locale}`, { headers: { diff --git a/test/fields-relationship/e2e.spec.ts b/test/fields-relationship/e2e.spec.ts index 8c096a55b..79aa38fd9 100644 --- a/test/fields-relationship/e2e.spec.ts +++ b/test/fields-relationship/e2e.spec.ts @@ -169,6 +169,16 @@ describe('fields - relationship', () => { await saveDocAndAssert(page); }); + test('should duplicate document with relationships', async () => { + await page.goto(url.edit(docWithExistingRelations.id)); + + await page.locator('.btn.duplicate').first().click(); + await expect(page.locator('.Toastify')).toContainText('successfully'); + const field = page.locator('#field-relationship .rs__value-container'); + + await expect(field).toHaveText(relationOneDoc.id); + }); + describe('existing relationships', () => { test('should highlight existing relationship', async () => { await page.goto(url.edit(docWithExistingRelations.id));