Merge branch '2126-ticket_weekly_search_by_name' of verdnatura/salix into dev
gitea/salix/dev This commit looks good
Details
gitea/salix/dev This commit looks good
Details
This commit is contained in:
commit
40f5093106
|
@ -38,7 +38,8 @@ module.exports = Self => {
|
||||||
case 'search':
|
case 'search':
|
||||||
return {or: [
|
return {or: [
|
||||||
{'t.id': value},
|
{'t.id': value},
|
||||||
{'c.id': value}
|
{'c.id': value},
|
||||||
|
{'c.name': {like: `%${value}%`}}
|
||||||
]};
|
]};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
|
describe('ticket-weekly filter()', () => {
|
||||||
|
const authUserId = 9;
|
||||||
|
it('should return the tickets matching the filter', async() => {
|
||||||
|
const ctx = {req: {accessToken: {userId: authUserId}}, args: {}};
|
||||||
|
const filter = {order: 'id DESC'};
|
||||||
|
const result = await app.models.TicketWeekly.filter(ctx, filter);
|
||||||
|
const firstRow = result[0];
|
||||||
|
|
||||||
|
expect(firstRow.ticketFk).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return the ticket with id one', async() => {
|
||||||
|
const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 2}};
|
||||||
|
const filter = {};
|
||||||
|
const result = await app.models.TicketWeekly.filter(ctx, filter);
|
||||||
|
const firstRow = result[0];
|
||||||
|
|
||||||
|
expect(firstRow.ticketFk).toEqual(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return the ticket matching the client name', async() => {
|
||||||
|
const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 'bruce'}};
|
||||||
|
const filter = {};
|
||||||
|
const result = await app.models.TicketWeekly.filter(ctx, filter);
|
||||||
|
const firstRow = result[0];
|
||||||
|
|
||||||
|
expect(firstRow.clientName).toEqual('Bruce Wayne');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return the ticket matching the client id', async() => {
|
||||||
|
const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 101}};
|
||||||
|
const filter = {};
|
||||||
|
const result = await app.models.TicketWeekly.filter(ctx, filter);
|
||||||
|
const firstRow = result[0];
|
||||||
|
|
||||||
|
expect(firstRow.clientFk).toEqual(101);
|
||||||
|
expect(firstRow.clientName).toEqual('Bruce Wayne');
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue