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
/**
 * @file        ADSO-51336
 * @description Verify production planning view along with Navigation
 * @author      Zayn Shaikh (SHAIKH.zayn@3ds.com)
 * @copyright   Dassault Systèmes
 */
 
import { qCustomMatcher } from '../../e2elib/lib/src/main/qmatchers.const';
import { AppMP, Demo, Scenario } from '../../libmp/appmp';
import { DataFoodBaseEntityName, DataFoodBaseProductName, DataLowFatVanilla6 } from '../../libmp/data/data.navigation';
import { startOfPlanningYear } from '../../libmp/data/data.period';
import { StepNavigationPanel } from '../../libmp/forms/navigationpanel/form.navigationpanel';
import { StepMatrix } from '../../libappsop/matrixeditorsop';
import { CellColors, MatrixEditorProductionPlan } from '../../libmp/forms/form.productionplan';
import { dataFoodUnits, dataFoodUnitsProvider } from '../../libmp/data/data.unit';
import { dataFoodProducts } from '../../libmp/data/data.product';
import { DataHierarchy } from '../../libappsop/datahierarchy';
 
describe('ADSO-51336 - Verify production planning view along with Navigation', () => {
  const appMP = AppMP.getInstance();
  const formProductionPlan = appMP.viewProductionPlan.formProductionPlan;
  const aprilSOP = `1-Apr-${startOfPlanningYear}`;
  const maySOP = `1-May-${startOfPlanningYear}`;
  const stockingDEWarehouse = DataFoodBaseEntityName.DEWarehouse;
  const stockingDEWarehouseParent = [DataFoodBaseEntityName.Europe];
  const [unitDEPackaging, unitDEPackagingParents] = dataFoodUnitsProvider.getHierarchy(dataFoodUnits.DEPackaging);
 
  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);
  });
 
  it(`Setup - Open view ${appMP.viewProductionPlan.viewPath}`, async () => {
    await appMP.viewProductionPlan.switchTo();
  });
 
  it(`Step 1 - ${StepNavigationPanel.showEntitiesList()} ${StepNavigationPanel.checkStockingPoints([stockingDEWarehouse])}`, async () => {
    await appMP.formNavigation.filterByEntity(stockingDEWarehouse, stockingDEWarehouseParent);
  });
 
  it(`Step 2 - ${StepMatrix.verifyTotalRow(MatrixEditorProductionPlan.title, 8)}`, async () => {
    await formProductionPlan.meProductionPlan.verifyTotalRow(8);
  });
 
  it(`Step 3 - ${StepNavigationPanel.showProductsList()} ${StepNavigationPanel.checkProducts([DataFoodBaseProductName.LowfatVanilla6pk])}`, async () => {
    await appMP.formNavigation.filterByProduct({ Name: DataFoodBaseProductName.LowfatVanilla6pk }, DataLowFatVanilla6.parents);
  });
 
  it(`Step 4 - ${StepMatrix.verifyTotalRow(MatrixEditorProductionPlan.title, 1)}`, async () => {
    await formProductionPlan.meProductionPlan.verifyTotalRow(1);
  });
 
  it(`Step 5 - ${StepMatrix.verifyCellColor(MatrixEditorProductionPlan.title, '0', aprilSOP, CellColors.hasSupply().Color)}`, async () => {
    await formProductionPlan.meProductionPlan.verifyCellColor(0, aprilSOP, CellColors.hasSupply().Rgb);
  });
 
  it(`Step 6 - ${StepMatrix.verifyCellColor(MatrixEditorProductionPlan.title, '0', maySOP, CellColors.noSupply().Color)}`, async () => {
    await formProductionPlan.meProductionPlan.verifyCellColor(0, maySOP, CellColors.noSupply().Rgb);
  });
 
  it(`Step 7 - ${StepNavigationPanel.clickHomeResetToRoot()}`, async () => {
    await appMP.formNavigation.resetNaviToRoot();
    await appMP.formNavigation.toggleProductList(false);
  });
 
  it(`Step 8 - ${StepNavigationPanel.checkUnits([unitDEPackaging.Name])}`, async () => {
    const parentsArr = unitDEPackagingParents.map((x: DataHierarchy) => x.Name);
    await appMP.formNavigation.filterByEntity(unitDEPackaging.Name, parentsArr);
  });
 
  it(`Step 9 - ${StepMatrix.verifyTotalRow(MatrixEditorProductionPlan.title, 8)}`, async () => {
    await formProductionPlan.meProductionPlan.verifyTotalRow(8);
  });
 
  it(`Step 10 - ${StepNavigationPanel.checkProducts([dataFoodProducts.LowfatStrawberry12pk.Name])}`, async () => {
    await appMP.formNavigation.toggleProductList();
    const [strawberry12pk, parents] = appMP.formNavigation.listProduct.getHierarchy(dataFoodUnitsProvider, dataFoodProducts.LowfatStrawberry12pk);
    await appMP.formNavigation.filterByProduct(strawberry12pk, parents!);
  });
 
  it(`Step 11 - ${StepMatrix.verifyTotalRow(MatrixEditorProductionPlan.title, 1)}`, async () => {
    await formProductionPlan.meProductionPlan.verifyTotalRow(1);
  });
});