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
94
95
96
97
98
99
100
101
102
103
104
/**
 * @file         ADSO-10193
 * @description  Products in Stocking points and Inventory costs display (filter by accounts)
 * @testcategory Web - Financials - Inventory
 * @author       Gay Er Xuan (erxuan.gay@3ds.com)
 * @copyright    Dassault Systèmes
 */
import { qCustomMatcher } from '../../../e2elib/lib/src/main/qmatchers.const';
import { AppMP, Demo, Scenario } from '../../../libmp/appmp';
import { DataInventoryAccount, DataInventoryCostCostDriver } from '../../../libmp/data/data.inventorycost';
import { DataLowFatVanilla6, DataFoodBaseEntity, DataFoodBaseEntityName } from '../../../libmp/data/data.navigation';
import { ListColumnAccountCosts } from '../../../libmp/forms/form.inventorycosts';
import { QConsole } from '../../../e2elib/lib/src/helper/qconsole';
import { startOfPlanningYear } from '../../../libmp/data/data.period';
 
describe('ADSO-10193 - Products in Stocking points and Inventory costs display (filter by accounts)', () => {
  const appMP = AppMP.getInstance();
  const listInventoryCost = appMP.viewInventoryCosts.frmInventoryCosts.lstAccountCosts;
  const cbFilterByAcc = appMP.viewInventoryCosts.frmInventoryCosts.cbFilterByAccounts;
  const stockingPoint = DataFoodBaseEntityName.HUWarehouse;
  const stockingPointParents = DataFoodBaseEntity.huWarehouseParent;
  const product = DataLowFatVanilla6.name;
  const accInventoryLocationPreferenceCost = DataInventoryAccount.InventoryLocationPreferenceCost;
  const accInventoryValue = DataInventoryAccount.InventoryValue;
  const accInventoryHoldingCost = DataInventoryAccount.InventoryHoldingCost;
  const newCostCostDriver = DataInventoryCostCostDriver.InventoryHolding;
  const newCostStart = new Date(`1-Jan-${startOfPlanningYear}`);
  const newCostCost = 100;
 
  beforeAll(async () => {
    jasmine.addMatchers(qCustomMatcher);
    await appMP.login();
  });
 
  afterAll(async () => {
    // Reset views and navigation
    await appMP.formNavigation.reset();
    await appMP.viewInventoryCosts.reset();
    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(`Setup - Open view ${appMP.viewInventoryCosts.viewPath}. Create a new inventory cost`, async () => {
    // Open Inventory Cost View
    await appMP.viewInventoryCosts.switchTo();
    // Create new inventory cost
    await listInventoryCost.createNewInventoryCost(accInventoryHoldingCost, newCostCostDriver, product, stockingPoint, newCostStart, newCostCost);
  });
 
  it('Step 1 - Reset filtering in navigation form and toggle ON Filter by Accounts in Inventory Costs form', async () => {
    // Open navigation form
    await appMP.formNavigation.openNavigationPanel();
    await appMP.formNavigation.resetNaviToRoot();
    // Toggle ON Filter by Accounts
    await appMP.viewInventoryCosts.frmInventoryCosts.toggleFilterByAccount(true);
    expect(await cbFilterByAcc.isChecked()).toBe(true, 'Filter by Accounts should be toggled to ON');
  });
 
  it(`Step 2 - Select ${accInventoryLocationPreferenceCost} and verify inventory cost showing no cost`, async () => {
    // Select inventory account
    const acc = await appMP.viewInventoryCosts.frmInventoryAccounts.lstAccounts.getAccountByName(accInventoryLocationPreferenceCost);
    await acc.leftClick();
    await listInventoryCost.waitForScreenUpdate();
    // Verify inventory cost list showing no cost
    expect(await listInventoryCost.getRowCount()).toBe(0, `No cost should be shown for ${accInventoryLocationPreferenceCost}`);
  });
 
  it(`Step 3 - Select ${accInventoryValue} and filter in navigation panel, then verify inventory cost showing correct cost`, async () => {
    // Select inventory account
    const acc = await appMP.viewInventoryCosts.frmInventoryAccounts.lstAccounts.getAccountByName(accInventoryValue);
    await acc.leftClick();
    // Filter in navigation panel
    await appMP.formNavigation.filterByEntity(stockingPoint, stockingPointParents);
    await appMP.formNavigation.filterByProduct({ Name: product }, DataLowFatVanilla6.parents);
    await QConsole.waitForStable(1000);
    // Verify list showing correct value
    const allRows = await listInventoryCost.getAllRows();
    expect(await listInventoryCost.matchColumnValueFromRows(allRows, ListColumnAccountCosts.Product, product)).toBe(true, `Inventory cost list should contain only rows with ${product} as product`);
    expect(await listInventoryCost.matchColumnValueFromRows(allRows, ListColumnAccountCosts.StockingPoint, stockingPoint)).toBe(true, `Inventory cost list should contain only rows with ${stockingPoint} as stocking point`);
    expect(await listInventoryCost.matchColumnValueFromRows(allRows, ListColumnAccountCosts.Account, accInventoryValue)).toBe(true, `Inventory cost list should contain only rows with ${accInventoryValue} as account`);
  });
 
  it('Step 4 - Toggle OFF Filter by Accounts and verify there is one more cost instance', async () => {
    // Record old instance count
    const oldAllRows = await listInventoryCost.getAllRows();
    const oldRowCount = oldAllRows.length;
    // Toggle OFF Filter by Accounts
    await appMP.viewInventoryCosts.frmInventoryCosts.toggleFilterByAccount(false);
    expect(await cbFilterByAcc.isChecked()).toBe(false, 'Filter by Accounts should be toggled to OFF');
    // Verify one more row is shown in the list
    const newRowCount = await listInventoryCost.getRowCount();
    expect(newRowCount - oldRowCount).toBe(1, 'There should be one more cost shown in the list after toggle Filter by Accounts to OFF');
    // Verify value of the additional instance
    const newRow = listInventoryCost.findInventoryCost(product, stockingPoint, accInventoryHoldingCost, newCostCostDriver, newCostCost);
    expect(newRow).toBeDefined('The values of the additional instance does not match');
  });
});