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
/**
 * @file         ADSO-10192
 * @description  Inventory account display relevant account
 * @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 { ListRow } from '../../../e2elib/lib/src/pageobjects/list/listrow.component';
import { ListAccountColumn } from '../../../libmp/forms/form.inventoryaccounts';
import { DataFoodBaseAccountName } from '../../../libmp/data/data.account';
import { LogMessage } from '../../../libappbase/logmessage';
import { DataInventoryAccount, DataInventoryCostCostDriver } from '../../../libmp/data/data.inventorycost';
 
describe('ADSO-10192 - Inventory account display relevant account', () => {
  const appMP = AppMP.getInstance();
  const inventoryAccs = [DataInventoryAccount.InventoryHoldingCost, DataInventoryAccount.InventoryValue, DataInventoryAccount.InventoryLocationPreferenceCost];
  const costDrivers = [DataInventoryCostCostDriver.InventoryHolding, DataInventoryCostCostDriver.InventoryValue];
 
  beforeAll(async () => {
    jasmine.addMatchers(qCustomMatcher);
    await appMP.login();
  });
 
  afterAll(async () => {
    // Reset view
    await appMP.viewAccount.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(`Step 1 - Open view ${appMP.viewInventoryCosts.viewPath}, then verify Inventory Accounts list showing columns Account, Default value and Default UoM with ${inventoryAccs.length} accounts: ${inventoryAccs.join(', ')}`, async () => {
    // Switch to inventory cost view
    await appMP.viewInventoryCosts.switchTo();
    const listInventoryAccount = appMP.viewInventoryCosts.frmInventoryAccounts.lstAccounts;
    const listName = 'inventory account list';
    // Verify Account, Default value, and Default UoM column is shown in the list
    expect(await listInventoryAccount.getColumnByValue(ListAccountColumn.Account)).toBeDefined(LogMessage.list_columnNotExist(ListAccountColumn.Account, listName));
    expect(await listInventoryAccount.getColumnByValue(ListAccountColumn.DefaultValue)).toBeDefined(LogMessage.list_columnNotExist(ListAccountColumn.DefaultValue, listName));
    expect(await listInventoryAccount.getColumnByValue(ListAccountColumn.DefaultUoM)).toBeDefined(LogMessage.list_columnNotExist(ListAccountColumn.DefaultUoM, listName));
    // Verify the account number in the list
    expect(await listInventoryAccount.getRowCount()).toBe(inventoryAccs.length, `The number of account in inventory account list should be ${inventoryAccs.length}`);
    // Verify each of the account is in the list
    for (const inventoryAcc of inventoryAccs) {
      const accRow: ListRow | undefined = await listInventoryAccount.getAccountByName(inventoryAcc).catch(() => undefined);
      expect(accRow).toBeDefined(`${inventoryAcc} should exist in the list`);
    }
  });
 
  it(`Step 2 - Open view ${appMP.viewAccount.viewPath}, then verify the ${inventoryAccs.length} accounts have any one of these cost drivers: ${costDrivers.join(', ')}`, async () => {
    await appMP.viewAccount.switchTo();
    // Expand row
    const listAccount = appMP.viewAccount.frmAccount.listAccount;
    await (await listAccount.getRow({ Name: DataFoodBaseAccountName.CostOfSales })).expandRow();
    // Verify account and cost driver match
    for (const inventoryAcc of inventoryAccs) {
      expect(await listAccount.isAccountCostDriverMatch(inventoryAcc, costDrivers)).toBe(true, `${inventoryAcc} should have any one of these cost drivers: ${costDrivers.join(', ')}`);
    }
  });
});