From b8b92b16e95401ebbc65c1f8876340765b71205b Mon Sep 17 00:00:00 2001 From: jeremielodi Date: Wed, 9 Sep 2020 14:15:41 +0100 Subject: [PATCH] start end-to-end test --- test/data.sql | 7 +++++- test/end-to-end/fillForm/fillForm.page.js | 1 - .../shared/components/bhDateEditor.js | 2 +- test/end-to-end/stock/stock.entry.page.js | 10 +++++++++ test/end-to-end/stock/stock.entry.spec.js | 22 +++++++++++++++++++ .../stock/stock.inventories.spec.js | 6 ++--- 6 files changed, 42 insertions(+), 6 deletions(-) diff --git a/test/data.sql b/test/data.sql index 78b6470556..69f1f7c5c4 100644 --- a/test/data.sql +++ b/test/data.sql @@ -3417,5 +3417,10 @@ INSERT INTO `village` (`uuid`, `name`, `sector_uuid`, `longitude`, `latitude`) V INSERT INTO `donor`(`id`, `display_name`) VALUES(1, 'Jeremie LODI'); +SET @donation_uuid = HUID('ae735e99-8faf-417b-aa63-9b404fca390d'); INSERT INTO `donation`(`uuid`, `date`, `donor_id`) -VALUES(HUID('ae735e99-8faf-417b-aa63-9b404fca390d'), NOW(), 1); +VALUES(@donation_uuid, NOW(), 1); + + +INSERT INTO `donation_item` (`uuid`, `donation_uuid`, `inventory_uuid`, `quantity`, `unit_price`) +VALUES(HUID(uuid()), @donation_uuid, @multivitamine, 200, 1300); \ No newline at end of file diff --git a/test/end-to-end/fillForm/fillForm.page.js b/test/end-to-end/fillForm/fillForm.page.js index 0cca75ace5..13fcf08029 100644 --- a/test/end-to-end/fillForm/fillForm.page.js +++ b/test/end-to-end/fillForm/fillForm.page.js @@ -42,7 +42,6 @@ class FillFormManagementPage { await browser.findElement(by.css('[name="nombreFois"]')).sendKeys(fillForm.nombreFois); await components.dateEditor.set(new Date(fillForm.date), null, '.title'); await browser.findElement(by.css('[name="voie"]')).sendKeys(fillForm.voie); - components.dateEditor.set(new Date(fillForm.date)); await browser.findElement(by.css('[ng-model="hours"]')).sendKeys(fillForm.hours); await browser.findElement(by.css('[ng-model="minutes"]')).sendKeys(fillForm.minutes); diff --git a/test/end-to-end/shared/components/bhDateEditor.js b/test/end-to-end/shared/components/bhDateEditor.js index d1f7724b37..0a5b551d25 100644 --- a/test/end-to-end/shared/components/bhDateEditor.js +++ b/test/end-to-end/shared/components/bhDateEditor.js @@ -16,7 +16,7 @@ module.exports = { * @param {String} id - a CSS id to select on. */ set : async function set(date, id, elementClick) { - const elementCloseComponent = elementClick || '.header-image'; + const elementCloseComponent = elementClick || '[bh-date-editor-label]'; // fail hard if the user did not pass into /* if (!(date instanceof Date)) { diff --git a/test/end-to-end/stock/stock.entry.page.js b/test/end-to-end/stock/stock.entry.page.js index 333368dd59..e62beb3407 100644 --- a/test/end-to-end/stock/stock.entry.page.js +++ b/test/end-to-end/stock/stock.entry.page.js @@ -27,6 +27,16 @@ function StockEntryPage() { await FU.modal.submit(); }; + /** + * @method setDonation + * @param {string} rowNumber - the purchase line on the modal + */ + page.setDonation = async (rowNumber) => { + await components.stockEntryExitType.set('donation'); + await GU.selectRow('DonationGrid', rowNumber); + await FU.modal.submit(); + }; + /** * @method setTransfer * @param {string} rowNumber - movement line on the modal grid diff --git a/test/end-to-end/stock/stock.entry.spec.js b/test/end-to-end/stock/stock.entry.spec.js index fe062b93b4..2fa9a367cf 100644 --- a/test/end-to-end/stock/stock.entry.spec.js +++ b/test/end-to-end/stock/stock.entry.spec.js @@ -21,7 +21,29 @@ function StockEntryTests() { await page.setDepot(DEPOT_PRINCIPAL); }); + it('Should enter stock from a donation', async () => { + + // select the purchase order + await page.setDonation(0); + + await page.setDate(new Date()); + + await page.setDescription(DESCRIPTION.concat(' - Donation')); + + const lots = [ + { label : 'LY-ONE', quantity : 100, expiration_date : expireInThreeYears }, + { label : 'LY-TWO', quantity : 50, expiration_date : expireInTwoYears }, + { label : 'LY-THREE', quantity : 50, expiration_date : expireInOneYear }, + ]; + + await page.setLots(0, lots, false); + + // submit + await page.submit(); + }); + it('Should enter stock from a purchase order', async () => { + await this.timeout(60000); // select the purchase order await page.setPurchase(0); diff --git a/test/end-to-end/stock/stock.inventories.spec.js b/test/end-to-end/stock/stock.inventories.spec.js index d518cbcd3c..fe3599c8cc 100644 --- a/test/end-to-end/stock/stock.inventories.spec.js +++ b/test/end-to-end/stock/stock.inventories.spec.js @@ -57,10 +57,10 @@ function StockInventoriesRegistryTests() { await filters.resetFilters(); }); - it('find 3 inventory by state (security reached)', async () => { + it('find 2 inventory by state (security reached)', async () => { await FU.radio('$ctrl.searchQueries.status', 2); await FU.modal.submit(); - await GU.expectRowCount(gridId, 3); + await GU.expectRowCount(gridId, 2); await filters.resetFilters(); }); @@ -77,7 +77,7 @@ function StockInventoriesRegistryTests() { await FU.radio('$ctrl.searchQueries.status', 4); await FU.modal.submit(); - await GU.expectRowCount(gridId, 7); + await GU.expectRowCount(gridId, 8); await filters.resetFilters(); });