haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
 * @file        ADSO-9503
 * @description Constraint on optimizer strategy with empty levels
 * @author      Pethaperumal Natarajan (Pethaperumal.NATARAJAN.intern@3ds.com)
 * @copyright   Dassault Systèmes
 */
 
import { AppMP, Demo, Scenario } from '../../libmp/appmp';
import { qCustomMatcher } from '../../e2elib/lib/src/main/qmatchers.const';
import { ListStrategy, ListStrategyContextMenuItem } from '../../libmp/forms/form.optimizerstrategies';
import { DialogStrategy, ListActiveGoals, ListActiveGoalsContextMenuItem } from '../../libmp/dialogs/dialog.strategy';
import { StepList } from '../../libappsop/listsop';
import { StepDialog } from '../../libappsop/dialogsop';
import { DialogGoal } from '../../libmp/dialogs/dialog.goal';
import { DataFoodStrategyName } from '../../libmp/data/data.strategy';
import { DataKPIName } from '../../libmp/data/data.kpi';
 
describe('ADSO-9503 - Constraint on optimizer strategy with empty levels', () => {
  const appMp = AppMP.getInstance();
  const listStrategy = appMp.viewOptimizerStrategies.frmOptimizerStrategies.listStrategy;
  let dlgStrategy: DialogStrategy;
  let listActiveGoals: ListActiveGoals;
  let dlgEdit: DialogGoal;
 
  beforeAll(async () => {
    jasmine.addMatchers(qCustomMatcher);
    await appMp.login();
  });
 
  afterAll(async () => {
    await appMp.resetActiveView(appMp.viewScenarioAnalysisOverview);
    await appMp.cleanupAndLogout();
  });
 
  afterEach(async () => {
    await appMp.checkToastMessage();
  });
 
  it(`Setup - ${AppMP.getDemoDataPath(Demo.Food, Scenario.Base)}`, async () => {
    await appMp.createDemoDataset(Demo.Food, Scenario.Base, false);
  });
 
  it(`Step 1 - Open view ${appMp.viewOptimizerStrategies.viewPath}`, async () => {
    await appMp.viewOptimizerStrategies.switchTo();
  });
 
  it(`Step 2 - ${StepList.selectRowAndClickMenu(ListStrategy.title, { Name: DataFoodStrategyName.Default }, ListStrategyContextMenuItem.Edit.Label)}`, async () => {
    const row = await listStrategy.getRow({ Name: DataFoodStrategyName.Default });
    [dlgStrategy] = await listStrategy.selectContextMenu(ListStrategyContextMenuItem.Edit, row);
  });
 
  it(`Step 3 - ${StepList.selectRowAndClickMenu(ListActiveGoals.name, { KPI: DataKPIName.Fulfillment }, ListActiveGoalsContextMenuItem.Deactivate.Label)}`, async () => {
    listActiveGoals = dlgStrategy.listActiveGoals;
    const row = await listActiveGoals.getRow({ KPI: DataKPIName.Fulfillment });
    await listActiveGoals.selectContextMenu(ListActiveGoalsContextMenuItem.Deactivate, row);
  });
 
  it(`Step 4 - ${StepDialog.verifyOKDisabled()}`, async () => {
    await dlgStrategy.verifyOKDisabled();
    // Disabled as there's empty level
  });
 
  it(`Step 5 - ${StepList.selectRowAndClickMenu(ListActiveGoals.name, { KPI: DataKPIName.SourcingCost }, ListActiveGoalsContextMenuItem.Edit.Label)}`, async () => {
    const row = await listActiveGoals.getRow({ KPI: DataKPIName.SourcingCost });
    [dlgEdit] = await listActiveGoals.selectContextMenu(ListActiveGoalsContextMenuItem.Edit, row);
  });
 
  it(`Step 6 - ${StepDialog.updateDialogValues(DialogGoal.title, { Level: '3' })}`, async () => {
    // Edit to the level of the deactivated goal in previous step. This will ensure no empty levels.
    await dlgEdit.updateDialogValues({ Level: '3' });
  });
 
  it(`Step 7 - ${StepDialog.clickOK()}`, async () => {
    await dlgEdit.clickOK();
  });
 
  it(`Step 8 - ${StepDialog.verifyOKEnabled()}`, async () => {
    // Enabled as there's no more empty level
    await dlgStrategy.verifyOKEnabled();
  });
 
  it(`Step 9 - ${StepDialog.clickCancel()}`, async () => {
    // Strategy is global to all food scenarios thus don't change the data else will effect subsequent tests
    await dlgStrategy.clickCancel();
  });
});