Fix REST API filters (#12929)
# Introduction close https://github.com/twentyhq/twenty/issues/12921 ### Done here: - Removed [check-order-by.utils.ts](https://github.com/twentyhq/twenty/pull/12929/files#diff-d044effc0b77b3b67523595ce0febd786d3a0fd74ae905ce2efc349134d7c7d0) that was a duplicated - new debug entry `twenty-server` entrypoint - fixed the fields name computation in case of a relation field metadata type - Updated and refactored coverage both unit and integration 
This commit is contained in:
@ -197,6 +197,34 @@ describe('Core REST API Find Many endpoint', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should support filtering on a relation field id', async () => {
|
||||
const response = await makeRestAPIRequest({
|
||||
method: 'get',
|
||||
path: `/people?filter=companyId[in]:["${TEST_COMPANY_1_ID}"]`,
|
||||
}).expect(200);
|
||||
|
||||
const filteredPeople = response.body.data.people;
|
||||
|
||||
expect(filteredPeople.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('should fail to filter on a relation field name', async () => {
|
||||
const response = await makeRestAPIRequest({
|
||||
method: 'get',
|
||||
path: `/people?filter=company[in]:["${TEST_COMPANY_1_ID}"]`,
|
||||
});
|
||||
|
||||
expect(response.body).toMatchInlineSnapshot(`
|
||||
{
|
||||
"error": "BadRequestException",
|
||||
"messages": [
|
||||
"field 'company' does not exist in 'person' object",
|
||||
],
|
||||
"statusCode": 400,
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
it('should support ordering Desc of results', async () => {
|
||||
const descResponse = await makeRestAPIRequest({
|
||||
method: 'get',
|
||||
|
||||
Reference in New Issue
Block a user