/** 
 | 
 * @file          ADSO-48500 - Navigation and Matrix performance 
 | 
 * @description   Performance testing on navigation and matrix 
 | 
 * @testCategory  Web app - Performance test - Matrix and chart 
 | 
 * @author        Peng Hing (penghing.ng@3ds.com) 
 | 
 * @copyright     Dassault Systèmes 
 | 
 */ 
 | 
import { qCustomMatcher } from '../../e2elib/lib/src/main/qmatchers.const'; 
 | 
import { AppMP, Demo, Scenario } from '../../libmp/appmp'; 
 | 
import { DataBCCBWide, DataMetalBaseEntityName } from '../../libmp/data/data.navigation'; 
 | 
import { GanttChartAction } from '../../e2elib/lib/src/pageobjects/ganttchart/ganttchart.component'; 
 | 
import { DataMatrixProductPlanningAttributeName, DataMatrixProductPlanningRowName } from '../../libmp/data/data.supplyplanning'; 
 | 
import { ListScenarioContextMenuItem, ScenarioManager } from '../../libmp/forms/form.scenario'; 
 | 
import { DataPCSBase } from '../../libmp/datafile/data.pcs'; 
 | 
import { browser } from '../../e2elib/node_modules/protractor/built'; 
 | 
import { DataProvider } from '../../libmp/dataprovider'; 
 | 
import { UtilSOP } from '../../libappsop/utilsop'; 
 | 
  
 | 
describe('ADSO-48500 - Navigation and Matrix performance', () => { 
 | 
  const appMP = AppMP.getInstance(); 
 | 
  const viewSupplyPlanning = appMP.viewSupplyPlanning; 
 | 
  const formCapacityPlanning = viewSupplyPlanning.frmCapacityPlanning; 
 | 
  const ganttChartCapacityPlanning = formCapacityPlanning.ganttChartCapacityPlanning; 
 | 
  
 | 
  const formProductPlanning = viewSupplyPlanning.frmProductPlanning; 
 | 
  const matrixProductPlanning = formProductPlanning.meProductPlanning; 
 | 
  const formNavigation = appMP.formNavigation; 
 | 
  
 | 
  const product = DataBCCBWide.name; 
 | 
  const productParent = DataBCCBWide.parents; 
 | 
  const stockingPoint = DataMetalBaseEntityName.NorthAmerica; 
 | 
  const stockingPointParent = [DataMetalBaseEntityName.QAluminum]; 
 | 
  
 | 
  const matrixRowBCCBWide = DataMatrixProductPlanningRowName.BCCBWideInAsia; 
 | 
  const matrixRowLaQuinta = DataMatrixProductPlanningRowName.CPNCoilInNorthAmerica; 
 | 
  const matrixRowNorthAmerica = DataMatrixProductPlanningRowName.CPNCoilInNorthAmerica; 
 | 
  const matrixAttributeTotalDemand = DataMatrixProductPlanningAttributeName.TotalDemand; 
 | 
  const listScenario = appMP.viewScenarioAnalysisOverview.formScenario.lstScenario; 
 | 
  const ganttChartRowCasterLaQuinta = 'Caster (La Quinta)'; 
 | 
  const efficiency = '1.75'; 
 | 
  let dataPCS: DataPCSBase; 
 | 
  
 | 
  let isMemoryOnly = true; 
 | 
  
 | 
  beforeAll(async () => { 
 | 
    jasmine.addMatchers(qCustomMatcher); 
 | 
    await appMP.login(); 
 | 
  }); 
 | 
  
 | 
  afterAll(async () => { 
 | 
    await ganttChartCapacityPlanning.editRowTimeCapacity(ganttChartRowCasterLaQuinta, '1.00'); 
 | 
    await appMP.resetActiveView(viewSupplyPlanning); 
 | 
  
 | 
    if (isMemoryOnly) { 
 | 
      await appMP.viewScenario.switchTo(); 
 | 
  
 | 
      // Not to delete scenario with this prefix, reused for few tests 
 | 
      await appMP.viewScenario.formScenario.lstScenario.deleteAllScenarios(ScenarioManager.AllScenarios, 'ADSO-'); 
 | 
      await appMP.viewScenario.formScenario.lstScenario.deleteAllScenarios(ScenarioManager.RecycleBin); 
 | 
    } 
 | 
    await formNavigation.reset(); 
 | 
    await appMP.logout(); 
 | 
  }); 
 | 
  
 | 
  afterEach(async () => { 
 | 
    await appMP.checkToastMessage(); 
 | 
  }); 
 | 
  
 | 
  it(`Setup - Get data, dataset = ${browser.params.testdata.name}`, async () => { 
 | 
    dataPCS = await DataProvider.getInstance().getDataPCS(); 
 | 
    isMemoryOnly = dataPCS.testData === 'MetalDemo'; 
 | 
  }); 
 | 
  
 | 
  it(`Setup - Create demo data / Load Dataset [${Demo.Metals}], scenario [${Scenario.Base}]`, async () => { 
 | 
      // create and load Metal base dataset 
 | 
      if (isMemoryOnly) { 
 | 
        await appMP.createDemoDataset(Demo.Metals, Scenario.Base); 
 | 
      } else { 
 | 
        await listScenario.expandFolderAndSelectMenu(dataPCS.scenarioName, ListScenarioContextMenuItem.Load); 
 | 
        await listScenario.expandFolderAndSelectMenu(dataPCS.scenarioName, ListScenarioContextMenuItem.Select); 
 | 
        await appMP.verifyActiveScenario(dataPCS.scenarioName); 
 | 
      } 
 | 
  }); 
 | 
  
 | 
  it(`Setup - Open view ${viewSupplyPlanning.viewPath}`, async () => { 
 | 
    await viewSupplyPlanning.switchTo(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 1.1 - Using the navigation panel on the left hand side, tick product [${product}] under [${UtilSOP.transformInterfaceValuesToStringArray(productParent).join(', ')}]`, async () => { 
 | 
    await formNavigation.filterByProduct({Name: product}, productParent); 
 | 
  }); 
 | 
  
 | 
  it('Step 1.2 - [PCS] Matrix cell in the Product Planning form should be updated within 1 second of making a selection in the navigation panel', async () => { 
 | 
    // Verify the matrix product planning value is not empty or undefined 
 | 
    await matrixProductPlanning.verifyCellValue(matrixRowBCCBWide, matrixAttributeTotalDemand, dataPCS.dateStartA, dataPCS.cellValue1); 
 | 
  }); 
 | 
  
 | 
  it(`Step 2.1 - Press the Home button on the navigation panel to reset all previous selection and tick stocking point [${stockingPoint}] under [${stockingPointParent}]`, async () => { 
 | 
    // Home button 
 | 
    await formNavigation.reset(); 
 | 
  
 | 
    // Choose QAluminum -> North America 
 | 
    await formNavigation.filterByEntity(stockingPoint, stockingPointParent); 
 | 
  }); 
 | 
  
 | 
  it('Step 2.2 - Scroll to column 1-Jan-2023 on the Product Planning Matrix for row "CPN coil in North America"', async () => { 
 | 
    await matrixProductPlanning.scrollToRowByRowHeader(matrixRowNorthAmerica); 
 | 
  }); 
 | 
  
 | 
  it('Step 2.3 - [PCS] Elements in Capacity Planning and Product Planning forms should be filtered accordingly within 3 seconds', async () => { 
 | 
    await matrixProductPlanning.verifyCellValue(matrixRowLaQuinta, matrixAttributeTotalDemand, dataPCS.dateStartA, dataPCS.cellValue2); 
 | 
    await ganttChartCapacityPlanning.verifyGanttChartHasValue(ganttChartRowCasterLaQuinta, dataPCS.dateStartA, dataPCS.dateEndA); 
 | 
  }); 
 | 
  
 | 
  it('Step 3.1 - Click in the matrix on Product Planning form, press the right arrow key until until a previously unseen cell is loaded', async () => { 
 | 
    await matrixProductPlanning.navigateToColumnAppear(dataPCS.dateStartB, true); 
 | 
  }); 
 | 
  
 | 
  it('Step 3.2 - [PCS] Matrix values should be updated within 1 seconds of becoming visible', async () => { 
 | 
    await matrixProductPlanning.verifyCellValue(matrixRowNorthAmerica, matrixAttributeTotalDemand, dataPCS.dateStartB, dataPCS.cellValue3); 
 | 
  }); 
 | 
  
 | 
  it('Step 4.1 - Click on the Capacity Planning form, move the gantt chart to right with action bar button until a previously unseen cell is loaded', async () => { 
 | 
    await ganttChartCapacityPlanning.actions(GanttChartAction.MoveRight); 
 | 
  }); 
 | 
  
 | 
  it('Step 4.2 - [PCS] Gantt chart values should be updated within 1 seconds of becoming visible', async () => { 
 | 
    await ganttChartCapacityPlanning.verifyGanttChartHasValue(ganttChartRowCasterLaQuinta, dataPCS.dateStartB, dataPCS.dateEndB); 
 | 
  }); 
 | 
  
 | 
  it(`Step 5.1 - On the Capacity Planning form, right click on [${ganttChartRowCasterLaQuinta}] and select edit. Change efficiency = [${efficiency}] and save changes`, async () => { 
 | 
    await ganttChartCapacityPlanning.editRowTimeCapacity(ganttChartRowCasterLaQuinta, efficiency); 
 | 
  }); 
 | 
  
 | 
  it('Step 5.2 - [PCS] Verify that the whole row updated within 3 seconds to show the new utilization percentages', async () => { 
 | 
    await ganttChartCapacityPlanning.verifyGanttChartValue(ganttChartRowCasterLaQuinta, dataPCS.dateStartB, dataPCS.dateEndB, dataPCS.gcNodeValueAfterIncreaseEfficiency); 
 | 
  }); 
 | 
}); 
 |