mirror of
https://github.com/strapi/strapi.git
synced 2025-11-23 05:30:11 +00:00
test: disconnect and clone relations
This commit is contained in:
parent
e6b1b53db9
commit
2ac90b8e8e
@ -920,7 +920,7 @@ describe('Relations', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe.only('Clone entity with relations', () => {
|
describe('Clone entity with relations', () => {
|
||||||
test('Clone entity with relations', async () => {
|
test('Clone entity with relations', async () => {
|
||||||
const createdShop = await createEntry(
|
const createdShop = await createEntry(
|
||||||
'shop',
|
'shop',
|
||||||
@ -1020,12 +1020,12 @@ describe('Relations', () => {
|
|||||||
products_ow: { connect: [id1] },
|
products_ow: { connect: [id1] },
|
||||||
products_oo: { connect: [id1] },
|
products_oo: { connect: [id1] },
|
||||||
products_mo: { connect: [id1] },
|
products_mo: { connect: [id1] },
|
||||||
products_om: { connect: [id1] },
|
products_om: { connect: [id1, id2] },
|
||||||
products_mm: { connect: [id1] },
|
products_mm: { connect: [id1, id2] },
|
||||||
products_mw: { connect: [id1] },
|
products_mw: { connect: [id1, id2] },
|
||||||
myCompo: {
|
myCompo: {
|
||||||
compo_products_ow: { connect: [id1] },
|
compo_products_ow: { connect: [id1] },
|
||||||
compo_products_mw: { connect: [id1] },
|
compo_products_mw: { connect: [id1, id2] },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
['myCompo']
|
['myCompo']
|
||||||
@ -1033,16 +1033,16 @@ describe('Relations', () => {
|
|||||||
|
|
||||||
const clonedShop = await cloneEntry('shop', createdShop.id, {
|
const clonedShop = await cloneEntry('shop', createdShop.id, {
|
||||||
name: 'Cazotte Shop 2',
|
name: 'Cazotte Shop 2',
|
||||||
products_ow: { connect: [id2] },
|
products_ow: { disconnect: [id1] },
|
||||||
products_oo: { connect: [id2] },
|
products_oo: { disconnect: [id1] },
|
||||||
products_mo: { connect: [id2] },
|
products_mo: { disconnect: [id1] },
|
||||||
products_om: { connect: [id2] },
|
products_om: { disconnect: [id1] },
|
||||||
products_mm: { connect: [id2] },
|
products_mm: { disconnect: [id1] },
|
||||||
products_mw: { connect: [id2] },
|
products_mw: { disconnect: [id1] },
|
||||||
myCompo: {
|
myCompo: {
|
||||||
id: createdShop.myCompo.id,
|
id: createdShop.myCompo.id,
|
||||||
compo_products_ow: { connect: [id2] },
|
compo_products_ow: { disconnect: [id1] },
|
||||||
compo_products_mw: { connect: [id2] },
|
compo_products_mw: { disconnect: [id1] },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1050,28 +1050,28 @@ describe('Relations', () => {
|
|||||||
|
|
||||||
let res;
|
let res;
|
||||||
res = await getRelations('default.compo', 'compo_products_mw', clonedShop.myCompo.id);
|
res = await getRelations('default.compo', 'compo_products_mw', clonedShop.myCompo.id);
|
||||||
expect(res.results).toMatchObject([{ id: id2 }, { id: id1 }]);
|
expect(res.results).toMatchObject([{ id: id2 }]);
|
||||||
|
|
||||||
res = await getRelations('default.compo', 'compo_products_ow', clonedShop.myCompo.id);
|
res = await getRelations('default.compo', 'compo_products_ow', clonedShop.myCompo.id);
|
||||||
expect(res.data).toMatchObject({ id: id2 });
|
expect(res.data).toBe(null);
|
||||||
|
|
||||||
res = await getRelations('api::shop.shop', 'products_mm', clonedShop.id);
|
res = await getRelations('api::shop.shop', 'products_mm', clonedShop.id);
|
||||||
expect(res.results).toMatchObject([{ id: id2 }, { id: id1 }]);
|
expect(res.results).toMatchObject([{ id: id2 }]);
|
||||||
|
|
||||||
res = await getRelations('api::shop.shop', 'products_mo', clonedShop.id);
|
res = await getRelations('api::shop.shop', 'products_mo', clonedShop.id);
|
||||||
expect(res.data).toMatchObject({ id: id2 });
|
expect(res.data).toBe(null);
|
||||||
|
|
||||||
res = await getRelations('api::shop.shop', 'products_mw', clonedShop.id);
|
res = await getRelations('api::shop.shop', 'products_mw', clonedShop.id);
|
||||||
expect(res.results).toMatchObject([{ id: id2 }, { id: id1 }]);
|
expect(res.results).toMatchObject([{ id: id2 }]);
|
||||||
|
|
||||||
res = await getRelations('api::shop.shop', 'products_om', clonedShop.id);
|
res = await getRelations('api::shop.shop', 'products_om', clonedShop.id);
|
||||||
expect(res.results).toMatchObject([{ id: id2 }, { id: id1 }]);
|
expect(res.results).toMatchObject([{ id: id2 }]);
|
||||||
|
|
||||||
res = await getRelations('api::shop.shop', 'products_oo', clonedShop.id);
|
res = await getRelations('api::shop.shop', 'products_oo', clonedShop.id);
|
||||||
expect(res.data).toMatchObject({ id: id2 });
|
expect(res.data).toBe(null);
|
||||||
|
|
||||||
res = await getRelations('api::shop.shop', 'products_ow', clonedShop.id);
|
res = await getRelations('api::shop.shop', 'products_ow', clonedShop.id);
|
||||||
expect(res.data).toMatchObject({ id: id2 });
|
expect(res.data).toBe(null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user