renhao
2023-09-21 1aa9f2bb83dd9e4b7517f1cbf06b0db53979bb31
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/**
 * @file        ADSO-10126, ADSO-10128, ADSO-10129 - Operations and Operation Costs display
 * @description Verify operation cost instances display result after filtering applied either via accounts form / navigation panel
 * @author      Wong Jia Hui (jiahui.wong@3ds.com)
 * @copyright   Dassault Systèmes
 */
import { qCustomMatcher } from '../../../e2elib/lib/src/main/qmatchers.const';
import { AppMP, Demo, Scenario } from '../../../libmp/appmp';
import { DataFoodBaseEntity, DataFoodBaseEntityName } from '../../../libmp/data/data.navigation';
import { ListEntityColumnName } from '../../../libmp/forms/navigationpanel/form.navigationpanel';
 
describe('ADSO-10126, ADSO-10128, ADSO-10129 - Verify OperationCost form display result after filter applied', () => {
  const appMP = AppMP.getInstance();
  let errMsg = '';
  let compareStringArray = [DataFoodBaseEntityName.HUFermenter, DataFoodBaseEntityName.HUStrainer, DataFoodBaseEntityName.HUFinishing, DataFoodBaseEntityName.HUPackaging];
  beforeAll(async () => {
    jasmine.addMatchers(qCustomMatcher);
    await appMP.login();
  });
 
  afterAll(async () => {
    await appMP.cleanupAndLogout();
  });
 
  afterEach(async () => {
    await appMP.checkToastMessage();
  });
 
  describe('ADSO-10126 - Verify OperationCost display result after filter applied via FilterByAccount checkbox and navigation panel', () => {
    it(`Setup - ${AppMP.getDemoDataPath(Demo.Food, Scenario.Base)}`, async () => {
      await appMP.createDemoDataset(Demo.Food, Scenario.Base, false);
    });
 
    it(`Setup - Open view ${appMP.viewOperationCost.viewPath}. Open navigation panel and click Home button to reset navigation to root operations.`, async () => {
      // Go to operation cost view and make sure operation, operation acc, and opertion cost form is opened
      await appMP.viewOperationCost.switchTo();
      await appMP.formNavigation.openNavigationPanel();
      // Click on home button on navigation panel to reset filter (if there is any filter set in navigation panel)
      // FIXME: CL219809 - Home button does not reset hidden child, due to changes of checkbox behavior.
      // Use this only if the targeted row is visible in the list
      await appMP.formNavigation.resetNaviToRoot();
    });
 
    it('Setup - Click StockingPoints and Units button and then resize "DisplayName" column', async () => {
      // Open 'StockingPoints and Units' list (ListEntity) in navigation panel by clicking on 'StockingPoints and Units' button (ButtonNavEntity)
      await appMP.formNavigation.toggleEntityList();
      // Resize DisplayName column in case DisplayName value will be show as "Hungary Pl..."
      await appMP.formNavigation.listEntity.resizeColumnWithCoveredName(ListEntityColumnName.DisplayName, 200);
    });
 
    it('Step 1 - Toggle ON Filter by Accounts in Operation Costs form.', async () => {
      // toggle on Filter by acocunts in operation cost form (it should be uncheck by default)
      await appMP.viewOperationCost.frmOperationCost.toggleFilterByAccount(true);
      expect(await appMP.viewOperationCost.frmOperationCost.cbFilterByAccounts.isChecked()).toBe(true, 'Checkbox FilterByAccounts should be checked');
    });
 
    it('Step 2 - In Operations Accounts form, select Rework cost account and verify Operation costs showing no cost', async () => {
      // toggle on Filter by acocunts in operation cost form (it should be uncheck by default)
      await appMP.viewOperationCost.frmOperationCost.toggleFilterByAccount(true);
      expect(await appMP.viewOperationCost.frmOperationCost.cbFilterByAccounts.isChecked()).toBe(true, 'Checkbox FilterByAccounts should be checked');
      // Select "Rework cost account" in operation account form
      await appMP.viewOperationCost.frmOperationsAccount.listOperationAccount.selectOperationAccountRowByName('Rework cost');
      // Verify there is no any row in operation cost form
      expect(await appMP.viewOperationCost.frmOperationCost.listOperationCost.getOperationCostRowCount()).toEqual(0, 'There should be no any instances show after filtered by "Rework cost account"');
    });
 
    it('Step 3 - Select Labor cost account in Operation Accounts list and check DE Fermenter in the navigation panel', async () => {
      // Select Labor cost in operation account form and check "DE Fermenter" unit in navigation panel
      await appMP.viewOperationCost.frmOperationsAccount.listOperationAccount.selectOperationAccountRowByName('Labor cost');
 
      // Check leaf units DE Fermenter
      await appMP.formNavigation.listEntity.toggleEntityRowCheckbox(true, DataFoodBaseEntityName.DEFermenter, DataFoodBaseEntity.deUnitsParents);
      const row = await appMP.formNavigation.listEntity.getRowByCellValue(ListEntityColumnName.DisplayName, DataFoodBaseEntityName.DEFermenter);
      expect(await row.isChecked()).toBe(true, 'DE Fermenter row checkbox should be checked');
    });
 
    it('Step 4 - Verify Operations Costs showing 1 Labor cost of DE Fermenter', async () => {
      // Verify operation cost form display only show instances with "Labor cost" and "DE Fermenter" unit
      const operationCostRows = await appMP.viewOperationCost.frmOperationCost.listOperationCost.getAllOperationCostRows();
      for (const row of operationCostRows) {
        const accountColumnCellValue = await appMP.viewOperationCost.frmOperationCost.listOperationCost.getCellValueFromRow('Account', row);
        expect(accountColumnCellValue).toEqual('Labor cost', 'All rows in OperationCostList should have Account value as "Labor cost"');
        const unitColumnCellValue = await appMP.viewOperationCost.frmOperationCost.listOperationCost.getCellValueFromRow('Unit', row);
        expect(unitColumnCellValue).toEqual('DE Fermenter', 'All rows in OperationCostList should have Unit value as "DE Fermenter"');
      }
    });
 
    it('Step 5 - Toggle OFF Filter by Accounts in Operation Costs form. Verify there are two operation costs of DE Fermenter: 1 Labor cost and 1 Operating cost', async () => {
      const rowCountBeforeToggleOffFilter = await appMP.viewOperationCost.frmOperationCost.listOperationCost.getOperationCostRowCount();
      // toggle off Filter by account in operation cost form
      await appMP.viewOperationCost.frmOperationCost.toggleFilterByAccount(false);
      expect(await appMP.viewOperationCost.frmOperationCost.cbFilterByAccounts.isChecked()).toBe(false, 'Checkbox FilterByAccounts should be uncheck');
      expect(await appMP.viewOperationCost.frmOperationCost.listOperationCost.getOperationCostRowCount()).toBeGreaterThan(rowCountBeforeToggleOffFilter, 'Number of row in OperationCost form should increase after unchecked FilterByAccount');
      // Verify operation cost form display only show instances with "DE Fermenter" unit with other account other than "Labor cost"
      const operationCostRows = await appMP.viewOperationCost.frmOperationCost.listOperationCost.getAllOperationCostRows();
      for (const row of operationCostRows) {
        const unitColumnCellValue = await appMP.viewOperationCost.frmOperationCost.listOperationCost.getCellValueFromRow('Unit', row);
        expect(unitColumnCellValue).toEqual('DE Fermenter', 'All rows in OperationCostList should have Unit value as "DE Fermenter"');
      }
    });
 
    it('Cleanup - Toggle off Filter By Account in operation cost; click Home button in navigation panel to reset filter in StockingPoints and Units list and collapse the list', async () => {
      // Toggle off Filter By Account in operation cost
      await appMP.viewOperationCost.frmOperationCost.toggleFilterByAccount(false);
      expect(await appMP.viewOperationCost.frmOperationCost.cbFilterByAccounts.isChecked()).toBe(false, 'Checkbox FilterByAccounts should be uncheck');
      // uncheck leaf units DE Fermenter.
      await appMP.formNavigation.resetNaviToRoot();
      // Collapse Denmark Plant
      const row = await appMP.formNavigation.listEntity.getRowByCellValue(ListEntityColumnName.DisplayName, DataFoodBaseEntityName.DenmarkPlant, DataFoodBaseEntity.plantsParent);
      await row.collapseRow();
    });
  });
 
  describe('ADSO-10128 - Verify OperationCost display result after filter applied via navigation panel (filter by parent unit)', () => {
    it('Step 1 - In navigation panel, select Hungary Plant unit', async () => {
      // Check Hungary Plant unit in navigation panel
      await appMP.formNavigation.listEntity.toggleEntityRowCheckbox(true, DataFoodBaseEntityName.HungaryPlant, DataFoodBaseEntity.plantsParent);
      const row = await appMP.formNavigation.listEntity.getRowByCellValue(ListEntityColumnName.DisplayName, DataFoodBaseEntityName.HungaryPlant);
      expect(await row.isChecked()).toBe(true, 'Hungary Plant row checkbox should be checked');
    });
 
    it('Step 2 - Verify Operations list shows all operations related to HU Fermenter(1), HU Packaging(8) and HU Strainer(4)', async () => {
      // Get all operation rows show and verify if the Unit value is either "HU Fermenter", "HU Strainer", "HU Finishing" or "HU Packaging"
      const operationRows = await appMP.viewOperationCost.frmOperations.listOperations.getAllOperationRows();
      errMsg = 'Unit value of UnitCost row should be either "HU Fermenter", "HU Finishing", "HU Packaging" or "HU Strainer"';
      const isAllRowsValid = await appMP.viewOperationCost.frmOperations.listOperations.verifyAllRowsSatisfyColumnValuesByUnit(operationRows, compareStringArray);
      expect(isAllRowsValid).toBe(true, errMsg);
    });
 
    it('Step 3 - Verify Operations Costs list shows all operation costs related to HU Fermenter(2), HU Finishing(16), HU Packaging(16) and HU Strainer(8)', async () => {
      // Get all operation cost rows show and verify if the Unit value is either "HU Fermenter", "HU Strainer", "HU Finishing" or "HU Packaging"
      const operationCostRows = await appMP.viewOperationCost.frmOperationCost.listOperationCost.getAllOperationCostRows();
      const isAllRowsValid = await appMP.viewOperationCost.frmOperationCost.listOperationCost.verifyAllRowsSatisfyColumnValuesByUnit(operationCostRows, compareStringArray);
      expect(isAllRowsValid).toBe(true, errMsg);
    });
 
    it('Cleanup - Toggle off Filter By Account in operation cost; click Home button in navigation panel to reset filter in StockingPoints and Units list', async () => {
      // Toggle off Filter By Account in operation cost
      await appMP.viewOperationCost.frmOperationCost.toggleFilterByAccount(false);
      expect(await appMP.viewOperationCost.frmOperationCost.cbFilterByAccounts.isChecked()).toBe(false, 'Checkbox FilterByAccounts should be uncheck');
 
      // Uncheck Hungary Plant unit in navigation panel
      await appMP.formNavigation.listEntity.toggleEntityRowCheckbox(false, DataFoodBaseEntityName.HungaryPlant, DataFoodBaseEntity.plantsParent);
    });
  });
 
  describe('ADSO-10129 - Verify OperationCost display result after filter applied via navigation panel (filter by leaf units)', () => {
    it('Step 1 - In navigation panel, select leaf Operations HU Fermenter', async () => {
      // Check HU Fermenter unit in navigation panel
      await appMP.formNavigation.listEntity.toggleEntityRowCheckbox(true, DataFoodBaseEntityName.HUFermenter, DataFoodBaseEntity.huUnitsParent);
      const row = await appMP.formNavigation.listEntity.getRowByCellValue(ListEntityColumnName.DisplayName, DataFoodBaseEntityName.HUFermenter);
      expect(await row.isChecked()).toBe(true, 'HU Fermenter row checkbox should be checked');
    });
 
    it('Step 2 - In navigation panel, select leaf Operations HU Strainer', async () => {
      // Check HU Strainer unit in navigation panel
      await appMP.formNavigation.listEntity.toggleEntityRowCheckbox(true, DataFoodBaseEntityName.HUStrainer, DataFoodBaseEntity.huUnitsParent);
      const row = await appMP.formNavigation.listEntity.getRowByCellValue(ListEntityColumnName.DisplayName, DataFoodBaseEntityName.HUStrainer);
      expect(await row.isChecked()).toBe(true, 'HU Strainer row checkbox should be checked');
    });
 
    it('Step 3 - Verify Operations list show 1 operation of HU Fermenter and 4 operations of HU Strainer', async () => {
      compareStringArray = [DataFoodBaseEntityName.HUFermenter, DataFoodBaseEntityName.HUStrainer];
      // Get all operation rows show and verify if the Unit value is either "HU Fermenter" or "HU Strainer"
      const operationRows = await appMP.viewOperationCost.frmOperations.listOperations.getAllOperationRows();
      errMsg = 'Unit value of UnitCost row should be either "HU Fermenter" or "HU Strainer"';
      const isAllRowsValid = await appMP.viewOperationCost.frmOperations.listOperations.verifyAllRowsSatisfyColumnValuesByUnit(operationRows, compareStringArray);
      expect(isAllRowsValid).toBe(true, errMsg);
    });
 
    it('Step 4 - Verify Operation Costs list showing 2 costs for HU Fermenter and 8 costs for HU Strainer', async () => {
      // Get all operation cost rows show and verify if the Unit value is either "HU Fermenter" or "HU Strainer"
      const operationCostRows = await appMP.viewOperationCost.frmOperationCost.listOperationCost.getAllOperationCostRows();
      const isAllRowsValid = await appMP.viewOperationCost.frmOperationCost.listOperationCost.verifyAllRowsSatisfyColumnValuesByUnit(operationCostRows, compareStringArray);
      expect(isAllRowsValid).toBe(true, errMsg);
    });
 
    it('Cleanup - Collapse Hungary Plant, Plants, Europe rows', async () => {
      // Uncheck HU Fermenter & HU Strainer unit in navigation panel
      await appMP.formNavigation.resetNaviToRoot();
      // Collapse Hungary Plant row
      let row = await appMP.formNavigation.listEntity.getRowByCellValue(ListEntityColumnName.DisplayName, DataFoodBaseEntityName.HungaryPlant, DataFoodBaseEntity.plantsParent);
      await row.collapseRow();
      // Collapse Plants row
      row = await appMP.formNavigation.listEntity.getRowByCellValue(ListEntityColumnName.DisplayName, DataFoodBaseEntityName.Plants, [DataFoodBaseEntityName.Europe]);
      await row.collapseRow();
      // Collapse Europe row
      row = await appMP.formNavigation.listEntity.getRowByCellValue(ListEntityColumnName.DisplayName, DataFoodBaseEntityName.Europe);
      await row.collapseRow();
    });
  });
});