Fixed back unit tests
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
7fdfd92a1c
commit
4d8a84e774
|
@ -601,11 +601,11 @@ INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `workerFk`, `created`)
|
|||
(12, 3, 19, NOW()),
|
||||
(13, 3, 19, NOW()),
|
||||
(14, 3, 19, NOW()),
|
||||
(15, 3, 19, NOW()),
|
||||
(15, 2, 19, NOW()),
|
||||
(16, 3, 19, NOW()),
|
||||
(17, 3, 19, NOW()),
|
||||
(18, 3, 19, NOW()),
|
||||
(19, 3, 19, NOW()),
|
||||
(17, 2, 19, NOW()),
|
||||
(18, 2, 19, NOW()),
|
||||
(19, 2, 19, NOW()),
|
||||
(20, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)),
|
||||
(21, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)),
|
||||
(22, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)),
|
||||
|
|
|
@ -265,7 +265,7 @@ module.exports = Self => {
|
|||
LEFT JOIN tmp.ticketProblems tp ON tp.ticketFk = f.id
|
||||
LEFT JOIN tmp.ticketTotal tt ON tt.ticketFk = f.id`);
|
||||
|
||||
if (args.problems != undefined && (!args.from || !args.to))
|
||||
if (args.problems != undefined && (!args.from && !args.to))
|
||||
throw new UserError('Choose a date range or days forward');
|
||||
|
||||
let condition;
|
||||
|
|
|
@ -17,7 +17,7 @@ describe('ticket deleteStowaway()', () => {
|
|||
await app.models.Stowaway.rawSql(
|
||||
`CALL ticketStateUpdate(?, ?)`, [shipId, 'OK']);
|
||||
await app.models.Stowaway.rawSql(
|
||||
`CALL ticketStateUpdate(?, ?)`, [stowawayId, 'OK']);
|
||||
`CALL ticketStateUpdate(?, ?)`, [stowawayId, 'FREE']);
|
||||
});
|
||||
|
||||
it('should create an stowaway', async() => {
|
||||
|
@ -97,6 +97,6 @@ describe('ticket deleteStowaway()', () => {
|
|||
}
|
||||
});
|
||||
|
||||
expect(shipState.name).toEqual('OK');
|
||||
expect(shipState.name).toEqual('Libre');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -11,7 +11,16 @@ describe('ticket filter()', () => {
|
|||
});
|
||||
|
||||
it('should return the tickets matching the problems on true', async() => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args: {problems: true}};
|
||||
const yesterday = new Date();
|
||||
yesterday.setHours(0, 0, 0, 0);
|
||||
const today = new Date();
|
||||
today.setHours(23, 59, 59, 59);
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args: {
|
||||
problems: true,
|
||||
from: yesterday,
|
||||
to: today
|
||||
}};
|
||||
const filter = {};
|
||||
const result = await app.models.Ticket.filter(ctx, filter);
|
||||
|
||||
|
@ -19,11 +28,21 @@ describe('ticket filter()', () => {
|
|||
});
|
||||
|
||||
it('should return the tickets matching the problems on false', async() => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args: {problems: false}};
|
||||
const yesterday = new Date();
|
||||
yesterday.setDate(yesterday.getDate() - 1);
|
||||
yesterday.setHours(0, 0, 0, 0);
|
||||
const today = new Date();
|
||||
today.setHours(23, 59, 59, 59);
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args: {
|
||||
problems: false,
|
||||
from: yesterday,
|
||||
to: today
|
||||
}};
|
||||
const filter = {};
|
||||
const result = await app.models.Ticket.filter(ctx, filter);
|
||||
|
||||
expect(result.length).toEqual(20);
|
||||
expect(result.length).toEqual(11);
|
||||
});
|
||||
|
||||
it('should return the tickets matching the problems on null', async() => {
|
||||
|
@ -52,10 +71,10 @@ describe('ticket filter()', () => {
|
|||
const secondRow = result[1];
|
||||
const thirdRow = result[2];
|
||||
|
||||
expect(result.length).toEqual(3);
|
||||
expect(firstRow.state).toEqual('Arreglar');
|
||||
expect(secondRow.state).toEqual('Arreglar');
|
||||
expect(thirdRow.state).toEqual('Arreglar');
|
||||
expect(result.length).toEqual(7);
|
||||
expect(firstRow.state).toEqual('Libre');
|
||||
expect(secondRow.state).toEqual('Libre');
|
||||
expect(thirdRow.state).toEqual('Libre');
|
||||
});
|
||||
|
||||
it('should return the tickets that are not pending', async() => {
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
panel="vn-ticket-search-panel"
|
||||
info="Search ticket by id or alias"
|
||||
model="model"
|
||||
fetch-params="$ctrl.fetchParams($params)">
|
||||
fetch-params="$ctrl.fetchParams($params)"
|
||||
suggested-filter="$ctrl.defaultFilter">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<vn-portal slot="menu">
|
||||
|
|
|
@ -2,10 +2,15 @@ import ngModule from '../module';
|
|||
import ModuleMain from 'salix/components/module-main';
|
||||
|
||||
export default class Ticket extends ModuleMain {
|
||||
fetchParams($params) {
|
||||
if (!Object.entries($params).length)
|
||||
$params.scopeDays = 1;
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.defaultFilter = {
|
||||
scopeDays: 1
|
||||
};
|
||||
}
|
||||
|
||||
fetchParams($params) {
|
||||
if (typeof $params.scopeDays === 'number') {
|
||||
const from = new Date();
|
||||
from.setHours(0, 0, 0, 0);
|
||||
|
|
Loading…
Reference in New Issue