E2E fixes

This commit is contained in:
Juan Ferrer 2019-11-11 16:32:03 +01:00
parent efa6ddc0f1
commit 95d943e515
17 changed files with 91 additions and 98 deletions

View File

@ -357,15 +357,16 @@ let actions = {
accessToSection: function(sectionRoute) {
return this.wait(`vn-left-menu`)
.evaluate(sectionRoute => {
return document.querySelector(`vn-left-menu ul li ul li > a[ui-sref="${sectionRoute}"]`) != null;
return document.querySelector(`vn-left-menu li li > a[ui-sref="${sectionRoute}"]`) != null;
}, sectionRoute)
.then(nested => {
if (!nested)
return this.waitToClick(`vn-left-menu li > a[ui-sref="${sectionRoute}"]`);
if (nested) {
this.waitToClick('vn-left-menu vn-item-section > vn-icon[icon=keyboard_arrow_down]')
.wait('vn-left-menu .expanded');
}
return this.waitToClick('vn-left-menu vn-item-section > vn-icon[icon=keyboard_arrow_down]')
.wait('vn-left-menu .expanded')
.waitToClick(`vn-left-menu li > a[ui-sref="${sectionRoute}"]`);
return this.waitToClick(`vn-left-menu li > a[ui-sref="${sectionRoute}"]`)
.waitForSpinnerLoad();
});
},

View File

@ -13,9 +13,7 @@ module.exports = function createNightmare(width = 1280, height = 720) {
x: 0,
y: 0,
waitTimeout: 2000,
// openDevTools: {
// mode: 'detach'
// }
// openDevTools: {mode: 'detach'}
}).viewport(width, height);
nightmare.on('console', (type, message, ...args) => {

View File

@ -336,7 +336,7 @@ export default {
searchButton: 'vn-searchbar vn-icon[icon="search"]',
searchWeeklyButton: 'vn-searchbar vn-icon[icon="search"]',
moreMenu: 'vn-ticket-index vn-icon-menu[icon=more_vert]',
moreMenuWeeklyTickets: '.vn-drop-down.shown li:nth-child(2)',
menuWeeklyTickets: 'vn-left-menu [ui-sref="ticket.weekly.index"]',
sixthWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tr:nth-child(6) vn-autocomplete[ng-model="weekly.weekDay"] input',
weeklyTicket: 'vn-ticket-weekly-index vn-table > div > vn-tbody > vn-tr',
firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-tr:nth-child(1) vn-icon-button[icon="delete"]',

View File

@ -11,8 +11,7 @@ describe('Ticket descriptor path', () => {
it('should count the amount of tickets in the turns section', async() => {
const result = await nightmare
.waitToClick(selectors.ticketsIndex.moreMenu)
.waitToClick(selectors.ticketsIndex.moreMenuWeeklyTickets)
.waitToClick(selectors.ticketsIndex.menuWeeklyTickets)
.wait(selectors.ticketsIndex.weeklyTicket)
.countElement(selectors.ticketsIndex.weeklyTicket);
@ -72,8 +71,7 @@ describe('Ticket descriptor path', () => {
it('should confirm the ticket 11 was added on thursday', async() => {
const result = await nightmare
.waitToClick(selectors.ticketsIndex.moreMenu)
.waitToClick(selectors.ticketsIndex.moreMenuWeeklyTickets)
.waitToClick(selectors.ticketsIndex.menuWeeklyTickets)
.waitToGetProperty(selectors.ticketsIndex.sixthWeeklyTicket, 'value');
expect(result).toEqual('Thursday');
@ -132,8 +130,7 @@ describe('Ticket descriptor path', () => {
it('should confirm the ticket 11 was added on saturday', async() => {
const result = await nightmare
.waitToClick(selectors.ticketsIndex.moreMenu)
.waitToClick(selectors.ticketsIndex.moreMenuWeeklyTickets)
.waitToClick(selectors.ticketsIndex.menuWeeklyTickets)
.waitToGetProperty(selectors.ticketsIndex.sixthWeeklyTicket, 'value');
expect(result).toEqual('Saturday');

View File

@ -20,7 +20,7 @@ describe('Ticket services path', () => {
.isDisabled(selectors.ticketService.firstAddDescriptionButton);
expect(result).toBeTruthy();
});
}, 100000);
it('should receive an error if you attempt to save a service without access rights', async() => {
const result = await nightmare

View File

@ -219,7 +219,6 @@ export default class Autocomplete extends Field {
else
return;
}
console.log(event.key);
}
onContainerClick(event) {

View File

@ -16,7 +16,7 @@ class DatePicker extends Field {
if (value) {
let ymd = value.split('-')
.map(e => parseInt(e));
date = new Date(...ymd);
date = new Date(ymd[0], ymd[1] - 1, ymd[2]);
if (this.field) {
let orgDate = this.field instanceof Date

View File

@ -3,6 +3,10 @@ describe('Component vnDatePicker', () => {
let $element;
let $ctrl;
let today;
today = new Date();
today.setHours(0, 0, 0, 0);
beforeEach(ngModule('vnCore'));
beforeEach(angular.mock.inject(($compile, $rootScope, _$filter_) => {
@ -18,14 +22,19 @@ describe('Component vnDatePicker', () => {
describe('field() setter', () => {
it(`should display the formated the date`, () => {
let today;
today = new Date();
today.setHours(0, 0, 0, 0);
$ctrl.field = today;
let displayed = $filter('date')(today, 'yyyy-MM-dd');
expect($ctrl.value).toEqual(displayed);
});
});
describe('onValueUpdate()', () => {
it(`should change the picker value to selected date`, () => {
$ctrl.value = $filter('date')(today, 'yyyy-MM-dd');
$ctrl.input.dispatchEvent(new Event('change'));
expect($ctrl.field).toEqual(today);
});
});
});

View File

@ -50,7 +50,7 @@ export default class Field extends FormInput {
}
set value(value) {
this.field = value;
this.input.value = value;
}
get value() {

View File

@ -1,14 +1,23 @@
module.exports = Self => {
Self.remoteMethod('getAgenciesWithWarehouse', {
description: 'Returns a list of agencies that can land a shipment on a day for an address and a warehouse',
accepts: [{
arg: 'filter',
type: 'object',
required: true,
description: 'addressFk'
}],
accepts: [
{
arg: 'addressFk',
type: 'number',
required: true
}, {
arg: 'landed',
type: 'date',
required: true
}, {
arg: 'warehouseFk',
type: 'number',
required: true
}
],
returns: {
type: 'object',
type: ['object'],
root: true
},
http: {
@ -17,10 +26,9 @@ module.exports = Self => {
}
});
Self.getAgenciesWithWarehouse = async filter => {
Self.getAgenciesWithWarehouse = async(addressFk, landed, warehouseFk) => {
let query = `CALL vn.zone_getWarehouse(?, ?, ?)`;
let result = await Self.rawSql(query, [filter.addressFk, filter.landed, filter.warehouseFk]);
let [result] = await Self.rawSql(query, [addressFk, landed, warehouseFk]);
return result;
};
};

View File

@ -1,12 +1,17 @@
module.exports = Self => {
Self.remoteMethod('landsThatDay', {
description: 'Returns a list of agencies that can land a shipment on a day for an address',
accepts: [{
arg: 'filter',
type: 'object',
required: true,
description: 'addressFk'
}],
accepts: [
{
arg: 'addressFk',
type: 'number',
required: true
}, {
arg: 'landed',
type: 'date',
required: true
}
],
returns: {
type: 'object',
root: true
@ -17,13 +22,13 @@ module.exports = Self => {
}
});
Self.landsThatDay = async filter => {
Self.landsThatDay = async(addressFk, landed) => {
let query = `
CALL vn.zoneGetAgency(?, ?);
CALL vn.zone_getAgency(?, ?);
SELECT * FROM tmp.zoneGetAgency;
DROP TEMPORARY TABLE tmp.zoneGetAgency;
`;
let result = await Self.rawSql(query, [filter.addressFk, filter.landed]);
let result = await Self.rawSql(query, [addressFk, landed]);
return result[1];
};

View File

@ -3,14 +3,7 @@ const app = require('vn-loopback/server/server');
describe('Agency getAgenciesWithWarehouse()', () => {
const today = new Date();
it('should return the agencies that can handle the given delivery request', async() => {
let filter = {
addressFk: 101,
landed: today,
warehouseFk: 1
};
let result = await app.models.Agency.getAgenciesWithWarehouse(filter);
let agencies = result[0];
let agencies = await app.models.Agency.getAgenciesWithWarehouse(101, today, 1);
expect(agencies.length).toEqual(3);
expect(agencies[0].agencyMode).toEqual('inhouse pickup');
@ -19,14 +12,7 @@ describe('Agency getAgenciesWithWarehouse()', () => {
});
it('should return no agencies if the date is incorrect', async() => {
let filter = {
addressFk: 101,
landed: null,
warehouseFk: 1
};
let result = await app.models.Agency.getAgenciesWithWarehouse(filter);
let agencies = result[0];
let agencies = await app.models.Agency.getAgenciesWithWarehouse(101, null, 1);
expect(agencies.length).toEqual(0);
});

View File

@ -3,12 +3,7 @@ const app = require('vn-loopback/server/server');
xdescribe('Agency landsThatDay()', () => {
const today = new Date();
it('should return a list of agencies that can land a shipment on a day for an address', async() => {
let filter = {
addressFk: 101,
landed: today,
};
let agencies = await app.models.Agency.landsThatDay(filter);
let agencies = await app.models.Agency.landsThatDay(101, today);
expect(agencies.length).toBeGreaterThanOrEqual(3);
});

View File

@ -78,16 +78,16 @@ class Controller {
}
getAvailableAgencies() {
this.order.agencyModeFk = null;
if (this.order.landed && this.order.addressFk) {
let filter = {
addressFk: this.order.addressFk,
landed: this.order.landed
};
this.$http.get(`Agencies/landsThatDay`, {params: {filter}})
.then(res => {
this._availableAgencies = res.data;
});
let order = this.order;
order.agencyModeFk = null;
let params = {
addressFk: order.addressFk,
landed: order.landed
};
if (params.landed && params.addressFk) {
this.$http.get(`Agencies/landsThatDay`, {params})
.then(res => this._availableAgencies = res.data);
}
}

View File

@ -24,8 +24,7 @@ class Controller {
* @param {Object} value - Order data
*/
set order(value) {
if (!value.id || this._order) return;
if (!value || !value.id || this._order) return;
this._order = value;
this.$.$applyAsync(() => {

View File

@ -86,14 +86,18 @@ class Controller {
}
getAvailableAgencies() {
if (this.ticket.warehouseFk && this.ticket.addressFk && this.ticket.landed && this.ticket.clientFk) {
this.ticket.agencyModeFk = null;
let filter = {warehouseFk: this.ticket.warehouseFk, addressFk: this.ticket.addressFk, landed: this.ticket.landed};
filter = encodeURIComponent(JSON.stringify(filter));
let query = `Agencies/getAgenciesWithWarehouse?filter=${filter}`;
this.$http.get(query).then(res => {
this._availableAgencies = res.data[0];
});
let ticket = this.ticket;
let params = {
warehouseFk: ticket.warehouseFk,
addressFk: ticket.addressFk,
landed: ticket.landed
};
if (params.warehouseFk && params.addressFk && params.landed) {
ticket.agencyModeFk = null;
this.$http.get(`Agencies/getAgenciesWithWarehouse`, {params})
.then(res => this._availableAgencies = res.data);
}
}

View File

@ -17,19 +17,11 @@ class Controller {
}
getDefaultTaxClass() {
let config = {params: {
filter: {
where: {
code: 'G'
}
}
}};
let query = 'TaxClasses/findOne';
this.$http.get(query, config).then(res => {
if (res.data)
this.defaultTaxClass = res.data;
});
let filter = {
where: {code: 'G'}
};
this.$http.get('TaxClasses/findOne', {filter})
.then(res => this.defaultTaxClass = res.data);
}
add() {