renhao
2023-09-21 1aa9f2bb83dd9e4b7517f1cbf06b0db53979bb31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
 * @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"');
    }
  });
});