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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**
 * @file        ADSO-9917
 * @description KPI selections saved per demo data type (Metals vs Food)
 * @author      Clarence (ccn7@3ds.com)
 * @copyright   Dassault Systèmes
 */
 
import { AppMP, Demo, Scenario, StepAppMP, Timeout } from '../../libmp/appmp';
import { qCustomMatcher } from '../../e2elib/lib/src/main/qmatchers.const';
import { FormKPI, GaugeKPIDashboard, PanelKPIDashboard, PanelKPISelection, StepFormKPI } from '../../libmp/forms/form.kpi';
import { DataKPIName } from '../../libmp/data/data.kpi';
import { StepForm } from '../../libappsop/formsop';
import { StepGauge } from '../../libappsop/gaugesop';
import { StepViewManager, ViewManagerSOP } from '../../libappsop/viewmanagersop';
 
describe('ADSO-9917 - KPI selections saved per demo data type (Metals vs Food)', () => {
  const appMP = AppMP.getInstance();
  const formKPI = appMP.frmKPI;
  const listKPISelection = formKPI.panelKPISelection.lstKPISelection;
  const gaugeKPIDashboard = formKPI.panelKPIDashboard.gaugeKPIDashboard;
 
  const kpiSupplyPlanningMetalsDemo = [DataKPIName.Fulfillment, DataKPIName.Margin];
  const kpiSupplyPlanningFoodDemo = [DataKPIName.Sales]; // MUST be different KPI to the one selected in Metals (to ease verification)
  const verifyExactMatch = true;
  const clearViewCache = false; // Must override false so that auto view cache NOT turned OFF
 
  beforeAll(async () => {
    jasmine.addMatchers(qCustomMatcher);
    await appMP.login(undefined, clearViewCache); // This test requires the auto view save feature. Remember to disable it back when test ends
  });
 
  afterAll(async () => {
    await appMP.disableAutoViewSave(); // revert to original value as we turn ON at beginning of this test (via appMP.login)
    await appMP.cleanupAndLogout();
  });
 
  afterEach(async () => {
    await appMP.checkToastMessage();
  });
 
  it(`Step 1 - ${AppMP.getDemoDataPath(Demo.Metals, Scenario.Base)}`, async () => {
    // We will create Metals demo, select 2 KPIs and redefine view stored with model
    // Then create another Food demo, select 1 different KPI and redefine view
    // This to ensure redefining view will preserve the KPI in each demo data type (Food vs Metals) and not overwrite each other for a given view
    await appMP.createDemoDataset(Demo.Metals, Scenario.Base, false);
  });
 
  it(`Step 2 - Open view ${appMP.viewSupplyPlanning.viewPath}.`, async () => {
    await appMP.viewSupplyPlanning.switchTo();
  });
 
  it(`Step 3 - ${StepForm.clickPanel(FormKPI.title, PanelKPISelection.title)}`, async () => {
    await formKPI.openKPISelectionPanel();
  });
 
  it(`Step 4 - ${StepFormKPI.deselectAllKPI()} ${StepFormKPI.selectKPI(kpiSupplyPlanningMetalsDemo)}`, async () => {
    await listKPISelection.deselectAllKPI();
    await listKPISelection.selectKPI(kpiSupplyPlanningMetalsDemo, Timeout.Short);
  });
 
  it(`Step 5 - ${StepForm.clickPanel(FormKPI.title, PanelKPIDashboard.title)}`, async () => {
    await formKPI.openKPIDashboardPanel();
  });
 
  it(`Step 6 - ${StepGauge.verifyGaugesPresent(GaugeKPIDashboard.title, kpiSupplyPlanningMetalsDemo, verifyExactMatch)}`, async () => {
    await gaugeKPIDashboard.verifyGaugesPresent(kpiSupplyPlanningMetalsDemo, verifyExactMatch);
  });
 
  it(`Step 7 - ${StepViewManager.redefineViewStoredWithModel(appMP.viewSupplyPlanning.name)}`, async () => {
    // This creates a view and store in the model layer (the one in library layer is ignored from this point onwards)
    await ViewManagerSOP.redefineViewStoredWithModelSOP(appMP.viewSupplyPlanning.name);
  });
 
  it(`Step 8 - ${AppMP.getDemoDataPath(Demo.Food, Scenario.FoodBaseWithRecall)}`, async () => {
    // Create Food demo that is not Base, else hard to distinguish the 2 Base scenarios from active scenario dropdown
    await appMP.createDemoDataset(Demo.Food, Scenario.FoodBaseWithRecall, false);
  });
 
  it(`Step 9 - Open view ${appMP.viewSupplyPlanning.viewPath}.`, async () => {
    await appMP.viewSupplyPlanning.switchTo();
  });
 
  it(`Step 10 - ${StepForm.clickPanel(FormKPI.title, PanelKPISelection.title)}`, async () => {
    await formKPI.openKPISelectionPanel();
  });
 
  it(`Step 11 - ${StepFormKPI.deselectAllKPI()} ${StepFormKPI.selectKPI(kpiSupplyPlanningFoodDemo)}`, async () => {
    await listKPISelection.deselectAllKPI();
    await listKPISelection.selectKPI(kpiSupplyPlanningFoodDemo, Timeout.Short);
  });
 
  it(`Step 12 - ${StepForm.clickPanel(FormKPI.title, PanelKPIDashboard.title)}`, async () => {
    await formKPI.openKPIDashboardPanel();
  });
 
  it(`Step 13 - ${StepGauge.verifyGaugesPresent(GaugeKPIDashboard.title, kpiSupplyPlanningFoodDemo, verifyExactMatch)}`, async () => {
    await gaugeKPIDashboard.verifyGaugesPresent(kpiSupplyPlanningFoodDemo, verifyExactMatch);
  });
 
  it(`Step 14 - ${StepViewManager.redefineViewStoredWithModel(appMP.viewSupplyPlanning.name)}`, async () => {
    await ViewManagerSOP.redefineViewStoredWithModelSOP(appMP.viewSupplyPlanning.name);
  });
 
  it(`Step 15 - ${StepAppMP.selectScenarioViaDropdown(Scenario.Base)}`, async () => {
    // Re-select metals base as active scenario
    await appMP.selectScenarioViaDropdown(Scenario.Base);
  });
 
  it(`Step 16 - Open view ${appMP.viewSupplyPlanning.viewPath}.`, async () => {
    await appMP.viewSupplyPlanning.switchTo();
  });
 
  it(`Step 17 - ${StepGauge.verifyGaugesPresent(GaugeKPIDashboard.title, kpiSupplyPlanningMetalsDemo, verifyExactMatch)}`, async () => {
    await gaugeKPIDashboard.verifyGaugesPresent(kpiSupplyPlanningMetalsDemo, verifyExactMatch);
  });
 
  it(`Step 18 - ${StepViewManager.resetToViewStoredInLibrary(appMP.viewSupplyPlanning.name)}`, async () => {
    // Remove the newly created view in model, so that the view is now based on the one bundled in the library
    // So to not affect subsequent tests that uses the view
    await ViewManagerSOP.resetToViewStoredInLibrarySOP(appMP.viewSupplyPlanning.name);
  });
});