/** 
 | 
 * @file        ADSO-9412 
 | 
 * @description Verify product planning matrix sanity check - unfulfilled sales demands on PISPIP 
 | 
 * @author      Gay Er Xuan (erxuan.gay@3ds.com) 
 | 
 * @copyright   Dassault Systèmes 
 | 
 */ 
 | 
import { QConsole } from '../../e2elib/lib/src/helper/qconsole'; 
 | 
import { qCustomMatcher } from '../../e2elib/lib/src/main/qmatchers.const'; 
 | 
import { AppMP, Demo, Scenario } from '../../libmp/appmp'; 
 | 
import { DataFoodBaseProductName, DataLowFatVanilla6 } from '../../libmp/data/data.navigation'; 
 | 
import { startOfPlanningYear } from '../../libmp/data/data.period'; 
 | 
  
 | 
describe('ADSO-9412 - Verify product planning matrix sanity check - unfulfilled sales demands on PISPIP', () => { 
 | 
  const appMP = AppMP.getInstance(); 
 | 
  const formProductPlanning = appMP.viewSupplyPlanning.frmProductPlanning; 
 | 
  const janSOP = `1-Jan-${startOfPlanningYear}`; 
 | 
  
 | 
  beforeAll(async () => { 
 | 
    jasmine.addMatchers(qCustomMatcher); 
 | 
    await appMP.login(); 
 | 
  }); 
 | 
  
 | 
  afterAll(async () => { 
 | 
    await appMP.cleanupAndLogout(); 
 | 
  }); 
 | 
  
 | 
  afterEach(async () => { 
 | 
    await appMP.checkToastMessage(); 
 | 
  }); 
 | 
  
 | 
  it(`Setup - ${AppMP.getDemoDataPath(Demo.Food, Scenario.Base)}`, async () => { 
 | 
    await appMP.createDemoDataset(Demo.Food, Scenario.Base); 
 | 
  }); 
 | 
  
 | 
  it(`Setup - Open view ${appMP.viewSupplyPlanning.viewPath}`, async () => { 
 | 
    await appMP.viewSupplyPlanning.switchTo(); 
 | 
  }); 
 | 
  
 | 
  it('Setup - Ensure navigation panel is visible', async () => { 
 | 
    await appMP.formNavigation.openNavigationPanel(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 1 - In navigation panel, click Product button to show product list. Select ${DataFoodBaseProductName.LowfatVanilla6pk} product`, async () => { 
 | 
    // Click Product button to show Products list 
 | 
    const listProduct = appMP.formNavigation.listProduct; 
 | 
    await appMP.formNavigation.toggleProductList(true); 
 | 
  
 | 
    // Check Lowfat Vanilla 6 pk product in navigation panel 
 | 
    const row = await listProduct.getRow({Name: DataLowFatVanilla6.name}, DataLowFatVanilla6.parents); 
 | 
    await listProduct.toggleRowCheckbox(row, true); 
 | 
    expect(await row.isChecked()).toBe(true, `${DataLowFatVanilla6.name} row checkbox should be checked`); 
 | 
  }); 
 | 
  
 | 
  it(`Step 2 - In product planning form, set supply of ${DataFoodBaseProductName.LowfatVanilla6pk} to 0 on ${janSOP}`, async () => { 
 | 
    // Wait matrix editor refresh and stable 
 | 
    await QConsole.waitForStable(1000); 
 | 
    // Get demand and set supply to 0 
 | 
    await formProductPlanning.meProductPlanning.setTotalSupply(0, janSOP, 0); 
 | 
  }); 
 | 
  
 | 
  it(`Step 3 - Verify demand for ${DataFoodBaseProductName.LowfatVanilla6pk} on ${janSOP} is highlighted orange (unfufilled demand)`, async () => { 
 | 
    // wait optimizer run finished 
 | 
    await QConsole.waitForStable(5000); 
 | 
    // Verify background color of the demand cell 
 | 
    expect(await formProductPlanning.getDemandBackgroundColor(0, janSOP)).toBe('rgb(255, 204, 153)', 'Background color of demand cell should be orange(255, 204, 153)'); 
 | 
  }); 
 | 
}); 
 |