fix: populate syntax in media test

Co-authored-by: Jean-Sébastien Herbaux <Convly@users.noreply.github.com>
This commit is contained in:
Bassel Kanso 2024-05-27 16:40:15 +03:00
parent ff5a4cf03b
commit 4fe3c1b4c4
2 changed files with 15 additions and 4 deletions

View File

@ -176,6 +176,8 @@ const populate = traverseFactory()
const newValue = await recurse(visitor, { schema, path, getModel }, { on: value?.on }); const newValue = await recurse(visitor, { schema, path, getModel }, { on: value?.on });
set(key, { on: newValue }); set(key, { on: newValue });
return;
} }
const targetSchemaUID = attribute.target; const targetSchemaUID = attribute.target;

View File

@ -21,7 +21,9 @@ const schemas = {
singularName: 'a', singularName: 'a',
pluralName: 'as', pluralName: 'as',
attributes: { attributes: {
cover: { type: 'media' }, cover: {
type: 'media',
},
}, },
}, },
b: { b: {
@ -143,9 +145,13 @@ describe('Sanitize populated entries', () => {
test("Media's relations (from related) can be populated without restricted attributes", async () => { test("Media's relations (from related) can be populated without restricted attributes", async () => {
const { status, body } = await contentAPIRequest.get(`/upload/files/${file.id}`, { const { status, body } = await contentAPIRequest.get(`/upload/files/${file.id}`, {
qs: { populate: { related: { populate: '*' } } }, qs: {
populate: {
related: true,
},
},
}); });
console.log(body);
expect(status).toBe(200); expect(status).toBe(200);
expect(body.related).toBeDefined(); expect(body.related).toBeDefined();
expect(Array.isArray(body.related)).toBeTruthy(); expect(Array.isArray(body.related)).toBeTruthy();
@ -170,7 +176,10 @@ describe('Sanitize populated entries', () => {
}); });
const { status } = await contentAPIRequest.get(`/${schemas.contentTypes.b.pluralName}`, { const { status } = await contentAPIRequest.get(`/${schemas.contentTypes.b.pluralName}`, {
qs: { fields: ['id'], populate: '*' }, qs: {
fields: ['id'],
populate: '*',
},
}); });
expect(status).toBe(200); expect(status).toBe(200);