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