From 33452b81fb59945546bb85c786495d48fbcfdba6 Mon Sep 17 00:00:00 2001 From: Cristina Stefan <50820854+cristinastefan90@users.noreply.github.com> Date: Wed, 28 Aug 2019 09:15:00 +0300 Subject: [PATCH 1/5] #316 select all rows on current page #316 Materialentnahme complete HUs --- .../purchase/purchase_order_material_receipt_invoice.js | 2 +- cypress/support/commands/navigation.js | 7 +++++++ cypress/support/index.d.ts | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cypress/integration/purchase/purchase_order_material_receipt_invoice.js b/cypress/integration/purchase/purchase_order_material_receipt_invoice.js index 7938ec03..a10b9f4d 100644 --- a/cypress/integration/purchase/purchase_order_material_receipt_invoice.js +++ b/cypress/integration/purchase/purchase_order_material_receipt_invoice.js @@ -151,7 +151,7 @@ describe('Create a purchase order and Material Receipts', function() { }); it('Select all candidates and run action "Generate Invoices"', function() { - cy.get('body').type('{alt}a'); // select all on this page + cy.selectAllRowsOnCurrentPage(); cy.readAllNotifications(); cy.executeHeaderActionWithDialog('C_Invoice_Candidate_EnqueueSelectionForInvoicing'); // no parameters are changed for this process diff --git a/cypress/support/commands/navigation.js b/cypress/support/commands/navigation.js index 43c3c923..f9e3e359 100644 --- a/cypress/support/commands/navigation.js +++ b/cypress/support/commands/navigation.js @@ -149,3 +149,10 @@ Cypress.Commands.add('selectRowByColumnAndValue', (columnName, expectedValue, mo }); }); }); +/** + * Select all rows on the current page + * + */ +Cypress.Commands.add('selectAllRowsOnCurrentPage', () => { + cy.get('body').type('{alt}a'); +}); diff --git a/cypress/support/index.d.ts b/cypress/support/index.d.ts index 3939a424..f5a10187 100644 --- a/cypress/support/index.d.ts +++ b/cypress/support/index.d.ts @@ -646,7 +646,10 @@ declare namespace Cypress { */ selectRowByColumnAndValue(columnName: string, expectedValue: string | number, modal ?: boolean, force ?: boolean): Chainable - + /** + * Select all rows on the current page + */ + selectAllRowsOnCurrentPage(): Chainable } } From d695ec49362b94c9365551cc29f96d4069f843e3 Mon Sep 17 00:00:00 2001 From: Cristina Stefan <50820854+cristinastefan90@users.noreply.github.com> Date: Wed, 28 Aug 2019 16:39:27 +0300 Subject: [PATCH 2/5] #316 partial impl #316 Materialentnahme complete HUs --- .../materialentnahme_complete_HUs.js | 186 ++++++++++++++++++ cypress/support/commands/navigation.js | 19 ++ cypress/support/index.d.ts | 5 + 3 files changed, 210 insertions(+) create mode 100644 cypress/integration/logistics/materialentnahme_complete_HUs.js diff --git a/cypress/integration/logistics/materialentnahme_complete_HUs.js b/cypress/integration/logistics/materialentnahme_complete_HUs.js new file mode 100644 index 00000000..842020f6 --- /dev/null +++ b/cypress/integration/logistics/materialentnahme_complete_HUs.js @@ -0,0 +1,186 @@ +import { BPartner } from '../../support/utils/bpartner'; +import { DiscountSchema } from '../../support/utils/discountschema'; +import { ProductCategory } from '../../support/utils/product'; +import { PackingMaterial } from '../../support/utils/packing_material'; +import { PackingInstructions } from '../../support/utils/packing_instructions'; +import { PackingInstructionsVersion } from '../../support/utils/packing_instructions_version'; +import { Builder } from '../../support/utils/builder'; +import { appendHumanReadableNow } from '../../support/utils/utils'; +import { PurchaseOrder, PurchaseOrderLine } from '../../support/utils/purchase_order'; +import { + applyFilters, + selectNotFrequentFilterWidget, + toggleNotFrequentFilters, + clearNotFrequentFilters, +} from '../../support/functions'; + +let productForPackingMaterial; +let packingInstructionsName; +let productName1; +let productCategoryName; +let discountSchemaName; +let priceSystemName; +let priceListName; +let priceListVersionName; +let productType; +let vendorName; +let materialentnahme; +let warehouseName; + +let totalHUs; +let countOnPage; +let countAfterMoving; + +it('Read the fixture', function() { + cy.fixture('logistics/materialentnahme_complete_HU.json').then(f => { + productForPackingMaterial = appendHumanReadableNow(f['productForPackingMaterial']); + packingInstructionsName = appendHumanReadableNow(f['packingInstructionsName']); + productName1 = appendHumanReadableNow(f['productName1']); + productCategoryName = appendHumanReadableNow(f['productCategoryName']); + discountSchemaName = appendHumanReadableNow(f['discountSchemaName']); + priceSystemName = appendHumanReadableNow(f['priceSystemName']); + priceListName = appendHumanReadableNow(f['priceListName']); + priceListVersionName = appendHumanReadableNow(f['priceListVersionName']); + productType = f['productType']; + vendorName = appendHumanReadableNow(f['vendorName']); + materialentnahme = f['materialentnahme']; + warehouseName = f['warehouseName']; + }); +}); + +describe('Change warehouse to Materialentnahmelager', function() { + it('Create price entities', function() { + Builder.createBasicPriceEntities(priceSystemName, priceListVersionName, priceListName, false); + cy.fixture('discount/discountschema.json').then(discountSchemaJson => { + Object.assign(new DiscountSchema(), discountSchemaJson) + .setName(discountSchemaName) + .apply(); + }); + }); + it('Create packing related entities', function() { + // eslint-disable-next-line + Builder.createProductWithPriceUsingExistingCategory(priceListName, productForPackingMaterial, productForPackingMaterial, productType, "24_Gebinde"); + cy.fixture('product/packing_material.json').then(packingMaterialJson => { + Object.assign(new PackingMaterial(), packingMaterialJson) + .setName(productForPackingMaterial) + .setProduct(productForPackingMaterial) + .apply(); + }); + cy.fixture('product/packing_instructions.json').then(packingInstructionsJson => { + Object.assign(new PackingInstructions(), packingInstructionsJson) + .setName(packingInstructionsName) + .apply(); + }); + cy.fixture('product/packing_instructions_version.json').then(pivJson => { + Object.assign(new PackingInstructionsVersion(), pivJson) + .setName(packingInstructionsName) + .setPackingInstructions(packingInstructionsName) + .setPackingMaterial(productForPackingMaterial) + .apply(); + }); + }); + + it('Create category', function() { + cy.fixture('product/simple_productCategory.json').then(productCategoryJson => { + Object.assign(new ProductCategory(), productCategoryJson) + .setName(productCategoryName) + .apply(); + }); + }); + + it('Create product1', function() { + Builder.createProductWithPriceAndCUTUAllocationUsingExistingCategory( + productCategoryName, + productCategoryName, + priceListName, + productName1, + productName1, + productType, + packingInstructionsName + ); + }); + + it('Create vendor', function() { + cy.fixture('sales/simple_vendor.json').then(vendorJson => { + new BPartner({ ...vendorJson, name: vendorName }) + .setVendorPricingSystem(priceSystemName) + .setVendorDiscountSchema(discountSchemaName) + .apply(); + + cy.readAllNotifications(); + }); + }); +}); + +describe('Create a purchase order and Material Receipts', function() { + it('Create a purchase order and visit Material Receipt Candidates', function() { + new PurchaseOrder() + .setBPartner(vendorName) + .setPriceSystem(priceSystemName) + .setPoReference('test') + .addLine(new PurchaseOrderLine().setProduct(productName1).setQuantity(1)) + .apply(); + cy.completeDocument(); + }); + + it('Visit referenced Material Receipt Candidates', function() { + cy.openReferencedDocuments('M_ReceiptSchedule'); + cy.expectNumberOfRows(2); + }); + + it('Create Material Receipt 1', function() { + cy.selectNthRow(0).click(); + cy.executeQuickAction('WEBUI_M_ReceiptSchedule_ReceiveHUs_UsingDefaults'); + cy.selectNthRow(0, true); + cy.executeQuickAction('WEBUI_M_HU_CreateReceipt_NoParams'); + cy.pressDoneButton(); + }); + it('Check if Materialentnahmelager warehouse exists', function() { + cy.visitWindow('139'); + toggleNotFrequentFilters(); + selectNotFrequentFilterWidget('default'); + cy.writeIntoStringField('Name', materialentnahme, false, null, true); + applyFilters(); + + cy.expectNumberOfRows(1); + }); + it('Change warehouse in handling unit editor', function() { + cy.visitWindow('540189'); + toggleNotFrequentFilters(); + selectNotFrequentFilterWidget('default'); + cy.writeIntoLookupListField('M_Locator_ID', warehouseName, warehouseName, false, false, null, true); + cy.selectInListField('HUStatus', 'Active', false, null, true); + applyFilters(); + }); + it('Count all rows with the warehouseName=Hauptlager and status=Active', function() { + cy.countAllRows('540189').then(rows => { + cy.log(rows); + totalHUs = parseInt(rows); + }); + }); + it('Select all rows on current page and move them to direct warehouse', function() { + cy.selectAllRowsOnCurrentPage(); + cy.get('.table tbody tr').then(el => { + countOnPage = parseInt(el.length); + cy.log('########################################CountOnPage' + countOnPage); + countAfterMoving = parseInt(totalHUs) - parseInt(countOnPage); + }); + cy.executeQuickAction('WEBUI_M_HU_MoveToDirectWarehouse', false, false); + cy.log('####################TotalHUs:' + totalHUs); + cy.log(totalHUs - countOnPage); + /**Filter to check if HUs have been moved - the number of HUs to be moved is the total number + * minus those moved earlier + */ + toggleNotFrequentFilters(); + selectNotFrequentFilterWidget('default'); + cy.writeIntoLookupListField('M_Locator_ID', warehouseName, warehouseName, false, false, null, true); + cy.selectInListField('HUStatus', 'Active', false, null, true); + applyFilters(); + /**currently this fails because "Handling Unit 1000178 is currently selected in the picking as source HU + * and must therefore not be moved. (SourceHuMayNotBeRemovedException)" + * see: https://chat.metasfresh.org/metasfresh/pl/61sw4n5z5ib8te8ibne6ckrtxy*/ + cy.countAllRows('540189').then(el => { + expect(el).to.equals(countAfterMoving); + }); + }); +}); diff --git a/cypress/support/commands/navigation.js b/cypress/support/commands/navigation.js index f9e3e359..3b6d0172 100644 --- a/cypress/support/commands/navigation.js +++ b/cypress/support/commands/navigation.js @@ -156,3 +156,22 @@ Cypress.Commands.add('selectRowByColumnAndValue', (columnName, expectedValue, mo Cypress.Commands.add('selectAllRowsOnCurrentPage', () => { cy.get('body').type('{alt}a'); }); +/** + * Select all rows from all pages + * This function only works on a list window, and not on a single view window + * @param windowId - the window for which the rows will be counted + */ +Cypress.Commands.add('countAllRows', windowId => { + cy.visitWindow(windowId); + cy.get('.pagination-row .pagination-part .hidden-sm-down').then(totalString => { + const totalRows = parseInt( + totalString + .text() + .split(' ') + .pop(), + 10 + ); + cy.log(`Total number of rows is: ${totalRows}`); + return cy.wrap(totalRows); + }); +}); diff --git a/cypress/support/index.d.ts b/cypress/support/index.d.ts index f5a10187..69270b12 100644 --- a/cypress/support/index.d.ts +++ b/cypress/support/index.d.ts @@ -650,6 +650,11 @@ declare namespace Cypress { * Select all rows on the current page */ selectAllRowsOnCurrentPage(): Chainable + /** + * Count all rows from all pages + * @param windowId - the window for which the rows will be counted + */ + countAllRows(windowID: string | number): Chainable } } From 09b9936f86cdc16307c8a313cb12f7f7d5886cb6 Mon Sep 17 00:00:00 2001 From: Cristina Stefan <50820854+cristinastefan90@users.noreply.github.com> Date: Thu, 29 Aug 2019 11:15:08 +0300 Subject: [PATCH 3/5] #316 cleanup #316 Materialentnahme complete HUs --- .../logistics/materialentnahme_complete_HUs.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/cypress/integration/logistics/materialentnahme_complete_HUs.js b/cypress/integration/logistics/materialentnahme_complete_HUs.js index 842020f6..ba314f5f 100644 --- a/cypress/integration/logistics/materialentnahme_complete_HUs.js +++ b/cypress/integration/logistics/materialentnahme_complete_HUs.js @@ -7,12 +7,7 @@ import { PackingInstructionsVersion } from '../../support/utils/packing_instruct import { Builder } from '../../support/utils/builder'; import { appendHumanReadableNow } from '../../support/utils/utils'; import { PurchaseOrder, PurchaseOrderLine } from '../../support/utils/purchase_order'; -import { - applyFilters, - selectNotFrequentFilterWidget, - toggleNotFrequentFilters, - clearNotFrequentFilters, -} from '../../support/functions'; +import { applyFilters, selectNotFrequentFilterWidget, toggleNotFrequentFilters } from '../../support/functions'; let productForPackingMaterial; let packingInstructionsName; @@ -162,12 +157,9 @@ describe('Create a purchase order and Material Receipts', function() { cy.selectAllRowsOnCurrentPage(); cy.get('.table tbody tr').then(el => { countOnPage = parseInt(el.length); - cy.log('########################################CountOnPage' + countOnPage); countAfterMoving = parseInt(totalHUs) - parseInt(countOnPage); }); cy.executeQuickAction('WEBUI_M_HU_MoveToDirectWarehouse', false, false); - cy.log('####################TotalHUs:' + totalHUs); - cy.log(totalHUs - countOnPage); /**Filter to check if HUs have been moved - the number of HUs to be moved is the total number * minus those moved earlier */ From 134d66d450625e2d01ce45e647e1550e5f3524a3 Mon Sep 17 00:00:00 2001 From: Cristina Stefan <50820854+cristinastefan90@users.noreply.github.com> Date: Thu, 29 Aug 2019 11:16:25 +0300 Subject: [PATCH 4/5] #316 moved test to integration defunct until backend issue is clarified #316 Materialentnahme complete HUs --- .../logistics/materialentnahme_complete_HUs.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename cypress/{integration => integration_defunct}/logistics/materialentnahme_complete_HUs.js (100%) diff --git a/cypress/integration/logistics/materialentnahme_complete_HUs.js b/cypress/integration_defunct/logistics/materialentnahme_complete_HUs.js similarity index 100% rename from cypress/integration/logistics/materialentnahme_complete_HUs.js rename to cypress/integration_defunct/logistics/materialentnahme_complete_HUs.js From c90f9dc0def7764189b3ad83eb06cb3ddefe33a0 Mon Sep 17 00:00:00 2001 From: Cristina Stefan <50820854+cristinastefan90@users.noreply.github.com> Date: Fri, 30 Aug 2019 10:17:08 +0300 Subject: [PATCH 5/5] #316 changes after cr #316 Materialentnahme complete HUs --- .../materialentnahme_complete_HUs.json | 20 +++++++ .../materialentnahme_complete_HUs.js | 53 ++++++++----------- cypress/support/commands/navigation.js | 6 +-- cypress/support/index.d.ts | 3 +- 4 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 cypress/fixtures/logistics/materialentnahme_complete_HUs.json diff --git a/cypress/fixtures/logistics/materialentnahme_complete_HUs.json b/cypress/fixtures/logistics/materialentnahme_complete_HUs.json new file mode 100644 index 00000000..bbe187b2 --- /dev/null +++ b/cypress/fixtures/logistics/materialentnahme_complete_HUs.json @@ -0,0 +1,20 @@ + +{ + "productForPackingMaterial": "ProductPackingMaterial", + "packingInstructionsName": "ProductPackingInstructions", + + "productName1": "Product1", + "productCategoryName": "ProductCategoryName", + + "discountSchemaName": "DiscountSchema", + "priceSystemName": "PriceSystem", + "priceListName": "PriceList", + "priceListVersionName": "PriceListVersion", + + "productType": "Item", + "vendorName": "Vendor", + + "materialentnahme": "Materialentnahmelager", + "warehouseName": "Hauptlager_StdWarehouse_Hauptlager_0_0_0", + "quantity": 1 +} \ No newline at end of file diff --git a/cypress/integration_defunct/logistics/materialentnahme_complete_HUs.js b/cypress/integration_defunct/logistics/materialentnahme_complete_HUs.js index ba314f5f..6b4c847c 100644 --- a/cypress/integration_defunct/logistics/materialentnahme_complete_HUs.js +++ b/cypress/integration_defunct/logistics/materialentnahme_complete_HUs.js @@ -1,13 +1,15 @@ import { BPartner } from '../../support/utils/bpartner'; import { DiscountSchema } from '../../support/utils/discountschema'; import { ProductCategory } from '../../support/utils/product'; -import { PackingMaterial } from '../../support/utils/packing_material'; -import { PackingInstructions } from '../../support/utils/packing_instructions'; -import { PackingInstructionsVersion } from '../../support/utils/packing_instructions_version'; import { Builder } from '../../support/utils/builder'; import { appendHumanReadableNow } from '../../support/utils/utils'; import { PurchaseOrder, PurchaseOrderLine } from '../../support/utils/purchase_order'; -import { applyFilters, selectNotFrequentFilterWidget, toggleNotFrequentFilters } from '../../support/functions'; +import { + applyFilters, + selectNotFrequentFilterWidget, + toggleNotFrequentFilters, + clearNotFrequentFilters, +} from '../../support/functions'; let productForPackingMaterial; let packingInstructionsName; @@ -21,13 +23,14 @@ let productType; let vendorName; let materialentnahme; let warehouseName; +let quantity; let totalHUs; let countOnPage; let countAfterMoving; it('Read the fixture', function() { - cy.fixture('logistics/materialentnahme_complete_HU.json').then(f => { + cy.fixture('logistics/materialentnahme_complete_HUs.json').then(f => { productForPackingMaterial = appendHumanReadableNow(f['productForPackingMaterial']); packingInstructionsName = appendHumanReadableNow(f['packingInstructionsName']); productName1 = appendHumanReadableNow(f['productName1']); @@ -40,6 +43,7 @@ it('Read the fixture', function() { vendorName = appendHumanReadableNow(f['vendorName']); materialentnahme = f['materialentnahme']; warehouseName = f['warehouseName']; + quantity = f['quantity']; }); }); @@ -52,27 +56,15 @@ describe('Change warehouse to Materialentnahmelager', function() { .apply(); }); }); - it('Create packing related entities', function() { - // eslint-disable-next-line - Builder.createProductWithPriceUsingExistingCategory(priceListName, productForPackingMaterial, productForPackingMaterial, productType, "24_Gebinde"); - cy.fixture('product/packing_material.json').then(packingMaterialJson => { - Object.assign(new PackingMaterial(), packingMaterialJson) - .setName(productForPackingMaterial) - .setProduct(productForPackingMaterial) - .apply(); - }); - cy.fixture('product/packing_instructions.json').then(packingInstructionsJson => { - Object.assign(new PackingInstructions(), packingInstructionsJson) - .setName(packingInstructionsName) - .apply(); - }); - cy.fixture('product/packing_instructions_version.json').then(pivJson => { - Object.assign(new PackingInstructionsVersion(), pivJson) - .setName(packingInstructionsName) - .setPackingInstructions(packingInstructionsName) - .setPackingMaterial(productForPackingMaterial) - .apply(); - }); + it('Create product and packing related entities', function() { + Builder.createProductWithPriceUsingExistingCategory( + priceListName, + productForPackingMaterial, + productForPackingMaterial, + productType, + '24_Gebinde' + ); + Builder.createPackingMaterial(productForPackingMaterial, packingInstructionsName); }); it('Create category', function() { @@ -113,7 +105,7 @@ describe('Create a purchase order and Material Receipts', function() { .setBPartner(vendorName) .setPriceSystem(priceSystemName) .setPoReference('test') - .addLine(new PurchaseOrderLine().setProduct(productName1).setQuantity(1)) + .addLine(new PurchaseOrderLine().setProduct(productName1).setQuantity(quantity)) .apply(); cy.completeDocument(); }); @@ -127,7 +119,7 @@ describe('Create a purchase order and Material Receipts', function() { cy.selectNthRow(0).click(); cy.executeQuickAction('WEBUI_M_ReceiptSchedule_ReceiveHUs_UsingDefaults'); cy.selectNthRow(0, true); - cy.executeQuickAction('WEBUI_M_HU_CreateReceipt_NoParams'); + cy.executeQuickAction('WEBUI_M_HU_CreateReceipt_NoParams', true, false); cy.pressDoneButton(); }); it('Check if Materialentnahmelager warehouse exists', function() { @@ -148,7 +140,7 @@ describe('Create a purchase order and Material Receipts', function() { applyFilters(); }); it('Count all rows with the warehouseName=Hauptlager and status=Active', function() { - cy.countAllRows('540189').then(rows => { + cy.countAllRows().then(rows => { cy.log(rows); totalHUs = parseInt(rows); }); @@ -163,6 +155,7 @@ describe('Create a purchase order and Material Receipts', function() { /**Filter to check if HUs have been moved - the number of HUs to be moved is the total number * minus those moved earlier */ + clearNotFrequentFilters(); toggleNotFrequentFilters(); selectNotFrequentFilterWidget('default'); cy.writeIntoLookupListField('M_Locator_ID', warehouseName, warehouseName, false, false, null, true); @@ -171,7 +164,7 @@ describe('Create a purchase order and Material Receipts', function() { /**currently this fails because "Handling Unit 1000178 is currently selected in the picking as source HU * and must therefore not be moved. (SourceHuMayNotBeRemovedException)" * see: https://chat.metasfresh.org/metasfresh/pl/61sw4n5z5ib8te8ibne6ckrtxy*/ - cy.countAllRows('540189').then(el => { + cy.countAllRows().then(el => { expect(el).to.equals(countAfterMoving); }); }); diff --git a/cypress/support/commands/navigation.js b/cypress/support/commands/navigation.js index 3b6d0172..c4f2faba 100644 --- a/cypress/support/commands/navigation.js +++ b/cypress/support/commands/navigation.js @@ -159,10 +159,8 @@ Cypress.Commands.add('selectAllRowsOnCurrentPage', () => { /** * Select all rows from all pages * This function only works on a list window, and not on a single view window - * @param windowId - the window for which the rows will be counted */ -Cypress.Commands.add('countAllRows', windowId => { - cy.visitWindow(windowId); +Cypress.Commands.add('countAllRows', () => { cy.get('.pagination-row .pagination-part .hidden-sm-down').then(totalString => { const totalRows = parseInt( totalString @@ -171,7 +169,7 @@ Cypress.Commands.add('countAllRows', windowId => { .pop(), 10 ); - cy.log(`Total number of rows is: ${totalRows}`); + cy.log(`Total number of rows on all pages is: ${totalRows}`); return cy.wrap(totalRows); }); }); diff --git a/cypress/support/index.d.ts b/cypress/support/index.d.ts index 69270b12..ff243d7e 100644 --- a/cypress/support/index.d.ts +++ b/cypress/support/index.d.ts @@ -652,9 +652,8 @@ declare namespace Cypress { selectAllRowsOnCurrentPage(): Chainable /** * Count all rows from all pages - * @param windowId - the window for which the rows will be counted */ - countAllRows(windowID: string | number): Chainable + countAllRows(): Chainable } }