/** 
 | 
 * @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); 
 | 
  }); 
 | 
}); 
 |