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
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-52491
 * @description Verify matrix cell enable state and filtered based on navigation
 * @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 { StepNavigationPanel } from '../../libmp/forms/navigationpanel';
import { DataFoodBaseEntityName } from '../../libmp/data/data.navigation';
import { StepMatrix } from '../../libappsop/matrixeditorsop';
import { dataFoodProducts } from '../../libmp/data/data.product';
import { ListProductColumn } from '../../libmp/forms/form.product';
import { startOfPlanningYear } from '../../libmp/data/data.period';
import { DataFoodPISP } from '../../libmp/data/data.pisp';
import { MatrixEditorTripPlan } from '../../libmp/forms/form.tripplan';
import { dataFoodUnits, dataFoodUnitsProvider } from '../../libmp/data/data.unit';
import { DataHierarchy } from '../../libappsop/datahierarchy';
 
describe('ADSO-52491 - Verify matrix cell enable state and filtered based on navigation', () => {
  const appMP = AppMP.getInstance();
  const formNavigation = appMP.formNavigation;
  const meTripPlan = appMP.viewTripPlan.formTripPlan.meTripPlan;
 
  const expectedRows1 = 8;
  const expectedRows2 = 1;
  const expectedCellValue = '66';
  const productRow: ListProductColumn = { Name: dataFoodProducts.GreekLemon12pk.Name };
  const productParent: ListProductColumn[] = [{ Name: dataFoodProducts.AllProducts.Name }, { Name: dataFoodProducts.FinishedGoods.Name }, { Name: dataFoodProducts.Greek.Name }];
  const columnApril = `1-Apr-${startOfPlanningYear}`;
  const columnMay = `1-May-${startOfPlanningYear}`;
 
  beforeAll(async () => {
    jasmine.addMatchers(qCustomMatcher);
    await appMP.login();
  });
 
  afterAll(async () => {
    await appMP.resetActiveView(appMP.viewTripPlan);
    await appMP.cleanupAndLogout();
  });
 
  afterEach(async () => {
    await appMP.checkToastMessage();
  });
 
  it(`Step 1 - ${AppMP.getDemoDataPath(Demo.Food, Scenario.Base)}`, async () => {
    // Need wait optimizer completes as we need a valid plan
    await appMP.createDemoDataset(Demo.Food, Scenario.Base, true);
  });
 
  it(`Step 2 - Open view ${appMP.viewTripPlan.viewPath}.`, async () => {
    await appMP.viewTripPlan.switchTo();
  });
 
  it(`Step 3 - ${StepNavigationPanel.showEntitiesList()} ${StepNavigationPanel.checkStockingPoints([DataFoodBaseEntityName.DCAustria])}`, async () => {
    await formNavigation.filterByEntity(DataFoodBaseEntityName.DCAustria, [DataFoodBaseEntityName.Europe]);
  });
 
  it(`Step 4 - ${StepMatrix.verifyTotalRow(MatrixEditorTripPlan.title, expectedRows1)}`, async () => {
    await meTripPlan.verifyTotalRow(expectedRows1);
  });
 
  it(`Step 5 - ${StepNavigationPanel.showProductsList()} ${StepNavigationPanel.checkProducts([dataFoodProducts.GreekLemon12pk.Name])}`, async () => {
    await formNavigation.filterByProduct(productRow, productParent);
  });
 
  it(`Step 6 - ${StepMatrix.verifyTotalRow(MatrixEditorTripPlan.title, expectedRows2)}`, async () => {
    await meTripPlan.verifyTotalRow(expectedRows2);
  });
 
  it(`Step 7 - ${StepMatrix.verifyCellValue(MatrixEditorTripPlan.title, DataFoodPISP.GreekLemon12PkDCAustria, columnApril, expectedCellValue)}`, async () => {
    await meTripPlan.verifyCellValue(DataFoodPISP.GreekLemon12PkDCAustria, 0, columnApril, expectedCellValue);
  });
 
  it(`Step 8 - ${StepMatrix.verifyCellHasNoData(MatrixEditorTripPlan.title, DataFoodPISP.GreekLemon12PkDCAustria, 0, columnMay)}`, async () => {
    await meTripPlan.verifyCellHasNoData(DataFoodPISP.GreekLemon12PkDCAustria, 0, columnMay);
  });
 
  it(`Step 9 - ${StepNavigationPanel.clickHomeResetToRoot()}`, async () => {
    await appMP.formNavigation.resetNaviToRoot();
    await appMP.formNavigation.toggleProductList(false);
  });
 
  it(`Step 10 - ${StepNavigationPanel.checkUnits([dataFoodUnits.EURail.Name])}`, async () => {
    const [unitEURail, unitEURailParents] = dataFoodUnitsProvider.getHierarchy(dataFoodUnits.EURail);
    const parentsArr = unitEURailParents.map((x: DataHierarchy) => x.Name);
    await formNavigation.filterByEntity(unitEURail.Name, parentsArr);
  });
 
  it(`Step 11 - ${StepMatrix.verifyTotalRow(MatrixEditorTripPlan.title, expectedRows1)}`, async () => {
    await meTripPlan.verifyTotalRow(expectedRows1);
  });
 
  it(`Step 12 - ${StepNavigationPanel.checkProducts([dataFoodProducts.GreekLemon12pk.Name])}`, async () => {
    const [greekLemon12pk, parents] = appMP.formNavigation.listProduct.getHierarchy(dataFoodUnitsProvider, dataFoodProducts.GreekLemon12pk);
    await appMP.formNavigation.filterByProduct(greekLemon12pk, parents!);
  });
 
  it(`Step 13 - ${StepMatrix.verifyTotalRow(MatrixEditorTripPlan.title, expectedRows2)}`, async () => {
    await meTripPlan.verifyTotalRow(expectedRows2);
  });
});