/** 
 | 
 * @file        ADSO-9915 
 | 
 * @description User KPI selection for a given view does not impact other users preferences 
 | 
 * @author      Pethaperumal Natarajan (Pethaperumal.NATARAJAN.intern@3ds.com) 
 | 
 * @copyright   Dassault Systèmes 
 | 
 */ 
 | 
  
 | 
import { AppMP, Demo, QuintiqUser, 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'; 
 | 
  
 | 
describe('ADSO-9915 - User KPI selection for a given view does not impact other users preferences', () => { 
 | 
  const appMP = AppMP.getInstance(); 
 | 
  const formKPI = appMP.frmKPI; 
 | 
  const listKPISelection = formKPI.panelKPISelection.lstKPISelection; 
 | 
  const gaugeKPIDashboard = formKPI.panelKPIDashboard.gaugeKPIDashboard; 
 | 
  
 | 
  const kpiSupplyPlanningUser01 = [DataKPIName.Fulfillment, DataKPIName.Margin]; 
 | 
  const kpiSupplyPlanningUser02 = [DataKPIName.Sales]; 
 | 
  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); 
 | 
  }); 
 | 
  
 | 
  afterAll(async () => { 
 | 
    await appMP.disableAutoViewSave(); // revert to original value as we turn ON at beginning of this test (via appMP.login) 
 | 
    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(kpiSupplyPlanningUser01)}`, async () => { 
 | 
    await listKPISelection.deselectAllKPI(); 
 | 
    await listKPISelection.selectKPI(kpiSupplyPlanningUser01, Timeout.Short); 
 | 
  }); 
 | 
  
 | 
  it(`Step 5 - ${StepForm.clickPanel(FormKPI.title, PanelKPIDashboard.title)}`, async () => { 
 | 
    await formKPI.openKPIDashboardPanel(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 6 - ${StepGauge.verifyGaugesPresent(GaugeKPIDashboard.title, kpiSupplyPlanningUser01, verifyExactMatch)}`, async () => { 
 | 
    await gaugeKPIDashboard.verifyGaugesPresent(kpiSupplyPlanningUser01, verifyExactMatch); 
 | 
  }); 
 | 
  
 | 
  it(`Step 7 - ${StepAppMP.logout()} ${StepAppMP.loginAs(QuintiqUser.QuintiqService)}`, async () => { 
 | 
    await appMP.logout(); 
 | 
    await appMP.login(QuintiqUser.QuintiqService, clearViewCache); 
 | 
  }); 
 | 
  
 | 
  it(`Step 8 - Open view ${appMP.viewSupplyPlanning.viewPath}.`, async () => { 
 | 
    await appMP.viewSupplyPlanning.switchTo(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 9 - ${StepForm.clickPanel(FormKPI.title, PanelKPISelection.title)}`, async () => { 
 | 
    await formKPI.openKPISelectionPanel(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 10 - ${StepFormKPI.deselectAllKPI()} ${StepFormKPI.selectKPI(kpiSupplyPlanningUser02)}`, async () => { 
 | 
    await listKPISelection.deselectAllKPI(); 
 | 
    await listKPISelection.selectKPI(kpiSupplyPlanningUser02, Timeout.Short); 
 | 
  }); 
 | 
  
 | 
  it(`Step 11 - ${StepForm.clickPanel(FormKPI.title, PanelKPIDashboard.title)}`, async () => { 
 | 
    await formKPI.openKPIDashboardPanel(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 12 - ${StepGauge.verifyGaugesPresent(GaugeKPIDashboard.title, kpiSupplyPlanningUser02, verifyExactMatch)}`, async () => { 
 | 
    await gaugeKPIDashboard.verifyGaugesPresent(kpiSupplyPlanningUser02, verifyExactMatch); 
 | 
  }); 
 | 
  
 | 
  it(`Step 13 - ${StepAppMP.logout()} ${StepAppMP.loginAs(QuintiqUser.Administrator)}`, async () => { 
 | 
    await appMP.logout(); 
 | 
    await appMP.login(QuintiqUser.Administrator, clearViewCache); 
 | 
  }); 
 | 
  
 | 
  it(`Step 14 - Open view ${appMP.viewSupplyPlanning.viewPath}.`, async () => { 
 | 
    await appMP.viewSupplyPlanning.switchTo(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 15 - ${StepForm.clickPanel(FormKPI.title, PanelKPIDashboard.title)}`, async () => { 
 | 
    await formKPI.openKPIDashboardPanel(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 16 - ${StepGauge.verifyGaugesPresent(GaugeKPIDashboard.title, kpiSupplyPlanningUser01, verifyExactMatch)}`, async () => { 
 | 
    await gaugeKPIDashboard.verifyGaugesPresent(kpiSupplyPlanningUser01, verifyExactMatch); 
 | 
  }); 
 | 
}); 
 |