| /** | 
|  * @file        ADSO-10195 | 
|  * @description Products in Stocking Points and Inventory costs display (filter by family products with leaf products selection from navigation panel) | 
|  * @author      Mehrab Kamrani (mehrab.hassan@3ds.com) | 
|  * @copyright   Dassault Systèmes | 
|  */ | 
| import { qCustomMatcher } from '../../../e2elib/lib/src/main/qmatchers.const'; | 
| import { AppMP, Demo, Scenario } from '../../../libmp/appmp'; | 
| import { asyncEvery } from '../../../libappbase/utils'; | 
| import { ListRow } from '../../../e2elib/lib/src/pageobjects/list/listrow.component'; | 
|   | 
| describe('ADSO-10195 - Products in Stocking Points and Inventory costs display (filter by family products with leaf products selection from navigation panel)', () => { | 
|   const appMP = AppMP.getInstance(); | 
|   const listAccountCosts = appMP.viewInventoryCosts.frmInventoryCosts.lstAccountCosts; | 
|   const listInventoryPISP = appMP.viewInventoryCosts.frmInventoryCostPISP.lstInventoryPISP; | 
|   const listProduct = appMP.formNavigation.listProduct; | 
|   | 
|   beforeAll(async () => { | 
|     jasmine.addMatchers(qCustomMatcher); | 
|     await appMP.login(); | 
|   }); | 
|   | 
|   afterAll(async () => { | 
|     await appMP.cleanupAndLogout(); | 
|   }); | 
|   | 
|   afterEach(async () => { | 
|     await appMP.checkToastMessage(); | 
|   }); | 
|   | 
|   it(`Setup - ${AppMP.getDemoDataPath(Demo.Food, Scenario.Base)}`, async () => { | 
|     await appMP.createDemoDataset(Demo.Food, Scenario.Base, false); | 
|   }); | 
|   | 
|   it(`Step 1 - Open view ${appMP.viewInventoryCosts.viewPath}`, async () => { | 
|     await appMP.viewInventoryCosts.switchTo(); | 
|   }); | 
|   | 
|   it('Step 2 - By default, Filter by Accounts toggled Off', async () => { | 
|     const isInventoryCostVisible = await appMP.viewInventoryCosts.frmInventoryCosts.cbFilterByAccounts.isChecked(); | 
|     expect(isInventoryCostVisible).toBe(false, 'Filter by Accounts toggled Off'); | 
|   }); | 
|   | 
|   it('Step 3 - In navigation panel, select stocking point HU Warehouse and family product Lowfat', async () => { | 
|     // Open StockingPoints and Units list | 
|     await appMP.formNavigation.btnEntity.click(); | 
|     expect(await appMP.formNavigation.listEntity.isVisible()).toBe(true, 'Stocking points and units list in navigation panel should be visible'); | 
|     // Select "HU Warehouse" stocking point | 
|     const huWarehouseStockingPointRow = await appMP.formNavigation.listEntity.getEntityRowByName('HU Warehouse', ['Europe']); | 
|     await huWarehouseStockingPointRow.checkboxClick(); | 
|     expect(await huWarehouseStockingPointRow.isChecked()).toBe(true, 'HU Warehouse row checkbox should be checked'); | 
|     // Close StockingPoints and Units list | 
|     await appMP.formNavigation.btnEntity.click(); | 
|     // Open Product list | 
|     await appMP.formNavigation.btnProduct.click(); | 
|     expect(await listProduct.isVisible()).toBe(true, 'Product list in navigation panel should be visible'); | 
|     // Select "Lowfat" product | 
|     const lowfatProductRow = await listProduct.getRowByCellValue('Name', 'Lowfat', ['All Products', 'Finished Goods']); | 
|     await lowfatProductRow.checkboxClick(); | 
|     expect(await lowfatProductRow.isChecked()).toBe(true, 'Lowfat row checkbox should be checked'); | 
|     await listInventoryPISP.waitForScreenUpdate(3000); | 
|   }); | 
|   | 
|   it('Step 4 - Verify products in Stocking Points and Inventory Cost list are correct', async () => { | 
|     // Verify products in Stocking Points list shows 4 pisps of lowfat product in HU Warehouse | 
|     const inventoryPISPRowCount = await listInventoryPISP.getRowCount(); | 
|     const inventoryPISPAllRows = await listInventoryPISP.getAllRows(); | 
|     const isPISPsLowfat = await asyncEvery(inventoryPISPAllRows, async (inventoryPISPRow: ListRow) => { | 
|       const value = await (await inventoryPISPRow.getCell('Product')).getValue(); | 
|       return value.includes('Lowfat'); | 
|     }); | 
|     expect(inventoryPISPRowCount === 4 && isPISPsLowfat).toBe(true, '4 PISPs of lowfat product should be in Product in Inventory list'); | 
|   | 
|     // Verify Inventory Costs list shows 4 inventory value instances of lowfat product in HU Warehouse | 
|     const accountCostRowCount = await listAccountCosts.getRowCount(); | 
|     const accountCostAllRows = await listInventoryPISP.getAllRows(); | 
|     const isAccountCostLowfat = await asyncEvery(accountCostAllRows, async (accountCostRow: ListRow) => { | 
|       const value = await (await accountCostRow.getCell('Product')).getValue(); | 
|       return value.includes('Lowfat'); | 
|     }); | 
|     expect(accountCostRowCount === 4 && isAccountCostLowfat).toBe(true, '4 inventory value instances of lowfat product should be in Inventory Costs list'); | 
|   | 
|     // Verify no non-leaf level pisps are shown in both lists | 
|     const lowfatInventoryCostRow = await listAccountCosts.getInventoryCostByName('Lowfat').catch(() => { | 
|       // do nothing as error is thrown due to no row is found | 
|     }); | 
|     expect(lowfatInventoryCostRow).toBeUndefined('Lowfat as a non-leaf PISP should not be in Inventory Account Cost list'); | 
|     const lowfatPISPRow = await listInventoryPISP.getPISPByName('Lowfat').catch(() => { | 
|       // do nothing as error is thrown due to no row is found | 
|     }); | 
|     expect(lowfatPISPRow).toBeUndefined('Lowfat as a non-leaf PISP should not be in Inventory Product in Stocking Point list'); | 
|   }); | 
| }); |