yanweiyuan3
2023-10-10 d901b1ab0ee0b690f5ac211b9cdb1db3a58bca86
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
/**
 * @file        ADSO-10266
 * @description Transportation Accounts display relevant accounts
 * @author      Pethaperumal Natarajan (Pethaperumal.NATARAJAN.intern@3ds.com)
 * @copyright   Dassault Systèmes
 */
 
import { AppMP, Demo, Scenario } from '../../../libmp/appmp';
import { qCustomMatcher } from '../../../e2elib/lib/src/main/qmatchers.const';
import { StepList } from '../../../libappsop/listsop';
import { ListTransportationAccounts, ListTransportationAccountsColumn } from '../../../libmp/forms/form.transportationaccounts';
import { ListAccount, ListAccountColumn } from '../../../libmp/forms/form.account';
import { DataFoodBaseAccountCostDriver, DataFoodBaseAccountName, DataFoodBaseAccountUoM } from '../../../libmp/data/data.account';
 
describe('ADSO-10266 - Transportation Accounts display relevant accounts', () => {
  const appMP = AppMP.getInstance();
  const listTransportationAccounts = appMP.viewTransportationCost.formTransportationAccounts.listTransportationAccounts;
  const listAccounts = appMP.viewAccount.frmAccount.listAccount;
 
  const defaultNumRows = 6;
 
  const transportationAccountSourcingCost: ListTransportationAccountsColumn = { Account: DataFoodBaseAccountName.SourcingCost, 'Default value': '100', 'Default UoM': DataFoodBaseAccountUoM.EuroPerTon };
  const transportationAccountTransportationCost: ListTransportationAccountsColumn = { Account: DataFoodBaseAccountName.TransportationCost, 'Default value': '100', 'Default UoM': DataFoodBaseAccountUoM.EuroPerTon };
  const transportationAccountOperatingCost: ListTransportationAccountsColumn = { Account: DataFoodBaseAccountName.OperatingCost, 'Default value': '100', 'Default UoM': DataFoodBaseAccountUoM.EuroPerTon };
  const transportationAccountProcessPreferenceCost: ListTransportationAccountsColumn = { Account: DataFoodBaseAccountName.ProcessPreferenceCost, 'Default value': '10', 'Default UoM': DataFoodBaseAccountUoM.EuroPerTon };
  const transportationAccountSourcingLotCost: ListTransportationAccountsColumn = { Account: DataFoodBaseAccountName.SourcingLotCost, 'Default value': '100', 'Default UoM': DataFoodBaseAccountUoM.EuroPerLot };
  const transportationAccountTransportationLotCost: ListTransportationAccountsColumn = { Account: DataFoodBaseAccountName.TransportationLotCost, 'Default value': '100', 'Default UoM': DataFoodBaseAccountUoM.EuroPerLot };
 
  const accountCostOfSales: ListAccountColumn = { Name: DataFoodBaseAccountName.CostOfSales };
  const accountTransportationCost: ListAccountColumn = { Name: DataFoodBaseAccountName.TransportationCost, 'Default cost driver': DataFoodBaseAccountCostDriver.Volume };
  const accountOperatingCost: ListAccountColumn = { Name: DataFoodBaseAccountName.OperatingCost, 'Default cost driver': DataFoodBaseAccountCostDriver.Volume };
  const accountSourcingCost: ListAccountColumn = { Name: DataFoodBaseAccountName.SourcingCost, 'Default cost driver': DataFoodBaseAccountCostDriver.Volume };
  const accountProcessPreferenceCost: ListAccountColumn = { Name: DataFoodBaseAccountName.ProcessPreferenceCost, 'Default cost driver': DataFoodBaseAccountCostDriver.Volume };
  const accountTransportationLotCost: ListAccountColumn = { Name: DataFoodBaseAccountName.TransportationLotCost, 'Default cost driver': DataFoodBaseAccountCostDriver.Lot };
  const accountSourcingLotCost: ListAccountColumn = { Name: DataFoodBaseAccountName.SourcingLotCost, 'Default cost driver': DataFoodBaseAccountCostDriver.Lot };
 
  beforeAll(async () => {
    jasmine.addMatchers(qCustomMatcher);
    await appMP.login();
  });
 
  afterAll(async () => {
    await appMP.resetActiveView(appMP.viewAccount);
    await appMP.cleanupAndLogout();
  });
 
  afterEach(async () => {
    await appMP.checkToastMessage();
  });
 
  it(`Step 1 - ${AppMP.getDemoDataPath(Demo.Metals, Scenario.Base)}`, async () => {
    await appMP.createDemoDataset(Demo.Metals, Scenario.Base, false);
  });
 
  it(`Step 2 - Open view ${appMP.viewTransportationCost.viewPath}.`, async () => {
    await appMP.viewTransportationCost.switchTo();
  });
 
  it(`Step 3 - ${StepList.verifyTotalRow(ListTransportationAccounts.title, defaultNumRows)} ${StepList.verifyRowExists(ListTransportationAccounts.title, transportationAccountSourcingCost)} ${StepList.verifyRowExists(ListTransportationAccounts.title, transportationAccountTransportationCost)} ${StepList.verifyRowExists(ListTransportationAccounts.title, transportationAccountOperatingCost)} ${StepList.verifyRowExists(ListTransportationAccounts.title, transportationAccountProcessPreferenceCost)} ${StepList.verifyRowExists(ListTransportationAccounts.title, transportationAccountSourcingLotCost)} ${StepList.verifyRowExists(ListTransportationAccounts.title, transportationAccountTransportationLotCost)}`, async () => {
    await listTransportationAccounts.verifyTotalRow(defaultNumRows);
    // Verifying that rows contain Account, Default value and Default UoM
    await listTransportationAccounts.verifyRowExists(transportationAccountSourcingCost);
    await listTransportationAccounts.verifyRowExists(transportationAccountTransportationCost);
    await listTransportationAccounts.verifyRowExists(transportationAccountOperatingCost);
    await listTransportationAccounts.verifyRowExists(transportationAccountProcessPreferenceCost);
    await listTransportationAccounts.verifyRowExists(transportationAccountSourcingLotCost);
    await listTransportationAccounts.verifyRowExists(transportationAccountTransportationLotCost);
  });
 
  it(`Step 4 - Open view ${appMP.viewAccount.viewPath}.`, async () => {
    await appMP.viewAccount.switchTo();
  });
 
  it(`Step 5 - ${StepList.verifyRowExists(ListAccount.title, accountTransportationCost, [accountCostOfSales])} ${StepList.verifyRowExists(ListAccount.title, accountOperatingCost, [accountCostOfSales])} ${StepList.verifyRowExists(ListAccount.title, accountSourcingCost, [accountCostOfSales])} ${StepList.verifyRowExists(ListAccount.title, accountProcessPreferenceCost)} ${StepList.verifyRowExists(ListAccount.title, accountTransportationLotCost, [accountCostOfSales])}, ${StepList.verifyRowExists(ListAccount.title, accountSourcingLotCost, [accountCostOfSales])}`, async () => {
    // Verify all these accounts have one of the two cost drivers: Volume & Lot
    await listAccounts.verifyRowExists(accountTransportationCost, [accountCostOfSales]);
    await listAccounts.verifyRowExists(accountOperatingCost, [accountCostOfSales]);
    await listAccounts.verifyRowExists(accountSourcingCost, [accountCostOfSales]);
    await listAccounts.verifyRowExists(accountProcessPreferenceCost);
    await listAccounts.verifyRowExists(accountTransportationLotCost, [accountCostOfSales]);
    await listAccounts.verifyRowExists(accountSourcingLotCost, [accountCostOfSales]);
  });
});