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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/**
 * @file        ADSO-52907
 * @description Warning when adding process min qty to level greater than 1 in strategy
 * @author      Clarence (ccn7@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, DialogStrategyWarningImage, ListActiveGoals, ListActiveGoalsColumn, ListActiveGoalsContextMenuItem, ListInactiveGoals, StepDialogStrategy } 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';
import { ListRow } from '../../e2elib/lib/src/pageobjects/list/listrow.component';
 
describe('ADSO-52907 - Warning when adding process min qty to level greater than 1 in strategy', () => {
  const appMP = AppMP.getInstance();
  const listStrategy = appMP.viewOptimizerStrategies.frmOptimizerStrategies.listStrategy;
  let dlgStrategy: DialogStrategy;
  let listActiveGoals: ListActiveGoals;
  let listInactiveGoals: ListInactiveGoals;
  let rowActiveFulfillmentTarget: ListRow;
  const fieldsFulfillmentTargetDropOn: ListActiveGoalsColumn = {KPI: DataKPIName.FulfillmentTarget, Level: '2'};
  const fieldsProcessMinQtyLevel2: ListActiveGoalsColumn = { KPI: DataKPIName.ProcessMinQuantity, Level: '2' };
 
  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, 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 - ${StepDialogStrategy.verifyHasWarningImage(false)}`, async () => {
    await dlgStrategy.verifyHasWarningImage(false);
  });
 
  it(`Step 4 - ${StepList.verifyRowExists(ListActiveGoals.title, fieldsFulfillmentTargetDropOn)}`, async () => {
    listActiveGoals = dlgStrategy.listActiveGoals;
    listInactiveGoals = dlgStrategy.listInactiveGoals;
    rowActiveFulfillmentTarget = await listActiveGoals.getRow(fieldsFulfillmentTargetDropOn);
  });
 
  it(`Step 5 - ${StepList.dropRowsOnTargetRow(ListInactiveGoals.title, [{Goal: DataKPIName.ProcessMinQuantity}], fieldsFulfillmentTargetDropOn, ListActiveGoals.title)}`, async () => {
    const rowInactiveProcessMinQty = await listInactiveGoals.getRow({Goal: DataKPIName.ProcessMinQuantity});
    await dlgStrategy.listInactiveGoals.dropRowOnTargetRow(rowInactiveProcessMinQty, rowActiveFulfillmentTarget);
  });
 
  it(`Step 6 - ${StepList.verifyRowExists(ListActiveGoals.title, fieldsProcessMinQtyLevel2)}`, async () => {
    await listActiveGoals.verifyRowExists(fieldsProcessMinQtyLevel2);
  });
 
  it(`Step 7 - ${StepList.verifyRowHasOnDrawImage(ListActiveGoals.title, fieldsProcessMinQtyLevel2, DialogStrategyWarningImage.Warning)}`, async () => {
    const row = await listActiveGoals.getRow(fieldsProcessMinQtyLevel2);
    await listActiveGoals.verifyRowHasOnDrawImage(row, DialogStrategyWarningImage.Warning);
  });
 
  it(`Step 8 - ${StepDialogStrategy.verifyHasWarningImage(true, DialogStrategyWarningImage.Warning)}`, async () => {
    await dlgStrategy.verifyHasWarningImage(true, DialogStrategyWarningImage.Warning);
  });
 
  it(`Step 9 - ${StepDialog.clickOK()}`, async () => {
    await dlgStrategy.clickOK();
  });
 
  it(`Step 10 - ${StepList.verifyRowValues(ListStrategy.title, {Name: DataFoodStrategyName.Default}, {ImgIsValid: DialogStrategyWarningImage.Warning})}`, async () => {
    // Strategy saved with not ideal configuration, flag image icon WARNING
    const row = await listStrategy.getRow({Name: DataFoodStrategyName.Default});
    await listStrategy.verifyRowValues(row, {ImgIsValid: DialogStrategyWarningImage.Warning});
  });
 
  it(`Step 11 - ${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 12 - ${StepDialogStrategy.verifyHasWarningImage(true, DialogStrategyWarningImage.Warning)}`, async () => {
    // Verify editing the same strategy, the WARNING still present
    await dlgStrategy.verifyHasWarningImage(true, DialogStrategyWarningImage.Warning);
  });
 
  it(`Step 13 - ${StepList.selectRowAndClickMenu(ListActiveGoals.title, { KPI: DataKPIName.ProcessMinQuantity }, ListActiveGoalsContextMenuItem.DecreaseLevel.Label)}`, async () => {
    // Fix the not ideal configuration by decreasing Process min quantity goal to level 1
    const row = await listActiveGoals.getRow({ KPI: DataKPIName.ProcessMinQuantity });
    await listActiveGoals.selectContextMenu(ListActiveGoalsContextMenuItem.DecreaseLevel, row);
  });
 
  it(`Step 14 - ${StepDialogStrategy.verifyHasWarningImage(false)}`, async () => {
    // And verify no more warning image
    await dlgStrategy.verifyHasWarningImage(false);
  });
 
  it(`Step 15 - ${StepDialog.clickCancel()}`, async () => {
    await dlgStrategy.clickCancel();
  });
});