| /** | 
|  * @file         ADSO-10095 - Unit costs display (filter by leaf units selection from navigation panel) | 
|  * @description  Verify unit cost instances display result after filter HU Fermenter & HU Strainer unit in navigation panel | 
|  * @testcategory Web - Financials - Units | 
|  * @author       Wong Jia Hui (jiahui.wong@3ds.com) | 
|  * @copyright    Dassault Systemes | 
|  */ | 
| import { qCustomMatcher } from '../../../e2elib/lib/src/main/qmatchers.const'; | 
| import { AppMP, Demo, Scenario } from '../../../libmp/appmp'; | 
|   | 
| describe('ADSO-10095 - Verify UnitCost form display result after filter applied', () => { | 
|   const appMP = AppMP.getInstance(); | 
|   | 
|   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.viewUnitCost.viewPath} and verify if "Filter by accounts" checkbox is uncheck by default`, async () => { | 
|     // Open Unit Cost View under Data -> Finances (ButtonDataFinances) -> Unit Costs (ContextMenuFinances) (MenuOperationCosts) | 
|     // Wait until Unit Accounts (FormUnitAccounts) and Unit Costs form (FormUnitCosts) is present | 
|     await appMP.viewUnitCost.switchTo(); | 
|     // Verify if 'Filter by Accounts' checkbox (cbFilterByAccounts) is toggled off by default | 
|     expect(await appMP.viewUnitCost.frmUnitCost.cbFilterByAccounts.isChecked()).toBeFalsy('Checkbox FilterByAccounts should be uncheck by default'); | 
|   }); | 
|   | 
|   it('Step 2: Verify navigation panel is show and open Entity list', async () => { | 
|     // Verify if navigation panel is showed by default | 
|     expect(await appMP.formNavigation.isVisible()).toBeTruthy('Navigation panel should be visible'); | 
|     // Open 'StockingPoints and Units' list (ListEntity) in navigation panel by clicking on 'StockingPoints and Units' button (ButtonNavEntity) | 
|     await appMP.formNavigation.btnEntity.click(); | 
|     expect(await appMP.formNavigation.listEntity.isVisible()).toBeTruthy('Entitiy list in navigation panel should be visible'); | 
|   }); | 
|   | 
|   it('Step 3: check "HU Fermenter" and "HU Strainer" units checkbox', async () => { | 
|     // Resize DisplayName column incase DisplayName value will be show as "Hungary Pl..." | 
|     const entityDisplayNameColumn = await appMP.formNavigation.listEntity.getColumnByValue('DisplayName'); | 
|     await entityDisplayNameColumn.resizeColumn(100); | 
|     // Check 2 leaf units HU Fermenter & HU Strainer (to get row in hierarchy list can refer to getBookmarkByName function) | 
|     const huFermenterUnitRow = await appMP.formNavigation.listEntity.getEntityRowByName('HU Fermenter', ['Europe', 'Plants', 'Hungary Plant']); | 
|     expect(huFermenterUnitRow).toBeDefined('HU Fermenter row should be found'); | 
|     await appMP.formNavigation.listEntity.scrollToRow(huFermenterUnitRow); | 
|     await huFermenterUnitRow.checkboxClick(); | 
|     expect(huFermenterUnitRow.isChecked).toBeTruthy('HU Fermenter row checkbox should be checked'); | 
|   | 
|     const huStrainerUnitRow = await appMP.formNavigation.listEntity.getEntityRowByName('HU Strainer', ['Europe', 'Plants', 'Hungary Plant']); | 
|     expect(huStrainerUnitRow).toBeDefined('HU Strainer row should be found'); | 
|     await appMP.formNavigation.listEntity.scrollToRow(huStrainerUnitRow); | 
|     await huStrainerUnitRow.checkboxClick(); | 
|     expect(huStrainerUnitRow.isChecked).toBeTruthy('HU Strainer row checkbox should be checked'); | 
|   }); | 
|   | 
|   it('Step 4: Verify instances unit value showed in UnitCost form to be either "HU Fermenter" or "HU Strainer"', async () => { | 
|     const unitCostRows = await appMP.viewUnitCost.frmUnitCost.listUnitCost.getAllRows(); | 
|     for (const row of unitCostRows) { | 
|       const cellValue = await appMP.viewUnitCost.frmUnitCost.listUnitCost.getCellValueFromRow('Unit', row); | 
|       let isMatchedValue = false; | 
|       if (cellValue === 'HU Fermenter' || cellValue === 'HU Strainer') { | 
|         isMatchedValue = true; | 
|       } | 
|       expect(isMatchedValue).toBeTruthy('Unit value of UnitCost row should be either "HU Fermenter" or "HU Strainer"'); | 
|     } | 
|   }); | 
| }); |