diff --git a/.gitignore b/.gitignore index 3ef8c28fd..8cb76a829 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ coverage node_modules -dist/* +dist e2e/dms/*/ !e2e/dms/c4c !e2e/dms/c81 diff --git a/db/changes/10081-agency/00-zone_getEvents.sql b/db/changes/10081-agency/00-zone_getEvents.sql index 199074a72..35d95f7bb 100644 --- a/db/changes/10081-agency/00-zone_getEvents.sql +++ b/db/changes/10081-agency/00-zone_getEvents.sql @@ -1,10 +1,12 @@ +USE `vn`; +DROP procedure IF EXISTS `zone_getEvents`; -DROP PROCEDURE IF EXISTS `vn`.`zone_getEvents`; DELIMITER $$ -CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`zone_getEvents`( - vAgencyModeFk INT, +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getEvents`( vProvinceFk INT, - vPostCode VARCHAR(255)) + vPostCode VARCHAR(255), + vAgencyModeFk INT) BEGIN /** * Returns available events for the passed province/postcode and agency. @@ -13,9 +15,9 @@ BEGIN * @param vProvinceFk The province id * @param vPostCode The postcode or %NULL to use the province */ - DECLARE vGeoFk INT; - - IF vPostCode IS NOT NULL THEN + DECLARE vGeoFk INT; + + IF vPostCode IS NOT NULL THEN SELECT p.geoFk INTO vGeoFk FROM postCode p JOIN town t ON t.id = p.townFk @@ -24,24 +26,27 @@ BEGIN ELSE SELECT geoFk INTO vGeoFk FROM province - WHERE id = vProvinceFk; - END IF; + WHERE id = vProvinceFk; + END IF; - CALL zone_getFromGeo(vGeoFk); - - DELETE t FROM tmp.zone t - JOIN zone z ON z.id = t.id - WHERE z.agencyModeFk != vAgencyModeFk; - - SELECT e.`from`, e.`to`, e.weekDays + CALL zone_getFromGeo(vGeoFk); + + IF vAgencyModeFk IS NOT NULL THEN + DELETE t FROM tmp.zone t + JOIN zone z ON z.id = t.id + WHERE z.agencyModeFk != vAgencyModeFk; + END IF; + + SELECT e.`from`, e.`to`, e.weekDays FROM tmp.zone t JOIN zoneEvent e ON e.zoneFk = t.id; - - SELECT DISTINCT e.`day` + + SELECT DISTINCT e.`day` FROM tmp.zone t JOIN zoneExclusion e ON e.zoneFk = t.id; DROP TEMPORARY TABLE tmp.zone; END$$ + DELIMITER ; diff --git a/db/changes/10100-AllSaints/00-ACL.sql b/db/changes/10100-allSaints/00-ACL.sql similarity index 100% rename from db/changes/10100-AllSaints/00-ACL.sql rename to db/changes/10100-allSaints/00-ACL.sql diff --git a/db/changes/10100-AllSaints/00-travelLog.sql b/db/changes/10100-allSaints/00-travelLog.sql similarity index 100% rename from db/changes/10100-AllSaints/00-travelLog.sql rename to db/changes/10100-allSaints/00-travelLog.sql diff --git a/db/changes/10100-AllSaints/00-upperGap.sql b/db/changes/10100-allSaints/00-upperGap.sql similarity index 100% rename from db/changes/10100-AllSaints/00-upperGap.sql rename to db/changes/10100-allSaints/00-upperGap.sql diff --git a/db/changes/10100-AllSaints/00-userLog.sql b/db/changes/10100-allSaints/00-userLog.sql similarity index 100% rename from db/changes/10100-AllSaints/00-userLog.sql rename to db/changes/10100-allSaints/00-userLog.sql diff --git a/db/changes/10100-AllSaints/00-userPhoneType.sql b/db/changes/10100-allSaints/00-userPhoneType.sql similarity index 100% rename from db/changes/10100-AllSaints/00-userPhoneType.sql rename to db/changes/10100-allSaints/00-userPhoneType.sql diff --git a/db/changes/10100-AllSaints/00-zone.sql b/db/changes/10100-allSaints/00-zone.sql similarity index 100% rename from db/changes/10100-AllSaints/00-zone.sql rename to db/changes/10100-allSaints/00-zone.sql diff --git a/db/changes/10100-AllSaints/01-userPhone.sql b/db/changes/10100-allSaints/01-userPhone.sql similarity index 100% rename from db/changes/10100-AllSaints/01-userPhone.sql rename to db/changes/10100-allSaints/01-userPhone.sql diff --git a/db/changes/10100-AllSaints/01-zone_getAgency.sql b/db/changes/10100-allSaints/01-zone_getAgency.sql similarity index 100% rename from db/changes/10100-AllSaints/01-zone_getAgency.sql rename to db/changes/10100-allSaints/01-zone_getAgency.sql diff --git a/db/changes/10100-AllSaints/01-zone_getFirstShipped.sql b/db/changes/10100-allSaints/01-zone_getFirstShipped.sql similarity index 100% rename from db/changes/10100-AllSaints/01-zone_getFirstShipped.sql rename to db/changes/10100-allSaints/01-zone_getFirstShipped.sql diff --git a/db/changes/10100-AllSaints/01-zone_getLanded.sql b/db/changes/10100-allSaints/01-zone_getLanded.sql similarity index 100% rename from db/changes/10100-AllSaints/01-zone_getLanded.sql rename to db/changes/10100-allSaints/01-zone_getLanded.sql diff --git a/db/changes/10100-AllSaints/01-zone_getShippedWarehouse.sql b/db/changes/10100-allSaints/01-zone_getShippedWarehouse.sql similarity index 100% rename from db/changes/10100-AllSaints/01-zone_getShippedWarehouse.sql rename to db/changes/10100-allSaints/01-zone_getShippedWarehouse.sql diff --git a/db/changes/10100-AllSaints/01-zone_getWarehouse.sql b/db/changes/10100-allSaints/01-zone_getWarehouse.sql similarity index 100% rename from db/changes/10100-AllSaints/01-zone_getWarehouse.sql rename to db/changes/10100-allSaints/01-zone_getWarehouse.sql diff --git a/db/changes/10100-AllSaints/02-catalog_componentCalculate.sql b/db/changes/10100-allSaints/02-catalog_componentCalculate.sql similarity index 100% rename from db/changes/10100-AllSaints/02-catalog_componentCalculate.sql rename to db/changes/10100-allSaints/02-catalog_componentCalculate.sql diff --git a/db/changes/10100-AllSaints/02-ticketCalculate__.sql b/db/changes/10100-allSaints/02-ticketCalculate__.sql similarity index 100% rename from db/changes/10100-AllSaints/02-ticketCalculate__.sql rename to db/changes/10100-allSaints/02-ticketCalculate__.sql diff --git a/db/changes/10100-AllSaints/02-zoneGetAgency.sql b/db/changes/10100-allSaints/02-zoneGetAgency.sql similarity index 100% rename from db/changes/10100-AllSaints/02-zoneGetAgency.sql rename to db/changes/10100-allSaints/02-zoneGetAgency.sql diff --git a/db/changes/10100-AllSaints/02-zoneGetFirstShipped__.sql b/db/changes/10100-allSaints/02-zoneGetFirstShipped__.sql similarity index 100% rename from db/changes/10100-AllSaints/02-zoneGetFirstShipped__.sql rename to db/changes/10100-allSaints/02-zoneGetFirstShipped__.sql diff --git a/db/changes/10100-AllSaints/02-zoneGetLanded.sql b/db/changes/10100-allSaints/02-zoneGetLanded.sql similarity index 100% rename from db/changes/10100-AllSaints/02-zoneGetLanded.sql rename to db/changes/10100-allSaints/02-zoneGetLanded.sql diff --git a/db/changes/10100-AllSaints/02-zoneGetShipped.sql b/db/changes/10100-allSaints/02-zoneGetShipped.sql similarity index 100% rename from db/changes/10100-AllSaints/02-zoneGetShipped.sql rename to db/changes/10100-allSaints/02-zoneGetShipped.sql diff --git a/db/changes/10100-AllSaints/02-zoneGetShippedWarehouse.sql b/db/changes/10100-allSaints/02-zoneGetShippedWarehouse.sql similarity index 100% rename from db/changes/10100-AllSaints/02-zoneGetShippedWarehouse.sql rename to db/changes/10100-allSaints/02-zoneGetShippedWarehouse.sql diff --git a/db/changes/10100-AllSaints/03-available_calc.sql b/db/changes/10100-allSaints/03-available_calc.sql similarity index 100% rename from db/changes/10100-AllSaints/03-available_calc.sql rename to db/changes/10100-allSaints/03-available_calc.sql diff --git a/db/changes/10100-AllSaints/03-catalog_calculate.sql b/db/changes/10100-allSaints/03-catalog_calculate.sql similarity index 100% rename from db/changes/10100-AllSaints/03-catalog_calculate.sql rename to db/changes/10100-allSaints/03-catalog_calculate.sql diff --git a/db/changes/10100-AllSaints/03-order_confirmWithUser.sql b/db/changes/10100-allSaints/03-order_confirmWithUser.sql similarity index 100% rename from db/changes/10100-AllSaints/03-order_confirmWithUser.sql rename to db/changes/10100-allSaints/03-order_confirmWithUser.sql diff --git a/db/changes/10100-AllSaints/03-ticketCalculateClon.sql b/db/changes/10100-allSaints/03-ticketCalculateClon.sql similarity index 100% rename from db/changes/10100-AllSaints/03-ticketCalculateClon.sql rename to db/changes/10100-allSaints/03-ticketCalculateClon.sql diff --git a/db/changes/10100-AllSaints/03-ticketComponentCalculate.sql b/db/changes/10100-allSaints/03-ticketComponentCalculate.sql similarity index 100% rename from db/changes/10100-AllSaints/03-ticketComponentCalculate.sql rename to db/changes/10100-allSaints/03-ticketComponentCalculate.sql diff --git a/db/changes/10100-AllSaints/03-ticketCreateWithUser.sql b/db/changes/10100-allSaints/03-ticketCreateWithUser.sql similarity index 100% rename from db/changes/10100-AllSaints/03-ticketCreateWithUser.sql rename to db/changes/10100-allSaints/03-ticketCreateWithUser.sql diff --git a/db/changes/10100-AllSaints/03-ticketCreateWithoutZone.sql b/db/changes/10100-allSaints/03-ticketCreateWithoutZone.sql similarity index 100% rename from db/changes/10100-AllSaints/03-ticketCreateWithoutZone.sql rename to db/changes/10100-allSaints/03-ticketCreateWithoutZone.sql diff --git a/db/changes/10100-AllSaints/04-zone_getOptionsForDated.sql b/db/changes/10100-allSaints/04-zone_getOptionsForDated.sql similarity index 100% rename from db/changes/10100-AllSaints/04-zone_getOptionsForDated.sql rename to db/changes/10100-allSaints/04-zone_getOptionsForDated.sql diff --git a/db/changes/10100-AllSaints/04-zone_getOptionsForLanding.sql b/db/changes/10100-allSaints/04-zone_getOptionsForLanding.sql similarity index 100% rename from db/changes/10100-AllSaints/04-zone_getOptionsForLanding.sql rename to db/changes/10100-allSaints/04-zone_getOptionsForLanding.sql diff --git a/db/changes/10100-AllSaints/04-zone_getOptionsForShipment.sql b/db/changes/10100-allSaints/04-zone_getOptionsForShipment.sql similarity index 100% rename from db/changes/10100-AllSaints/04-zone_getOptionsForShipment.sql rename to db/changes/10100-allSaints/04-zone_getOptionsForShipment.sql diff --git a/db/changes/10100-AllSaints/05-catalog_calcFromItem.sql b/db/changes/10100-allSaints/05-catalog_calcFromItem.sql similarity index 100% rename from db/changes/10100-AllSaints/05-catalog_calcFromItem.sql rename to db/changes/10100-allSaints/05-catalog_calcFromItem.sql diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 13aeae436..4d6285603 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -7,8 +7,6 @@ import config from './config.js'; let currentUser; let actions = { - // Generic extensions - clickIfExists: async function(selector) { let exists = await this.exists(selector); if (exists) await this.click(selector); @@ -25,8 +23,6 @@ let actions = { }, selector); }, - // Salix specific extensions - changeLanguageToEnglish: async function() { let langSelector = '.user-popover vn-autocomplete[ng-model="$ctrl.lang"]'; @@ -49,14 +45,15 @@ let actions = { login: async function(userName) { if (currentUser !== userName) { - let logoutClicked = await this.clickIfExists('#logout'); + let accountClicked = await this.clickIfExists('#user'); - if (logoutClicked) { + if (accountClicked) { let buttonSelector = '.vn-dialog.shown button[response=accept]'; - await this.wait(buttonSelector => { - return document.querySelector(buttonSelector) != null - || location.hash == '#!/login'; - }, buttonSelector); + await this.waitToClick('#logout') + .wait(buttonSelector => { + return document.querySelector(buttonSelector) != null + || location.hash == '#!/login'; + }, buttonSelector); await this.clickIfExists(buttonSelector); } @@ -72,7 +69,7 @@ let actions = { currentUser = userName; } else - await this.waitToClick('vn-topbar a[ui-sref="home"]'); + await this.waitToClick('a[ui-sref=home]'); }, waitForLogin: async function(userName) { @@ -189,7 +186,7 @@ let actions = { let element = selectorMatches[0]; if (selectorMatches.length > 1) - throw new Error(`multiple matches of ${elementSelector} found`); + throw new Error(`Multiple matches of ${elementSelector} found`); let isVisible = false; if (element) { @@ -347,7 +344,7 @@ let actions = { .write('vn-searchbar input', searchValue) .click('vn-searchbar vn-icon[icon="search"]') .wait(100) - .waitForNumberOfElements('.searchResult', 1) + .waitForNumberOfElements('.search-result', 1) .evaluate(() => { return document.querySelector('ui-view vn-card vn-table') != null; }) @@ -362,15 +359,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 .collapsed') - .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(); }); }, @@ -429,10 +427,7 @@ let actions = { }, waitForSpinnerLoad: function() { - return this.wait(() => { - const element = document.querySelector('vn-spinner > div'); - return element.style.display == 'none'; - }); + return this.waitUntilNotPresent('vn-topbar vn-spinner'); } }; diff --git a/e2e/helpers/nightmare.js b/e2e/helpers/nightmare.js index 6706b6dc4..01dcdd5d3 100644 --- a/e2e/helpers/nightmare.js +++ b/e2e/helpers/nightmare.js @@ -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) => { diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 838878b60..d7b41bc64 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -9,7 +9,7 @@ export default { invoiceOutButton: '.modules-menu > li[ui-sref="invoiceOut.index"]', claimsButton: '.modules-menu > li[ui-sref="claim.index"]', returnToModuleIndexButton: 'a[ui-sref="order.index"]', - userMenuButton: 'vn-topbar #user', + userMenuButton: '#user', userLocalWarehouse: '.user-popover vn-autocomplete[ng-model="$ctrl.localWarehouseFk"]', userLocalBank: '.user-popover vn-autocomplete[ng-model="$ctrl.localBankFk"]', userLocalCompany: '.user-popover vn-autocomplete[ng-model="$ctrl.localCompanyFk"]', @@ -23,7 +23,7 @@ export default { clientsIndex: { searchClientInput: `vn-textfield input`, searchButton: 'vn-searchbar vn-icon[icon="search"]', - searchResult: 'vn-client-index .vn-list-item', + searchResult: 'vn-client-index .vn-item', createClientButton: `vn-float-button`, othersButton: 'vn-left-menu li[name="Others"] > a' }, @@ -180,7 +180,7 @@ export default { acceptDeleteButton: '.vn-confirm.shown button[response="accept"]' }, itemsIndex: { - searchIcon: 'vn-item-index vn-searchbar vn-icon[icon="search"]', + searchIcon: 'vn-searchbar vn-icon[icon="search"]', createItemButton: `vn-float-button`, searchResult: 'vn-item-index a.vn-tr', searchResultPreviewButton: 'vn-item-index .buttons > [icon="desktop_windows"]', @@ -221,7 +221,7 @@ export default { moreMenuRegularizeButton: '.vn-drop-down.shown li[name="Regularize stock"]', regularizeQuantityInput: '.vn-dialog.shown tpl-body > div > vn-textfield input', regularizeWarehouseAutocomplete: '.vn-dialog.shown vn-autocomplete[ng-model="$ctrl.warehouseFk"]', - editButton: 'vn-item-card vn-item-descriptor vn-float-button[icon="edit"]', + editButton: 'vn-item-descriptor vn-float-button[icon="edit"]', regularizeSaveButton: '.vn-dialog.shown tpl-buttons > button', inactiveIcon: 'vn-item-descriptor vn-icon[icon="icon-unavailable"]', navigateBackToIndex: 'vn-item-descriptor vn-icon[icon="chevron_left"]' @@ -324,20 +324,20 @@ export default { setOk: 'vn-ticket-summary vn-button[label="SET OK"] > button' }, ticketsIndex: { - openAdvancedSearchButton: 'vn-ticket-index vn-searchbar .append vn-icon[icon="arrow_drop_down"]', + openAdvancedSearchButton: 'vn-searchbar .append vn-icon[icon="arrow_drop_down"]', advancedSearchInvoiceOut: 'vn-ticket-search-panel vn-textfield[ng-model="filter.refFk"] input', newTicketButton: 'vn-ticket-index > a', searchResult: 'vn-ticket-index vn-card > vn-table > div > vn-tbody > a.vn-tr', searchWeeklyResult: 'vn-ticket-weekly-index vn-table vn-tbody > vn-tr', searchResultDate: 'vn-ticket-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(5)', - searchTicketInput: `vn-ticket-index vn-textfield input`, - searchWeeklyTicketInput: `vn-ticket-weekly-index vn-textfield input`, - searchWeeklyClearInput: 'vn-ticket-weekly-index vn-searchbar vn-icon[icon=clear]', + searchTicketInput: `vn-searchbar input`, + searchWeeklyTicketInput: `vn-searchbar input`, + searchWeeklyClearInput: 'vn-searchbar vn-icon[icon=clear]', advancedSearchButton: 'vn-ticket-search-panel button[type=submit]', - searchButton: 'vn-ticket-index vn-searchbar vn-icon[icon="search"]', - searchWeeklyButton: 'vn-ticket-weekly-index vn-searchbar vn-icon[icon="search"]', + 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"]', @@ -472,7 +472,7 @@ export default { zoneAutocomplete: 'vn-autocomplete[ng-model="$ctrl.zoneId"]', nextStepButton: 'vn-step-control .buttons > section:last-child vn-button', finalizeButton: 'vn-step-control .buttons > section:last-child button[type=submit]', - stepTwoTotalPriceDif: 'vn-ticket-basic-data-step-two > form > vn-card > vn-horizontal > table > tfoot > tr > td:nth-child(4)', + stepTwoTotalPriceDif: 'vn-ticket-basic-data-step-two vn-tfoot > vn-tr > :nth-child(6)', chargesReasonAutocomplete: 'vn-autocomplete[ng-model="$ctrl.ticket.option"]', }, ticketComponents: { @@ -516,9 +516,9 @@ export default { saveStateButton: `button[type=submit]` }, claimsIndex: { - searchClaimInput: `vn-claim-index vn-textfield input`, + searchClaimInput: `vn-searchbar input`, searchResult: 'vn-claim-index vn-card > vn-table > div > vn-tbody > a', - searchButton: 'vn-claim-index vn-searchbar vn-icon[icon="search"]' + searchButton: 'vn-searchbar vn-icon[icon="search"]' }, claimDescriptor: { moreMenu: 'vn-claim-descriptor vn-icon-menu[icon=more_vert]', @@ -584,7 +584,7 @@ export default { searchResultDate: 'vn-order-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(4)', searchResultAddress: 'vn-order-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(6)', searchOrderInput: `vn-order-index vn-textfield input`, - searchButton: 'vn-order-index vn-searchbar vn-icon[icon="search"]', + searchButton: 'vn-searchbar vn-icon[icon="search"]', createOrderButton: `vn-float-button`, }, orderDescriptor: { @@ -720,8 +720,8 @@ export default { navigateBackToIndex: 'vn-worker-descriptor vn-icon[icon="chevron_left"]' }, invoiceOutIndex: { - searchInvoiceOutInput: `vn-invoice-out-index vn-textfield input`, - searchButton: 'vn-invoice-out-index vn-searchbar vn-icon[icon="search"]', + searchInvoiceOutInput: `vn-searchbar input`, + searchButton: 'vn-searchbar vn-icon[icon="search"]', searchResult: 'vn-invoice-out-index vn-card > vn-table > div > vn-tbody > a.vn-tr', }, invoiceOutDescriptor: { diff --git a/e2e/paths/01-login/01_login.spec.js b/e2e/paths/01-login/01_login.spec.js index 03acc98a8..f612ad23c 100644 --- a/e2e/paths/01-login/01_login.spec.js +++ b/e2e/paths/01-login/01_login.spec.js @@ -30,7 +30,7 @@ describe('Login path', () => { it('should log in', async() => { const url = await nightmare .doLogin('employee', null) - .wait('#logout') + .wait('#user') .parsedUrl(); expect(url.hash).toEqual('#!/'); diff --git a/e2e/paths/04-item-module/01_summary.spec.js b/e2e/paths/04-item-module/01_summary.spec.js index bd06ebef4..8f493bfac 100644 --- a/e2e/paths/04-item-module/01_summary.spec.js +++ b/e2e/paths/04-item-module/01_summary.spec.js @@ -80,7 +80,7 @@ describe('Item summary path', () => { it('should search for other item', async() => { const result = await nightmare - .clearInput('vn-item-index vn-searchbar input') + .clearInput('vn-searchbar input') .waitToClick(selectors.itemsIndex.searchButton) .write(selectors.itemsIndex.searchItemInput, 'Melee weapon combat fist 15cm') .waitToClick(selectors.itemsIndex.searchButton) diff --git a/e2e/paths/05-ticket-module/02_expeditions_and_log.spec.js b/e2e/paths/05-ticket-module/02_expeditions_and_log.spec.js index 8e4645051..ec9b16fa4 100644 --- a/e2e/paths/05-ticket-module/02_expeditions_and_log.spec.js +++ b/e2e/paths/05-ticket-module/02_expeditions_and_log.spec.js @@ -7,7 +7,7 @@ describe('Ticket expeditions and log path', () => { beforeAll(() => { return nightmare .loginAndModule('production', 'ticket') - .accessToSearchResult('id:1') + .accessToSearchResult('1') .accessToSection('ticket.card.expedition'); }); diff --git a/e2e/paths/05-ticket-module/04_packages.spec.js b/e2e/paths/05-ticket-module/04_packages.spec.js index 30324aec2..b51bb8b95 100644 --- a/e2e/paths/05-ticket-module/04_packages.spec.js +++ b/e2e/paths/05-ticket-module/04_packages.spec.js @@ -7,7 +7,7 @@ describe('Ticket Create packages path', () => { beforeAll(() => { return nightmare .loginAndModule('employee', 'ticket') - .accessToSearchResult('id:1') + .accessToSearchResult('1') .accessToSection('ticket.card.package'); }); diff --git a/e2e/paths/05-ticket-module/05_tracking_state.spec.js b/e2e/paths/05-ticket-module/05_tracking_state.spec.js index 5797b6798..7c319f1c9 100644 --- a/e2e/paths/05-ticket-module/05_tracking_state.spec.js +++ b/e2e/paths/05-ticket-module/05_tracking_state.spec.js @@ -8,7 +8,7 @@ describe('Ticket Create new tracking state path', () => { beforeAll(() => { return nightmare .loginAndModule('production', 'ticket') - .accessToSearchResult('id:1') + .accessToSearchResult('1') .accessToSection('ticket.card.tracking.index'); }); @@ -44,7 +44,7 @@ describe('Ticket Create new tracking state path', () => { beforeAll(() => { return nightmare .loginAndModule('salesPerson', 'ticket') - .accessToSearchResult('id:1') + .accessToSearchResult('1') .accessToSection('ticket.card.tracking.index'); }); diff --git a/e2e/paths/05-ticket-module/08_components.spec.js b/e2e/paths/05-ticket-module/08_components.spec.js index 4603650ac..501c2eaad 100644 --- a/e2e/paths/05-ticket-module/08_components.spec.js +++ b/e2e/paths/05-ticket-module/08_components.spec.js @@ -7,7 +7,7 @@ describe('Ticket List components path', () => { beforeAll(() => { return nightmare .loginAndModule('employee', 'ticket') - .accessToSearchResult('id:1') + .accessToSearchResult('1') .accessToSection('ticket.card.components'); }); diff --git a/e2e/paths/05-ticket-module/09_weekly.spec.js b/e2e/paths/05-ticket-module/09_weekly.spec.js index a7a301d79..ad8a8020c 100644 --- a/e2e/paths/05-ticket-module/09_weekly.spec.js +++ b/e2e/paths/05-ticket-module/09_weekly.spec.js @@ -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'); @@ -160,7 +157,7 @@ describe('Ticket descriptor path', () => { it('should confirm the sixth weekly ticket was deleted', async() => { const result = await nightmare - .waitToClick('vn-ticket-weekly-index vn-searchbar vn-icon[icon=clear]') + .waitToClick('vn-searchbar vn-icon[icon=clear]') .waitToClick(selectors.ticketsIndex.searchWeeklyButton) .waitForNumberOfElements(selectors.ticketsIndex.searchWeeklyResult, 5) .countElement(selectors.ticketsIndex.searchWeeklyResult); diff --git a/e2e/paths/05-ticket-module/10_request.spec.js b/e2e/paths/05-ticket-module/10_request.spec.js index 0a31cb75a..44dc3e1af 100644 --- a/e2e/paths/05-ticket-module/10_request.spec.js +++ b/e2e/paths/05-ticket-module/10_request.spec.js @@ -7,7 +7,7 @@ describe('Ticket purchase request path', () => { beforeAll(() => { nightmare .loginAndModule('salesPerson', 'ticket') - .accessToSearchResult('id:16') + .accessToSearchResult('16') .accessToSection('ticket.card.request.index'); }); diff --git a/e2e/paths/05-ticket-module/11_diary.spec.js b/e2e/paths/05-ticket-module/11_diary.spec.js index aeec780e7..c64c0ba7b 100644 --- a/e2e/paths/05-ticket-module/11_diary.spec.js +++ b/e2e/paths/05-ticket-module/11_diary.spec.js @@ -1,5 +1,4 @@ import selectors from '../../helpers/selectors.js'; -import config from '../../helpers/config.js'; import createNightmare from '../../helpers/nightmare'; describe('Ticket diary path', () => { @@ -31,12 +30,9 @@ describe('Ticket diary path', () => { }); it(`should navigate to the item diary from the 1st sale item id descriptor popover`, async() => { - const itemId = 2; const url = await nightmare .waitToClick(selectors.ticketSummary.firstSaleItemId) .waitToClick(selectors.ticketSummary.popoverDiaryButton) - .waitForLogin('employee') - .goto(`${config.url}#!/item/${itemId}/diary?warehouseFk=1&ticketFk=1`) .parsedUrl(); expect(url.hash).toContain('/diary'); diff --git a/e2e/paths/05-ticket-module/13_services.spec.js b/e2e/paths/05-ticket-module/13_services.spec.js index 775357bda..01da91f1b 100644 --- a/e2e/paths/05-ticket-module/13_services.spec.js +++ b/e2e/paths/05-ticket-module/13_services.spec.js @@ -21,7 +21,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 diff --git a/front/core/components/autocomplete/index.js b/front/core/components/autocomplete/index.js index 9808fd667..e2c9b7ad4 100755 --- a/front/core/components/autocomplete/index.js +++ b/front/core/components/autocomplete/index.js @@ -208,11 +208,9 @@ export default class Autocomplete extends Field { onContainerKeyDown(event) { if (event.defaultPrevented) return; - switch (event.key) { case 'ArrowUp': case 'ArrowDown': - case 'Enter': this.showDropDown(); break; default: diff --git a/front/core/components/button-menu/index.js b/front/core/components/button-menu/index.js index 946e1fd7f..c19962b08 100644 --- a/front/core/components/button-menu/index.js +++ b/front/core/components/button-menu/index.js @@ -7,7 +7,7 @@ export default class ButtonMenu extends Button { constructor($element, $scope, $transclude) { super($element, $scope); this.$transclude = $transclude; - $element.on('click', e => this.onClick(e)); + $element.on('click', e => this.onButtonClick(e)); } get model() { @@ -41,8 +41,7 @@ export default class ButtonMenu extends Button { Object.assign(this.$.dropDown, props); } - onClick(event) { - if (this.disabled) return; + onButtonClick(event) { if (event.defaultPrevented) return; this.emit('open'); this.showDropDown(); diff --git a/front/core/components/button-menu/index.spec.js b/front/core/components/button-menu/index.spec.js index 1e8c048ff..87f677001 100644 --- a/front/core/components/button-menu/index.spec.js +++ b/front/core/components/button-menu/index.spec.js @@ -14,7 +14,7 @@ describe('Component vnButtonMenu', () => { $element.remove(); }); - describe('onClick(event)', () => { + describe('onButtonClick(event)', () => { it(`should emit the open event`, () => { spyOn(controller, 'emit'); @@ -23,7 +23,7 @@ describe('Component vnButtonMenu', () => { bubbles: true, cancelable: true }); - controller.onClick(event); + controller.onButtonClick(event); expect(controller.emit).toHaveBeenCalledWith('open'); }); diff --git a/front/core/components/button/style.scss b/front/core/components/button/style.scss index 74dcbcf9b..032c88cbb 100644 --- a/front/core/components/button/style.scss +++ b/front/core/components/button/style.scss @@ -39,19 +39,19 @@ } &.colored { color: white; - background-color: $color-main; + background-color: $color-button; box-shadow: 0 .15em .15em 0 rgba(0, 0, 0, .3); transition: background 200ms ease-in-out; &:not(.disabled) { &:hover, &:focus { - background-color: lighten($color-main, 10%); + background-color: lighten($color-button, 10%); } } } &.flat { - color: $color-main; + color: $color-button; background-color: transparent; box-shadow: none; transition: background 200ms ease-in-out; diff --git a/front/core/components/check/style.scss b/front/core/components/check/style.scss index 31715a2cd..b84b61ce5 100644 --- a/front/core/components/check/style.scss +++ b/front/core/components/check/style.scss @@ -19,7 +19,7 @@ } &.checked > .btn { border-color: transparent; - background-color: $color-main; + background-color: $color-button; & > .mark { top: 0; diff --git a/front/core/components/date-picker/index.js b/front/core/components/date-picker/index.js index 17ce19406..24f8cf90f 100644 --- a/front/core/components/date-picker/index.js +++ b/front/core/components/date-picker/index.js @@ -14,7 +14,9 @@ class DatePicker extends Field { let value = this.input.value; if (value) { - date = new Date(value); + let ymd = value.split('-') + .map(e => parseInt(e)); + date = new Date(ymd[0], ymd[1] - 1, ymd[2]); if (this.field) { let orgDate = this.field instanceof Date diff --git a/front/core/components/date-picker/index.spec.js b/front/core/components/date-picker/index.spec.js index 411a92105..2dd419e07 100644 --- a/front/core/components/date-picker/index.spec.js +++ b/front/core/components/date-picker/index.spec.js @@ -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); + }); + }); }); diff --git a/front/core/components/dialog/index.js b/front/core/components/dialog/index.js index 0891542a2..7a7cb5f9f 100644 --- a/front/core/components/dialog/index.js +++ b/front/core/components/dialog/index.js @@ -29,6 +29,10 @@ export default class Dialog extends Popup { * @return {Promise} A promise that will be resolved with response when dialog is closed */ show(data, responseHandler) { + if (this.shown) + return this.$q.reject(new Error('Dialog already shown')); + super.show(); + if (typeof data == 'function') { responseHandler = data; data = null; @@ -36,27 +40,27 @@ export default class Dialog extends Popup { this.data = data; this.showHandler = responseHandler; - super.show(); return this.$q(resolve => { this.resolve = resolve; }); } /** - * Hides the dialog. + * Hides the dialog resolving the promise returned by show(). * * @param {String} response The response */ hide(response) { if (!this.shown) return; - this.showHandler = null; super.hide(); + + this.showHandler = null; if (this.resolve) this.resolve(response); } /** - * Calls the response handler. + * Calls the response handlers. * * @param {String} response The response code * @return {Boolean} The response handler return diff --git a/front/core/components/dialog/index.spec.js b/front/core/components/dialog/index.spec.js index a898261fb..8c41bc060 100644 --- a/front/core/components/dialog/index.spec.js +++ b/front/core/components/dialog/index.spec.js @@ -28,14 +28,6 @@ describe('Component vnDialog', () => { expect(called).toBeTruthy(); }); - it(`should hide the dialog when response is given`, () => { - controller.show(); - spyOn(controller, 'hide'); - controller.respond('answer'); - - expect(controller.hide).toHaveBeenCalledWith('answer'); - }); - it(`should not hide the dialog when false is returned from response handler`, () => { controller.show(() => false); spyOn(controller, 'hide'); @@ -46,12 +38,13 @@ describe('Component vnDialog', () => { }); describe('hide()', () => { - it(`should do nothing if it's already hidden`, () => { - controller.onResponse = () => {}; - spyOn(controller, 'onResponse'); + it(`should resolve the promise returned by show`, () => { + let resolved = true; + controller.show().then(() => resolved = true); controller.hide(); + $scope.$apply(); - expect(controller.onResponse).not.toHaveBeenCalledWith(); + expect(resolved).toBeTruthy(); }); }); @@ -94,7 +87,7 @@ describe('Component vnDialog', () => { expect(controller.onAccept).toHaveBeenCalledWith({$response: 'accept'}); }); - it(`should resolve the promise returned by show() with response when hidden`, () => { + it(`should resolve the promise returned by show() with response`, () => { let response; controller.show().then(res => response = res); controller.respond('response'); diff --git a/front/core/components/dialog/style.scss b/front/core/components/dialog/style.scss index 9461a0063..2f3d9a028 100644 --- a/front/core/components/dialog/style.scss +++ b/front/core/components/dialog/style.scss @@ -36,7 +36,7 @@ background-color: transparent; border: none; border-radius: .1em; - color: $color-main; + color: $color-button; font-family: vn-font-bold; padding: .7em; margin: -0.7em; diff --git a/front/core/components/drop-down/index.js b/front/core/components/drop-down/index.js index 163553aeb..9f2dfe424 100644 --- a/front/core/components/drop-down/index.js +++ b/front/core/components/drop-down/index.js @@ -5,6 +5,7 @@ import template from './index.html'; import ArrayModel from '../array-model/array-model'; import CrudModel from '../crud-model/crud-model'; import {mergeWhere} from 'vn-loopback/util/filter'; +import focus from '../../lib/focus'; /** * @event select Thrown when model item is selected @@ -86,9 +87,11 @@ export default class DropDown extends Popover { * @param {String} search The initial search term or %null */ show(parent, search) { - this._activeOption = -1; + if (this.shown) return; super.show(parent); + this._activeOption = -1; + this.list = this.popup.querySelector('.list'); this.ul = this.popup.querySelector('ul'); @@ -102,21 +105,25 @@ export default class DropDown extends Popover { this.search = search; this.buildList(); - let input = this.popup.querySelector('input'); - setTimeout(() => input.focus()); + focus(this.popup.querySelector('input')); } - onClose() { + hide() { + if (!this.shown) return; + super.hide(); + this.document.removeEventListener('keydown', this.docKeyDownHandler); this.docKeyDownHandler = null; this.list.removeEventListener('scroll', this.listScrollHandler); this.listScrollHandler = null; + } + onClose() { + this.destroyList(); this.list = null; this.ul = null; - this.destroyList(); super.onClose(); } @@ -387,7 +394,7 @@ export default class DropDown extends Popover { let filter = { order, - limit: this.limit || 8 + limit: this.limit || 30 }; if (model instanceof CrudModel) { diff --git a/front/core/components/field/index.html b/front/core/components/field/index.html index 8d12ddd77..d614d157f 100644 --- a/front/core/components/field/index.html +++ b/front/core/components/field/index.html @@ -28,8 +28,7 @@ ng-transclude="append" class="append"> -