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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**
 * @file        ADSO-9511
 * @description Decrease weight optimizer strategy
 * @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 { DataKPIName } from '../../libmp/data/data.kpi';
import { DataFoodStrategyName } from '../../libmp/data/data.strategy';
 
describe('ADSO-9511 - Decrease weight optimizer strategy', () => {
  const appMP = AppMP.getInstance();
  const listStrategy = appMP.viewOptimizerStrategies.frmOptimizerStrategies.listStrategy;
  let dlgStrategy: DialogStrategy;
  let listActiveGoals: ListActiveGoals;
 
  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.PrioritizeFulfillment }, ListStrategyContextMenuItem.Edit.Label)}`, async () => {
    const row = await listStrategy.getRow({ Name: DataFoodStrategyName.PrioritizeFulfillment });
    [dlgStrategy] = await listStrategy.selectContextMenu(ListStrategyContextMenuItem.Edit, row);
  });
 
  it(`Step 3 - ${StepList.verifyRowExists(ListActiveGoals.name, { KPI: DataKPIName.Fulfillment, Weight: '5' })}`, async () => {
    listActiveGoals = dlgStrategy.listActiveGoals;
    await listActiveGoals.verifyRowExists({ KPI: DataKPIName.Fulfillment, Weight: '5' });
  });
 
  it(`Step 4 - ${StepList.selectRowAndClickMenu(ListActiveGoals.name, { KPI: DataKPIName.Fulfillment }, ListActiveGoalsContextMenuItem.DecreaseWeight.Label)}`, async () => {
    const row = await listActiveGoals.getRow({ KPI: DataKPIName.Fulfillment });
    await listActiveGoals.selectContextMenu(ListActiveGoalsContextMenuItem.DecreaseWeight, row);
  });
 
  it(`Step 5 - ${StepList.verifyRowExists(ListActiveGoals.name, { KPI: DataKPIName.Fulfillment, Weight: '4' })}`, async () => {
    await listActiveGoals.verifyRowExists({ KPI: DataKPIName.Fulfillment, Weight: '4' });
  });
 
  it(`Step 6 - ${StepList.selectRowAndClickMenu(ListActiveGoals.name, { KPI: DataKPIName.Fulfillment }, ListActiveGoalsContextMenuItem.DecreaseWeight.Label)}`, async () => {
    const row = await listActiveGoals.getRow({ KPI: DataKPIName.Fulfillment });
    await listActiveGoals.selectContextMenu(ListActiveGoalsContextMenuItem.DecreaseWeight, row);
  });
 
  it(`Step 7 - ${StepList.selectRowAndClickMenu(ListActiveGoals.name, { KPI: DataKPIName.Fulfillment }, ListActiveGoalsContextMenuItem.DecreaseWeight.Label)}`, async () => {
    const row = await listActiveGoals.getRow({ KPI: DataKPIName.Fulfillment });
    await listActiveGoals.selectContextMenu(ListActiveGoalsContextMenuItem.DecreaseWeight, row);
  });
 
  it(`Step 8 - ${StepList.selectRowAndClickMenu(ListActiveGoals.name, { KPI: DataKPIName.Fulfillment }, ListActiveGoalsContextMenuItem.DecreaseWeight.Label)}`, async () => {
    const row = await listActiveGoals.getRow({ KPI: DataKPIName.Fulfillment });
    await listActiveGoals.selectContextMenu(ListActiveGoalsContextMenuItem.DecreaseWeight, row);
  });
 
  it(`Step 9 - ${StepList.verifyRowExists(ListActiveGoals.name, { KPI: DataKPIName.Fulfillment, Weight: '1' })}`, async () => {
    await listActiveGoals.verifyRowExists({ KPI: DataKPIName.Fulfillment, Weight: '1' });
  });
 
  it(`Step 10 - ${StepList.verifyContextMenuDisabled(ListActiveGoals.name, ListActiveGoalsContextMenuItem.DecreaseWeight.Label)}`, async () => {
    const row = await listActiveGoals.getRow({ KPI: DataKPIName.Fulfillment });
    await listActiveGoals.verifyContextMenuDisabled(ListActiveGoalsContextMenuItem.DecreaseWeight, [row]);
  });
 
  it(`Step 11 - ${StepDialog.clickCancel()}`, async () => {
    // Strategy is global to all food scenarios thus don't change the data else will effect subsequent tests
    await dlgStrategy.clickCancel();
  });
});