haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
 * @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');
  });
});