mirror of
https://github.com/strapi/strapi.git
synced 2025-11-01 10:23:34 +00:00
fix permission + simplify test
This commit is contained in:
parent
35a13433f0
commit
c84ad063bb
@ -29,7 +29,7 @@ module.exports = {
|
||||
const entityManager = getService('entity-manager');
|
||||
const permissionChecker = getService('permission-checker').create({
|
||||
userAbility,
|
||||
model: sourceModel,
|
||||
model,
|
||||
});
|
||||
|
||||
if (permissionChecker.cannot.read()) {
|
||||
|
||||
@ -61,6 +61,15 @@ const shopModel = {
|
||||
pluralName: 'shops',
|
||||
};
|
||||
|
||||
const createEntry = async (uid, data) => {
|
||||
const { body } = await rq({
|
||||
method: 'POST',
|
||||
url: `/content-manager/collection-types/${uid}`,
|
||||
body: data,
|
||||
});
|
||||
return body;
|
||||
};
|
||||
|
||||
describe('Relations', () => {
|
||||
const builder = createTestBuilder();
|
||||
|
||||
@ -74,28 +83,16 @@ describe('Relations', () => {
|
||||
strapi = await createStrapiInstance();
|
||||
rq = await createAuthRequest({ strapi });
|
||||
|
||||
const { body: createdProduct1 } = await rq({
|
||||
method: 'POST',
|
||||
url: '/content-manager/collection-types/api::product.product',
|
||||
body: { name: 'Skate' },
|
||||
});
|
||||
const { body: createdProduct2 } = await rq({
|
||||
method: 'POST',
|
||||
url: '/content-manager/collection-types/api::product.product',
|
||||
body: { name: 'Candle' },
|
||||
});
|
||||
const createdProduct1 = await createEntry('api::product.product', { name: 'Skate' });
|
||||
const createdProduct2 = await createEntry('api::product.product', { name: 'Candle' });
|
||||
|
||||
data.products.push(createdProduct1);
|
||||
data.products.push(createdProduct2);
|
||||
|
||||
const { body: createdShop } = await rq({
|
||||
method: 'POST',
|
||||
url: '/content-manager/collection-types/api::shop.shop',
|
||||
body: {
|
||||
name: 'Cazotte Shop',
|
||||
products: [createdProduct1.id],
|
||||
myCompo: { compoProducts: [createdProduct2.id] },
|
||||
},
|
||||
const createdShop = await createEntry('api::shop.shop', {
|
||||
name: 'Cazotte Shop',
|
||||
products: [createdProduct1.id],
|
||||
myCompo: { compoProducts: [createdProduct2.id] },
|
||||
});
|
||||
|
||||
data.shops.push(createdShop);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user