mirror of
https://github.com/strapi/strapi.git
synced 2025-07-26 18:38:46 +00:00
test filtering
This commit is contained in:
parent
5c5d27247b
commit
767f3dbd60
@ -135,6 +135,25 @@ describe('Core API - Sanitize', () => {
|
|||||||
checkAPIResultLength(res, 0);
|
checkAPIResultLength(res, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Successfully filters invalid attributes', async () => {
|
||||||
|
const document = data.document[2];
|
||||||
|
const filters = {
|
||||||
|
ID: document.id, // invalid casing on key 'id'
|
||||||
|
notAnAttribute: '', // doesn't exist on schema
|
||||||
|
t0: { createdBy: { id: { $lt: '1' } } }, // join table name
|
||||||
|
t1: { createdBy: { id: { $lt: '1' } } }, // join table name
|
||||||
|
$fakeOp: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
const res = await rq.get('/api/documents', { qs: { filters } });
|
||||||
|
|
||||||
|
// Should not return a 500 error from notAnAttribute or $fakeOp
|
||||||
|
expect(res.status).toEqual(200);
|
||||||
|
|
||||||
|
// Should receive all documents because createdBy was filtered out
|
||||||
|
checkAPIResultLength(res, documentsLength());
|
||||||
|
});
|
||||||
|
|
||||||
it('Successfully filters on valid ID', async () => {
|
it('Successfully filters on valid ID', async () => {
|
||||||
const document = data.document[2];
|
const document = data.document[2];
|
||||||
const res = await rq.get('/api/documents', { qs: { filters: { id: document.id } } });
|
const res = await rq.get('/api/documents', { qs: { filters: { id: document.id } } });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user