fix: duplicate with relationships
This commit is contained in:
@@ -32,9 +32,11 @@ const Duplicate: React.FC<Props> = ({ slug, collection, id }) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const create = async (locale?: string): Promise<string | null> => {
|
const create = async (locale = ''): Promise<string | null> => {
|
||||||
const localeParam = locale ? `locale=${locale}` : '';
|
const response = await requests.get(`${serverURL}${api}/${slug}/${id}`, {
|
||||||
const response = await requests.get(`${serverURL}${api}/${slug}/${id}?${localeParam}`);
|
locale,
|
||||||
|
depth: 0,
|
||||||
|
});
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
const result = await requests.post(`${serverURL}${api}/${slug}`, {
|
const result = await requests.post(`${serverURL}${api}/${slug}`, {
|
||||||
headers: {
|
headers: {
|
||||||
@@ -59,7 +61,10 @@ const Duplicate: React.FC<Props> = ({ slug, collection, id }) => {
|
|||||||
.filter((locale) => locale !== localization.defaultLocale)
|
.filter((locale) => locale !== localization.defaultLocale)
|
||||||
.forEach(async (locale) => {
|
.forEach(async (locale) => {
|
||||||
if (!abort) {
|
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 localizedDoc = await res.json();
|
||||||
const patchResult = await requests.patch(`${serverURL}${api}/${slug}/${duplicateID}?locale=${locale}`, {
|
const patchResult = await requests.patch(`${serverURL}${api}/${slug}/${duplicateID}?locale=${locale}`, {
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -169,6 +169,16 @@ describe('fields - relationship', () => {
|
|||||||
await saveDocAndAssert(page);
|
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', () => {
|
describe('existing relationships', () => {
|
||||||
test('should highlight existing relationship', async () => {
|
test('should highlight existing relationship', async () => {
|
||||||
await page.goto(url.edit(docWithExistingRelations.id));
|
await page.goto(url.edit(docWithExistingRelations.id));
|
||||||
|
|||||||
Reference in New Issue
Block a user