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-9913
 * @description Update user KPI selection for a given view
 * @author      Pethaperumal Natarajan (Pethaperumal.NATARAJAN.intern@3ds.com)
 * @copyright   Dassault Systèmes
 */
 
import { AppMP, Demo, Scenario, 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';
 
describe('ADSO-9913 - Update user KPI selection for a given view', () => {
  const appMP = AppMP.getInstance();
  const formKPI = appMP.frmKPI;
  const listKPISelection = formKPI.panelKPISelection.lstKPISelection;
  const gaugeKPIDashboard = formKPI.panelKPIDashboard.gaugeKPIDashboard;
 
  const kpiSupplyPlanning = [DataKPIName.Fulfillment, DataKPIName.Margin];
  const kpiForecast = [DataKPIName.FulfillmentTarget, DataKPIName.PostponementPenalty];
  const verifyExactMatch = true;
  const clearViewCache = false;
 
  beforeAll(async () => {
    jasmine.addMatchers(qCustomMatcher);
 
    // libappbase framework by default turn off auto view save, this test needs it ON else KPI selection won't persist in the view. to turn off by end of test
    await appMP.login(undefined, clearViewCache);
  });
 
  afterAll(async () => {
    await appMP.disableAutoViewSave(); // revert to original value as we turn ON at beginning of this test
    await appMP.resetActiveView(appMP.viewSupplyPlanning);
    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.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(kpiSupplyPlanning)}`, async () => {
    await listKPISelection.deselectAllKPI();
    await listKPISelection.selectKPI(kpiSupplyPlanning, Timeout.Short);
  });
 
  it(`Step 5 - ${StepForm.clickPanel(FormKPI.title, PanelKPIDashboard.title)}`, async () => {
    await formKPI.openKPIDashboardPanel();
  });
 
  it(`Step 6 - ${StepGauge.verifyGaugesPresent(GaugeKPIDashboard.title, kpiSupplyPlanning, verifyExactMatch)}`, async () => {
    await gaugeKPIDashboard.verifyGaugesPresent(kpiSupplyPlanning, verifyExactMatch);
  });
 
  it(`Step 7 - Open view ${appMP.viewForecasts.viewPath}.`, async () => {
    await appMP.viewForecasts.switchTo();
  });
 
  it(`Step 8 - ${StepForm.clickPanel(FormKPI.title, PanelKPISelection.title)}`, async () => {
    await formKPI.openKPISelectionPanel();
  });
 
  it(`Step 9 - ${StepFormKPI.deselectAllKPI()} ${StepFormKPI.selectKPI(kpiForecast)}`, async () => {
    await listKPISelection.deselectAllKPI();
    await listKPISelection.selectKPI(kpiForecast, Timeout.Short);
  });
 
  it(`Step 10 - ${StepForm.clickPanel(FormKPI.title, PanelKPIDashboard.title)}`, async () => {
    await formKPI.openKPIDashboardPanel();
  });
 
  it(`Step 11 - ${StepGauge.verifyGaugesPresent(GaugeKPIDashboard.title, kpiForecast, verifyExactMatch)}`, async () => {
    await gaugeKPIDashboard.verifyGaugesPresent(kpiForecast, verifyExactMatch);
  });
 
  it(`Step 12 - Open view ${appMP.viewSupplyPlanning.viewPath}.`, async () => {
    await appMP.viewSupplyPlanning.switchTo();
  });
 
  it(`Step 13 - ${StepGauge.verifyGaugesPresent(GaugeKPIDashboard.title, kpiSupplyPlanning, verifyExactMatch)}`, async () => {
    await gaugeKPIDashboard.verifyGaugesPresent(kpiSupplyPlanning, verifyExactMatch);
  });
});