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
117
118
119
120
/**
 * @file        ADSO-49544 - Activate/Deactive New campaign optimizer
 * @description Modify advanced setting in strategy - Campaign optimizer combinations
 * @author      Zan Sen (zansen.tai@3ds.com)
 * @copyright   Dassault Systèmes
 */
 
import { DataKPIName } from '../../libmp/data/data.kpi';
import { AppMP, Demo, Scenario } from '../../libmp/appmp';
import { DataMetalStrategyName } from '../../libmp/data/data.strategy';
import { qCustomMatcher } from '../../e2elib/lib/src/main/qmatchers.const';
import { ListStrategyContextMenuItem } from '../../libmp/forms/form.optimizerstrategies';
import { DialogStrategy, btnOkTooltip, campaignOptimizerTooltip } from '../../libmp/dialogs/dialog.strategy';
 
describe('ADSO-49544 - Activate/Deactive New campaign optimizer.', () => {
  // New dialog strategy instance to use active goal list name in steps
  let dlgStrategy = new DialogStrategy();
  const isFullMatch = true;
  const appMP = AppMP.getInstance();
  const viewOptimizerStrategies = appMP.viewOptimizerStrategies;
  const listStrategy = appMP.viewOptimizerStrategies.frmOptimizerStrategies.listStrategy;
 
  beforeAll(async () => {
    jasmine.addMatchers(qCustomMatcher);
    await appMP.login();
  });
 
  afterAll(async () => {
    // Collapse the right docked optimizer strategies
    await appMP.viewOptimizerStrategies.frmOptimizerStrategies.collapse();
    await appMP.cleanupAndLogout();
  });
 
  afterEach(async () => {
    await appMP.checkToastMessage();
  });
 
  it(`Setup- ${AppMP.getDemoDataPath(Demo.Metals, Scenario.Base)}`, async () => {
    await appMP.createDemoDataset(Demo.Metals, Scenario.Base, false);
  });
 
  it(`Step 1 - Click "${viewOptimizerStrategies.viewPath}" to open right docked form "${viewOptimizerStrategies.name}"`, async () => {
    await viewOptimizerStrategies.switchTo();
  });
 
  it(`Step 2 - Right click strategy "${DataMetalStrategyName.MaximizeEBITDA}" and select menu "${ListStrategyContextMenuItem.Edit.Label}".`, async () => {
    const selectedRow = await listStrategy.getRow({ Name: DataMetalStrategyName.MaximizeEBITDA });
    [dlgStrategy] = await listStrategy.selectContextMenu(ListStrategyContextMenuItem.Edit, selectedRow);
  });
 
  it(`Step 3 - In list "${dlgStrategy.listActiveGoals.name}", right click "${DataKPIName.Campaign}" and select menu "${ListStrategyContextMenuItem.Edit.Label}". Set Weight = 1 and click OK. Verify Weight updated to 1.`, async () => {
    await dlgStrategy.listActiveGoals.updateActiveGoalWeight(DataKPIName.Campaign, '1');
  });
 
  it('Step 4 - Click "Advanced" tab and verify "Enable campaign sequencing optimizer" toggle off and "Maximum number of elements in campaign combi" is disabled and equals 4.', async () => {
    await dlgStrategy.panelAdvanced.clickTab();
    await dlgStrategy.verifyDialogValues({ EnableCampaignOptimizer: 'false', MaxNrOfElementsInCampaignCombi: '4' });
    await dlgStrategy.verifyDialogEnabled({ MaxNrOfElementsInCampaignCombi: 'false' });
  });
 
  it(`Step 5 - Hover "Enable campaign sequencing optimizer" and verify tooltip = "${campaignOptimizerTooltip.checkBox_enableCampaignOptimizer}".`, async () => {
    await dlgStrategy.hoverElementVerifyTooltip({ EnableCampaignOptimizer: campaignOptimizerTooltip.checkBox_enableCampaignOptimizer });
  });
 
  it(`Step 6 - Hover "Maximum number of elements in campaign combi" and verify tooltip = "${campaignOptimizerTooltip.editField_maxNrOfElementsInCampaignCombi}".`, async () => {
    await dlgStrategy.hoverElementVerifyTooltip({ MaxNrOfElementsInCampaignCombi: campaignOptimizerTooltip.editField_maxNrOfElementsInCampaignCombi });
  });
 
  it('Step 7 - Toggle on "Enable campaign sequencing optimizer" and verify "Maximum number of elements in campaign combi" enabled and defaulted to 4.', async () => {
    await dlgStrategy.updateDialogValues({ EnableCampaignOptimizer: 'true' });
    await dlgStrategy.verifyDialogEnabled({ MaxNrOfElementsInCampaignCombi: 'true' });
    await dlgStrategy.verifyDialogValues({ MaxNrOfElementsInCampaignCombi: '4' });
  });
 
  it(`Step 8 - Set "Maximum number of elements in campaign combi" = -1 and verify OK disabled with precondition = "${btnOkTooltip.maxNrOfElementsInCampaignCombi_isNumberNegative('-1')}".`, async () => {
    await dlgStrategy.updateDialogValues({ MaxNrOfElementsInCampaignCombi: '-1' });
    await dlgStrategy.verifyOKDisabled(btnOkTooltip.maxNrOfElementsInCampaignCombi_isNumberNegative('-1'), isFullMatch);
  });
 
  it(`Step 9 - Set "Maximum number of elements in campaign combi" = 1.5 and verify OK disabled with precondition = "${btnOkTooltip.maxNrOfElementsInCampaignCombi_isInputInvalid()}".`, async () => {
    await dlgStrategy.updateDialogValues({ MaxNrOfElementsInCampaignCombi: '1.5' });
    await dlgStrategy.verifyOKDisabled(btnOkTooltip.maxNrOfElementsInCampaignCombi_isInputInvalid(), isFullMatch);
  });
 
  it('Step 10 - Set "Maximum number of elements in campaign combi" = 5 and verify OK enabled. Click OK to save.', async () => {
    await dlgStrategy.updateDialogValues({ MaxNrOfElementsInCampaignCombi: '5' });
    await dlgStrategy.verifyOKEnabled();
    await dlgStrategy.clickOK();
  });
 
  it('Step 11 - Edit the strategy again. In dialog, verify Campaign Weight = 1.', async () => {
    const selectedRow = await listStrategy.getRow({ Name: DataMetalStrategyName.MaximizeEBITDA });
    [dlgStrategy] = await listStrategy.selectContextMenu(ListStrategyContextMenuItem.Edit, selectedRow);
    const selectedActiveGoal = await dlgStrategy.listActiveGoals.getRow({ KPI: DataKPIName.Campaign });
    await dlgStrategy.listActiveGoals.verifyRowValues(selectedActiveGoal, { Weight: '1' });
  });
 
  it('Step 12 - Click "Advanced" tab. Verify "Enable campaign sequencing optimizer" toggle on and "Maximum number of elements in campaign combi" = 5.', async () => {
    await dlgStrategy.panelAdvanced.clickTab();
    await dlgStrategy.verifyDialogValues({ EnableCampaignOptimizer: 'true', MaxNrOfElementsInCampaignCombi: '5' });
  });
 
  it('Step 13 - Toggle off "Enable campaign sequencing optimizer" and verify "Maximum number of elements in campaign combi" is disabled. Click OK.', async () => {
    await dlgStrategy.updateDialogValues({ EnableCampaignOptimizer: 'false' });
    await dlgStrategy.verifyDialogEnabled({ MaxNrOfElementsInCampaignCombi: 'false' });
    await dlgStrategy.clickOK();
  });
 
  it(`Step 14 - Edit "${DataMetalStrategyName.MaximizeEBITDA}" again.`, async () => {
    const selectedRow = await listStrategy.getRow({ Name: DataMetalStrategyName.MaximizeEBITDA });
    [dlgStrategy] = await listStrategy.selectContextMenu(ListStrategyContextMenuItem.Edit, selectedRow);
  });
 
  it('Step 15 - Click "Advanced" tab. Verify "Enable campaign sequencing optimizer" is unchecked and "Maximum number of elements in campaign combi" = 4 has been disabled. Click Cancel.', async () => {
    await dlgStrategy.panelAdvanced.clickTab();
    await dlgStrategy.verifyDialogEnabled({ MaxNrOfElementsInCampaignCombi: 'false' });
    await dlgStrategy.verifyDialogValues({ EnableCampaignOptimizer: 'false', MaxNrOfElementsInCampaignCombi: '4' });
    await dlgStrategy.clickCancel();
  });
});