yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
 * @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)');
  });
});