#1618 e2e ticket.basicData.stepOne
gitea/salix/dev This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2019-08-20 14:18:32 +02:00
parent c58d94ccd8
commit 11b99d9a5f
6 changed files with 132 additions and 22 deletions

View File

@ -433,7 +433,7 @@ INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaF
('T', 'Española rapida', 1, 'NATIONAL', 0),
('V', 'Intracomunitaria global', 0, 'CEE', 1);
INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `warehouseFk`, `agencyModeFk`, `travelingDays`, `price`, `bonus`)
INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `warehouseFk`, `agencyModeFk`, `travelingDays`, `price`, `bonus`)
VALUES
(1, 'Zone pickup A', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 1, 1, 0, 0, 0),
(2, 'Zone pickup B', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 2, 1, 0, 0, 0),
@ -441,8 +441,8 @@ INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `warehouseFk`, `agencyModeFk`, `t
(4, 'Zone 247 B', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 2, 7, 1, 2, 0),
(5, 'Zone expensive A', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 1, 8, 1, 1000, 0),
(6, 'Zone expensive B', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 2, 8, 1, 1000, 0),
(7, 'Zone refund', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 1, 10, 0, 0, 0),
(8, 'Zone others', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 1, 23, 0, 0, 0),
(7, 'Zone refund', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 1, 23, 0, 0, 0),
(8, 'Zone others', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 1, 10, 0, 0, 0),
(9, 'Zone superMan', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 1, 2, 0, 0, 0),
(10, 'Zone teleportation', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 3, 3, 0, 0, 0),
(11, 'Zone pickup C', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 5, 1, 0, 0, 0),
@ -473,8 +473,8 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF
(20, 1, 5, 5, 3, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 'Somewhere in Thailand', 129, NULL, 0, 13, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
(21, NULL, 5, 5, NULL, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 'Somewhere in Holland', 102, NULL, 0, 13, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
(22, NULL, 5, 5, NULL, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 'Somewhere in Japan', 103, NULL, 0, 13, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
(23, NULL, 23, 1, NULL, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 101, 'address 21', 121, NULL, 0, 8, CURDATE()),
(24 ,NULL, 23, 1, NULL, CURDATE(), CURDATE(), 101, 'Bruce Wayne', 1, NULL, 0, 8, CURDATE());
(23, NULL, 10, 1, NULL, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 101, 'address 21', 121, NULL, 0, 8, CURDATE()),
(24 ,NULL, 10, 1, NULL, CURDATE(), CURDATE(), 101, 'Bruce Wayne', 1, NULL, 0, 8, CURDATE());
INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`)
VALUES

View File

@ -11,6 +11,7 @@ describe('Item regularize path', () => {
it('should edit the user local warehouse', async() => {
let result = await nightmare
.waitForSpinnerLoad()
.waitToClick(selectors.globalItems.userMenuButton)
.autocompleteSearch(selectors.globalItems.userLocalWarehouse, 'Warehouse Four')
.waitForLastSnackbar();

View File

@ -11,10 +11,58 @@ describe('Ticket Edit basic data path', () => {
.accessToSection('ticket.card.basicData.stepOne');
});
it(`should edit the ticket agency then click next`, async() => {
it(`should confirm the zone autocomplete is disabled unless your role is productionBoss`, async() => {
const disabled = await nightmare
.wait(selectors.ticketBasicData.zoneAutocomplete)
.evaluate(selector => {
return document.querySelector(selector).disabled;
}, `${selectors.ticketBasicData.zoneAutocomplete} input`);
expect(disabled).toBeTruthy();
});
it(`should now log as productionBoss to perform the rest of the tests`, async() => {
await nightmare
.loginAndModule('productionBoss', 'ticket')
.accessToSearchResult(11)
.accessToSection('ticket.card.basicData.stepOne');
});
it(`should confirm the zone autocomplete is enabled for the role productionBoss`, async() => {
const disabled = await nightmare
.wait(selectors.ticketBasicData.zoneAutocomplete)
.evaluate(selector => {
return document.querySelector(selector).disabled;
}, `${selectors.ticketBasicData.zoneAutocomplete} input`);
expect(disabled).toBeFalsy();
});
it(`should check the zone is for Silla247`, async() => {
let zone = await nightmare
.waitToGetProperty(`${selectors.ticketBasicData.zoneAutocomplete} input`, 'value');
expect(zone).toContain('Zone 247 A');
});
it(`should edit the ticket agency then check there are no zones for it`, async() => {
let zone = await nightmare
.autocompleteSearch(selectors.ticketBasicData.agencyAutocomplete, 'Entanglement')
.getProperty(`${selectors.ticketBasicData.zoneAutocomplete} input`, 'value');
expect(zone.length).toEqual(0);
});
it(`should edit the ticket zone then check the agency is for the new zone`, async() => {
let zone = await nightmare
.autocompleteSearch(selectors.ticketBasicData.zoneAutocomplete, 'Zone expensive A')
.waitToGetProperty(`${selectors.ticketBasicData.agencyAutocomplete} input`, 'value');
expect(zone).toContain('Silla247Expensive');
});
it(`should click next`, async() => {
let url = await nightmare
.autocompleteSearch(selectors.ticketBasicData.agencyAutocomplete, 'Silla247Expensive')
.waitToGetProperty(`${selectors.ticketBasicData.zoneAutocomplete} input`, 'value')
.waitToClick(selectors.ticketBasicData.nextStepButton)
.waitForURL('data/step-two')
.parsedUrl();

View File

@ -5,7 +5,6 @@
order="name"
auto-load="true">
</vn-crud-model>
<form name="form">
<vn-card pad-large>
<vn-horizontal>

View File

@ -70,11 +70,11 @@ class Controller {
return null;
}
set agencyModeId(value) {
this.ticket.agencyModeFk = value;
if (value)
this.onChangeAgencyMode(value);
set agencyModeId(id) {
if (id != this.ticket.agencyModeFk) {
this.ticket.agencyModeFk = id;
this.onChangeAgencyMode(id);
}
}
get zoneId() {
@ -84,11 +84,11 @@ class Controller {
return null;
}
set zoneId(value) {
this.ticket.zoneFk = value;
if (value)
this.onChangeZone(value);
set zoneId(id) {
if (id != this.ticket.zoneFk) {
this.ticket.zoneFk = id;
this.onChangeZone(id);
}
}
/*
@ -181,6 +181,7 @@ class Controller {
* Gets an agency from an specified zone
*/
onChangeZone(zoneId) {
this.ticket.agencyModeFk = null;
const query = `/api/Zones/${zoneId}`;
this.$http.get(query).then(res => {
if (res.data)
@ -204,8 +205,9 @@ class Controller {
this.$http.get(query, {params}).then(res => {
if (res.data)
this.ticket.zoneFk = res.data.id;
else {
return this.vnApp.showMessage(
if (!res.data) {
this.vnApp.showMessage(
this.$translate.instant('No delivery zone available for this parameters')
);
}

View File

@ -24,6 +24,13 @@ describe('Ticket', () => {
expect(controller.onChangeClient).toHaveBeenCalledWith(101);
});
it(`should not call onChangeClient() method as the ticket doesn't have an ID`, () => {
spyOn(controller, 'onChangeClient');
controller.ticket = {};
expect(controller.onChangeClient).not.toHaveBeenCalledWith();
});
});
describe('clientId() setter', () => {
@ -59,7 +66,7 @@ describe('Ticket', () => {
});
describe('agencyModeId() setter', () => {
it('should set agencyModeId property and call onChangeAgencyMode() method ', () => {
it('should set agencyModeId property and call onChangeAgencyMode() method', () => {
const agencyModeId = 8;
spyOn(controller, 'onChangeAgencyMode');
controller.ticket = {id: 1};
@ -67,6 +74,15 @@ describe('Ticket', () => {
expect(controller.onChangeAgencyMode).toHaveBeenCalledWith(agencyModeId);
});
it('should do nothing if attempting to set the same agencyMode id', () => {
spyOn(controller, 'onChangeAgencyMode');
const agencyModeId = 8;
controller.ticket = {agencyModeFk: agencyModeId};
controller.agencyModeId = agencyModeId;
expect(controller.onChangeAgencyMode).not.toHaveBeenCalledWith();
});
});
describe('zoneId() setter', () => {
@ -78,6 +94,15 @@ describe('Ticket', () => {
expect(controller.onChangeZone).toHaveBeenCalledWith(zoneId);
});
it('should do nothing if attempting to set the same zone id', () => {
const zoneId = 5;
spyOn(controller, 'onChangeZone');
controller.ticket = {id: 1, zoneFk: zoneId};
controller.zoneId = zoneId;
expect(controller.onChangeZone).not.toHaveBeenCalledWith(zoneId);
});
});
describe('onChangeClient()', () => {
@ -165,6 +190,13 @@ describe('Ticket', () => {
describe('onChangeZone()', () => {
it('should return an available zone', async() => {
const zoneId = 5;
const landed = new Date();
controller._ticket = {
id: 1,
landed: landed,
addressFk: 121,
warehouseFk: 1
};
$httpBackend.when('GET', `/api/Zones/${zoneId}`).respond(200);
$httpBackend.expect('GET', `/api/Zones/${zoneId}`);
@ -199,6 +231,34 @@ describe('Ticket', () => {
controller.onChangeAgencyMode(agencyModeId);
$httpBackend.flush();
});
it('should throw a user error', async() => {
spyOn(controller.vnApp, 'showMessage');
const landed = new Date();
const agencyModeId = 7;
controller._ticket = {
id: 1,
landed: landed,
addressFk: 121,
agencyModeFk: agencyModeId,
warehouseFk: 1
};
let params = {
landed: landed,
addressFk: 121,
agencyModeFk: agencyModeId,
warehouseFk: 1
};
let serializedParams = $httpParamSerializer(params);
$httpBackend.when('GET', `/api/Agencies/getShipped?${serializedParams}`).respond(null);
$httpBackend.expect('GET', `/api/Agencies/getShipped?${serializedParams}`);
controller.onChangeAgencyMode(agencyModeId);
$httpBackend.flush();
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('No delivery zone available for this parameters');
});
});
describe('isFormInvalid()', () => {