yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
/**
 * @file         ADSO-10125
 * @description  Operation account display relevant account
 * @testcategory Web - Financials - Operations
 * @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 { ListOperationAccountColumn } from '../../../libmp/forms/form.operationaccount';
import { ListRow } from '../../../e2elib/lib/src/pageobjects/list/listrow.component';
 
describe('ADSO-10125 - Operation account display relevant account', () => {
  const appMP = AppMP.getInstance();
  const operationAccs = ['Operation utilization penalty', 'Labor cost', 'Rework cost', 'Sourcing(Lot) cost', 'Transportation(Lot) Cost', 'Operating cost', 'Sourcing cost', 'Transportation cost', 'Process preference cost'];
  const costDrivers = ['Time', 'Volume', 'Lot', 'One time cost'];
 
  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.viewOperationCost.viewPath}. Verify ${operationAccs.length} accounts exist in operation account list`, async () => {
    // Switch to operation cost view
    await appMP.viewOperationCost.switchTo();
    const listOperationAccount = appMP.viewOperationCost.frmOperationsAccount.listOperationAccount;
    // Verify Account, Default value, and Default UoM column is shown in the list
    expect(await listOperationAccount.getColumnByValue(ListOperationAccountColumn.Account)).toBeDefined('Account column should exist in operation account list');
    expect(await listOperationAccount.getColumnByValue(ListOperationAccountColumn.DefaultValue)).toBeDefined('Default value column should exist in operation account list');
    expect(await listOperationAccount.getColumnByValue(ListOperationAccountColumn.DefaultUoM)).toBeDefined('Default UoM column should exist in operation account list');
    // Verify the account number in the list
    expect(await listOperationAccount.getOperationAccountCount()).toBe(operationAccs.length, `The number of account in operation account list should be ${operationAccs.length}`);
    // Verify each of the account is in the list
    for (const operationAcc of operationAccs) {
      const accRow: ListRow | undefined = await listOperationAccount.getOperationAccountByName(operationAcc).catch(() => undefined);
      expect(accRow).toBeDefined(`${operationAcc} should exist in the list`);
    }
  });
 
  it(`Step 2 - Open view ${appMP.viewAccount.viewPath}. Verify the ${operationAccs.length} accounts have any one of these cost drivers: ${costDrivers.join(', ')}`, async () => {
    // Switch to account view
    await appMP.viewAccount.switchTo();
    // Expand row
    const listAccount = appMP.viewAccount.frmAccount.listAccount;
    await (await listAccount.getRowByValue([{ columnID: 'Name', value: 'Cost of sales' }])).expandRow();
    // Verify account and cost driver match
    for (const operationAcc of operationAccs) {
      expect(await listAccount.isAccountCostDriverMatch(operationAcc, costDrivers)).toBe(true, `${operationAcc} should have any one of these cost drivers: ${costDrivers.join(', ')}`);
    }
  });
});