diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index d37fc9c75..a52e24736 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2233,8 +2233,8 @@ INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', INSERT INTO `vn`.`temperature`(`code`, `name`, `description`) VALUES - ('WARM', 'Warm', 'Warm'), - ('COOL', 'Cool', 'Cool'); + ('warm', 'Warm', 'Warm'), + ('cool', 'Cool', 'Cool'); INSERT INTO `vn`.`thermograph`(`id`, `model`) VALUES diff --git a/e2e/helpers/puppeteer.js b/e2e/helpers/puppeteer.js index 70546b080..f562cf588 100644 --- a/e2e/helpers/puppeteer.js +++ b/e2e/helpers/puppeteer.js @@ -5,10 +5,11 @@ import {url as defaultURL} from './config'; export async function getBrowser() { const args = [ - '--no-sandbox', `--window-size=${ 1920 },${ 1080 }`, - '--single-process', - '--no-zygote' + // '--disable-gpu' + // '--no-sandbox', + // '--single-process', + // '--no-zygote', // '--disable-dev-shm-usage' // '--full-memory-crash-report', // '--unlimited-storage' @@ -26,7 +27,7 @@ export async function getBrowser() { args, defaultViewport: null, headless: headless, - slowMo: 0, // slow down by ms + slowMo: 5, // slow down by ms // ignoreDefaultArgs: ['--disable-extensions'], // executablePath: '/usr/bin/google-chrome-stable', // executablePath: '/usr/bin/firefox-developer-edition', diff --git a/e2e/paths/04-item/08_regularize.spec.js b/e2e/paths/04-item/08_regularize.spec.js index a18f81e53..97c45643f 100644 --- a/e2e/paths/04-item/08_regularize.spec.js +++ b/e2e/paths/04-item/08_regularize.spec.js @@ -38,7 +38,6 @@ describe('Item regularize path', () => { }); it('should open the regularize dialog and check the warehouse matches the local user settings', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.itemDescriptor.moreMenu); await page.waitToClick(selectors.itemDescriptor.moreMenuRegularizeButton); const result = await page.waitToGetProperty(selectors.itemDescriptor.regularizeWarehouse, 'value'); @@ -108,7 +107,6 @@ describe('Item regularize path', () => { }); it('should regularize the item once more', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.itemDescriptor.moreMenu); await page.waitToClick(selectors.itemDescriptor.moreMenuRegularizeButton); await page.write(selectors.itemDescriptor.regularizeQuantity, '100'); diff --git a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js index 0ce803bea..55bbdf9ff 100644 --- a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js +++ b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js @@ -196,7 +196,6 @@ describe('Ticket Edit sale path', () => { }); it('should select the third sale and create a claim of it', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox); await page.waitToClick(selectors.ticketSales.moreMenu); await page.waitToClick(selectors.ticketSales.moreMenuCreateClaim); @@ -355,7 +354,7 @@ describe('Ticket Edit sale path', () => { it('should mark the first sale as reserved', async() => { await page.waitToClick(selectors.ticketSales.firstSaleCheckbox); - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work + await page.waitToClick(selectors.ticketSales.moreMenu); await page.waitToClick(selectors.ticketSales.moreMenuReserve); await page.closePopup(); @@ -366,7 +365,6 @@ describe('Ticket Edit sale path', () => { }); it('should unmark the first sale as reserved', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.ticketSales.moreMenu); await page.waitToClick(selectors.ticketSales.moreMenuUnmarkReseved); await page.waitForClassPresent(selectors.ticketSales.firstSaleReservedIcon, 'ng-hide'); diff --git a/e2e/paths/05-ticket/09_weekly.spec.js b/e2e/paths/05-ticket/09_weekly.spec.js index be5b1e153..2392de28f 100644 --- a/e2e/paths/05-ticket/09_weekly.spec.js +++ b/e2e/paths/05-ticket/09_weekly.spec.js @@ -28,7 +28,6 @@ describe('Ticket descriptor path', () => { }); it('should add the ticket to thursday turn using the descriptor more menu', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.ticketDescriptor.moreMenu); await page.waitToClick(selectors.ticketDescriptor.moreMenuAddToTurn); await page.waitToClick(selectors.ticketDescriptor.thursdayButton); @@ -64,7 +63,6 @@ describe('Ticket descriptor path', () => { }); it('should add the ticket to saturday turn using the descriptor more menu', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.ticketDescriptor.moreMenu); await page.waitToClick(selectors.ticketDescriptor.moreMenuAddToTurn); await page.waitToClick(selectors.ticketDescriptor.saturdayButton); diff --git a/e2e/paths/05-ticket/12_descriptor.spec.js b/e2e/paths/05-ticket/12_descriptor.spec.js index e63d4f431..3429acc89 100644 --- a/e2e/paths/05-ticket/12_descriptor.spec.js +++ b/e2e/paths/05-ticket/12_descriptor.spec.js @@ -22,7 +22,6 @@ describe('Ticket descriptor path', () => { }); it(`should update the shipped hour using the descriptor menu`, async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.ticketDescriptor.moreMenu); await page.waitToClick(selectors.ticketDescriptor.moreMenuChangeShippedHour); await page.pickTime(selectors.ticketDescriptor.changeShippedHour, '08:15'); @@ -41,7 +40,6 @@ describe('Ticket descriptor path', () => { }); it('should delete the ticket using the descriptor menu', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.ticketDescriptor.moreMenu); await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteTicket); await page.waitToClick(selectors.ticketDescriptor.acceptDialog); @@ -67,7 +65,6 @@ describe('Ticket descriptor path', () => { describe('Restore ticket', () => { it('should restore the ticket using the descriptor menu', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.ticketDescriptor.moreMenu); await page.waitToClick(selectors.ticketDescriptor.moreMenuRestoreTicket); await page.waitToClick(selectors.ticketDescriptor.acceptDialog); @@ -85,7 +82,6 @@ describe('Ticket descriptor path', () => { }); it('should open the add stowaway dialog', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitForFunction(() => { let element = document.querySelector('vn-ticket-descriptor-menu'); return element.$ctrl.canShowStowaway === true; @@ -118,7 +114,6 @@ describe('Ticket descriptor path', () => { }); it('should delete the stowaway', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.ticketDescriptor.moreMenu); await page.waitForContentLoaded(); await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteStowawayButton); @@ -150,7 +145,6 @@ describe('Ticket descriptor path', () => { }); it('should invoice the ticket using the descriptor menu', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.ticketDescriptor.moreMenu); await page.waitForContentLoaded(); await page.waitToClick(selectors.ticketDescriptor.moreMenuMakeInvoice); @@ -182,7 +176,6 @@ describe('Ticket descriptor path', () => { describe('SMS', () => { it('should send the payment SMS using the descriptor menu', async() => { - await page.waitForTimeout(2000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.ticketDescriptor.moreMenu); await page.waitToClick(selectors.ticketDescriptor.moreMenuPaymentSMS); await page.waitForSelector(selectors.ticketDescriptor.SMStext); @@ -194,7 +187,6 @@ describe('Ticket descriptor path', () => { }); it('should send the import SMS using the descriptor menu', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.ticketDescriptor.moreMenu); await page.waitForContentLoaded(); await page.waitToClick(selectors.ticketDescriptor.moreMenuSendImportSms); diff --git a/e2e/paths/05-ticket/14_create_ticket.spec.js b/e2e/paths/05-ticket/14_create_ticket.spec.js index 1c0e10e6d..bfaa08775 100644 --- a/e2e/paths/05-ticket/14_create_ticket.spec.js +++ b/e2e/paths/05-ticket/14_create_ticket.spec.js @@ -62,7 +62,6 @@ describe('Ticket create path', () => { }); it('should make the previously created ticket the stowaway of the current ticket', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.ticketDescriptor.moreMenu); await page.waitToClick(selectors.ticketDescriptor.moreMenuAddStowaway); await page.waitToClick(selectors.ticketDescriptor.addStowawayDialogFirstTicket); @@ -72,7 +71,6 @@ describe('Ticket create path', () => { }); it('should delete the current ticket', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.ticketDescriptor.moreMenu); await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteTicket); await page.waitToClick(selectors.ticketDescriptor.acceptDialog); diff --git a/e2e/paths/05-ticket/15_create_ticket_from_client.spec.js b/e2e/paths/05-ticket/15_create_ticket_from_client.spec.js index a27050daa..a68ce894e 100644 --- a/e2e/paths/05-ticket/15_create_ticket_from_client.spec.js +++ b/e2e/paths/05-ticket/15_create_ticket_from_client.spec.js @@ -17,7 +17,6 @@ describe('Ticket create from client path', () => { }); it('should click the create simple ticket on the descriptor menu', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.clientDescriptor.moreMenu); await page.waitToClick(selectors.clientDescriptor.simpleTicketButton); await page.waitForState('ticket.create'); diff --git a/e2e/paths/09-invoice-in/02_descriptor.spec.js b/e2e/paths/09-invoice-in/02_descriptor.spec.js index 28b8e7ae3..02bbce7ac 100644 --- a/e2e/paths/09-invoice-in/02_descriptor.spec.js +++ b/e2e/paths/09-invoice-in/02_descriptor.spec.js @@ -18,7 +18,6 @@ describe('InvoiceIn descriptor path', () => { }); it('should clone the invoiceIn using the descriptor more menu', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.invoiceInDescriptor.moreMenu); await page.waitToClick(selectors.invoiceInDescriptor.moreMenuCloneInvoiceIn); await page.waitToClick(selectors.invoiceInDescriptor.acceptButton); @@ -32,7 +31,6 @@ describe('InvoiceIn descriptor path', () => { }); it('should delete the cloned invoiceIn using the descriptor more menu', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.invoiceInDescriptor.moreMenu); await page.waitToClick(selectors.invoiceInDescriptor.moreMenuDeleteInvoiceIn); await page.waitToClick(selectors.invoiceInDescriptor.acceptButton); diff --git a/e2e/paths/09-invoice-out/02_descriptor.spec.js b/e2e/paths/09-invoice-out/02_descriptor.spec.js index 222237b4f..8d403e083 100644 --- a/e2e/paths/09-invoice-out/02_descriptor.spec.js +++ b/e2e/paths/09-invoice-out/02_descriptor.spec.js @@ -38,7 +38,6 @@ describe('InvoiceOut descriptor path', () => { }); it('should delete the invoiceOut using the descriptor more menu', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.invoiceOutDescriptor.moreMenu); await page.waitToClick(selectors.invoiceOutDescriptor.moreMenuDeleteInvoiceOut); await page.waitToClick(selectors.invoiceOutDescriptor.acceptDeleteButton); diff --git a/e2e/paths/09-invoice-out/03_manualInvoice.spec.js b/e2e/paths/09-invoice-out/03_manualInvoice.spec.js index 71ece0030..396f84bfb 100644 --- a/e2e/paths/09-invoice-out/03_manualInvoice.spec.js +++ b/e2e/paths/09-invoice-out/03_manualInvoice.spec.js @@ -16,9 +16,7 @@ describe('InvoiceOut manual invoice path', () => { }); it('should open the manual invoice form', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.invoiceOutIndex.createInvoice); - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.invoiceOutIndex.createManualInvoice); await page.waitForSelector(selectors.invoiceOutIndex.manualInvoiceForm); }); @@ -46,7 +44,6 @@ describe('InvoiceOut manual invoice path', () => { }); it('should now open the manual invoice form', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.invoiceOutIndex.createInvoice); await page.waitToClick(selectors.invoiceOutIndex.createManualInvoice); await page.waitForSelector(selectors.invoiceOutIndex.manualInvoiceForm); diff --git a/e2e/paths/10-travel/03_descriptor.spec.js b/e2e/paths/10-travel/03_descriptor.spec.js index d61818866..619228f35 100644 --- a/e2e/paths/10-travel/03_descriptor.spec.js +++ b/e2e/paths/10-travel/03_descriptor.spec.js @@ -34,7 +34,6 @@ describe('Travel descriptor path', () => { }); it('should be redirected to the create entry view', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.travelDescriptor.dotMenu); await page.waitToClick(selectors.travelDescriptor.dotMenuAddEntry); await page.waitForState('entry.create'); @@ -90,7 +89,6 @@ describe('Travel descriptor path', () => { }); it('should be redirected to the create travel when using the clone option of the dot menu', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.travelDescriptor.dotMenu); await page.waitToClick(selectors.travelDescriptor.dotMenuClone); await page.respondToDialog('accept'); @@ -116,7 +114,6 @@ describe('Travel descriptor path', () => { }); it('should atempt to clone the travel and its entries using the descriptor menu but receive an error', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.travelDescriptor.dotMenu); await page.waitToClick(selectors.travelDescriptor.dotMenuCloneWithEntries); await page.waitToClick(selectors.travelDescriptor.acceptClonation); diff --git a/e2e/paths/11-zone/02_descriptor.spec.js b/e2e/paths/11-zone/02_descriptor.spec.js index d88829907..1de84d601 100644 --- a/e2e/paths/11-zone/02_descriptor.spec.js +++ b/e2e/paths/11-zone/02_descriptor.spec.js @@ -17,7 +17,6 @@ describe('Zone descriptor path', () => { }); it('should eliminate the zone using the descriptor option', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.zoneDescriptor.menu); await page.waitToClick(selectors.zoneDescriptor.deleteZone); await page.respondToDialog('accept'); diff --git a/e2e/paths/14-account/01_create_and_basic_data.spec.js b/e2e/paths/14-account/01_create_and_basic_data.spec.js index 204da363c..5a07119e7 100644 --- a/e2e/paths/14-account/01_create_and_basic_data.spec.js +++ b/e2e/paths/14-account/01_create_and_basic_data.spec.js @@ -91,7 +91,6 @@ describe('Account create and basic data path', () => { }); it('should activate the account using the descriptor menu', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.accountDescriptor.menuButton); await page.waitToClick(selectors.accountDescriptor.activateAccount); await page.waitToClick(selectors.accountDescriptor.acceptButton); @@ -139,7 +138,6 @@ describe('Account create and basic data path', () => { describe('Set password', () => { it('should set the password using the descriptor menu', async() => { - await page.waitForTimeout(1000); // initialization of functionality takes about 1000ms to work await page.waitToClick(selectors.accountDescriptor.menuButton); await page.waitToClick(selectors.accountDescriptor.setPassword); await page.write(selectors.accountDescriptor.newPassword, 'quantum.crypt0graphy'); diff --git a/modules/travel/front/thermograph/create/index.js b/modules/travel/front/thermograph/create/index.js index b6d78fc50..fa2c1261a 100644 --- a/modules/travel/front/thermograph/create/index.js +++ b/modules/travel/front/thermograph/create/index.js @@ -1,5 +1,6 @@ import ngModule from '../../module'; import Section from 'salix/components/section'; +import UserError from 'core/lib/user-error'; class Controller extends Section { constructor($element, $) { @@ -56,7 +57,7 @@ class Controller extends Section { } onAddThermographClick(event) { - const defaultTemperature = 'COOL'; + const defaultTemperature = 'cool'; const defaultModel = 'DISPOSABLE'; event.preventDefault(); @@ -72,6 +73,15 @@ class Controller extends Section { } onNewThermographAccept() { + const hasMissingField = + !this.newThermograph.thermographId || + !this.newThermograph.warehouseId || + !this.newThermograph.temperatureFk || + !this.newThermograph.model; + + if (hasMissingField) + throw new UserError(`Some fields are invalid`); + return this.$http.post(`Thermographs/createThermograph`, this.newThermograph) .then(res => this.dms.thermographId = res.data.id); } diff --git a/modules/travel/front/thermograph/create/index.spec.js b/modules/travel/front/thermograph/create/index.spec.js index c2b94d3e8..1ad263d31 100644 --- a/modules/travel/front/thermograph/create/index.spec.js +++ b/modules/travel/front/thermograph/create/index.spec.js @@ -79,8 +79,24 @@ describe('Ticket', () => { }); describe('onNewThermographAccept()', () => { - it('should set the created thermograph id on to the controller for the autocomplete to use it', () => { - const response = {id: 'the created id'}; + it('should set the created thermograph data on to the controller for the autocomplete to use it', () => { + const id = 'the created id'; + const warehouseId = 1; + const temperatureId = 'cool'; + const model = 'my model'; + + controller.newThermograph = { + thermographId: id, + warehouseId: warehouseId, + temperatureFk: temperatureId, + model: model + }; + const response = { + id: id, + warehouseId: warehouseId, + temperatureFk: temperatureId, + model: model + }; $httpBackend.when('POST', `Thermographs/createThermograph`).respond(response); controller.onNewThermographAccept(); $httpBackend.flush();