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
/**
 * @file        ADSO-9499
 * @description Edit optimizer strategy - advanced setting
 * @author      Clarence (ccn7@3ds.com)
 * @copyright   Dassault Systèmes
 */
import { qCustomMatcher } from '../../e2elib/lib/src/main/qmatchers.const';
import { AppMP, Demo, Scenario } from '../../libmp/appmp';
import { StepDialog } from '../../libappsop/dialogsop';
import { StepList } from '../../libappsop/listsop';
import { DataFoodStrategyName } from '../../libmp/data/data.strategy';
import { btnOkTooltip, DialogStrategy, DialogStrategyFields } from '../../libmp/dialogs/dialog.strategy';
import { ListStrategy, ListStrategyColumn, ListStrategyContextMenuItem } from '../../libmp/forms/form.optimizerstrategies';
 
describe('ADSO-9499 - Edit optimizer strategy - advanced setting', () => {
  const appMP = AppMP.getInstance();
  const listStrategy = appMP.viewOptimizerStrategies.frmOptimizerStrategies.listStrategy;
  let dlgStrategy: DialogStrategy;
  const fullMatchTooltip = true;
  const editStrategyRow: ListStrategyColumn = {Name: DataFoodStrategyName.Default};
  const updateNumPeriodsAvgDemandInvalid: DialogStrategyFields = {NumPeriodsForAverageDemand: '0'};
  const updateNumPeriodsAvgDemandValid: DialogStrategyFields = {NumPeriodsForAverageDemand: '5'};
  const updateNumSmartPlanInvalid: DialogStrategyFields = {NumPeriodsForSmartPlan: '0'};
  const updateNumSmartPlanValid: DialogStrategyFields = {NumPeriodsForSmartPlan: '15'};
  const verifySlidingWindowDisabled: DialogStrategyFields = {NrOfPeriodsInWindow: 'false', NrOfPeriodsPerSlide: 'false'};
  const verifySlidingWindowEnabled: DialogStrategyFields = {UseSlidingWindow: 'true', NrOfPeriodsInWindow: 'true', NrOfPeriodsPerSlide: 'true'};
  const updateSlidingWindowValid: DialogStrategyFields = {NrOfPeriodsInWindow: '1', NrOfPeriodsPerSlide: '1'};
  const updateSlidingWindowValid2: DialogStrategyFields = {NrOfPeriodsInWindow: '2'};
  // Combine object values
  const verifyDlgValuesAfterEditTabSettings: DialogStrategyFields = {...updateNumPeriodsAvgDemandValid, ...updateNumSmartPlanValid};
  const verifyDlgValuesAfterEditTabAdvanced: DialogStrategyFields = {UseSlidingWindow: 'true', ...updateSlidingWindowValid, ...updateSlidingWindowValid2};
 
  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 - ${appMP.viewOptimizerStrategies.stepDescription}`, async () => {
    await appMP.viewOptimizerStrategies.switchTo();
  });
 
  it(`Step 2 - ${StepList.selectRowAndClickMenu(ListStrategy.title, editStrategyRow, ListStrategyContextMenuItem.Edit.Label)} ${StepDialog.clickTab('Settings')}`, async () => {
    [dlgStrategy] = await listStrategy.selectContextMenu(ListStrategyContextMenuItem.Edit, await listStrategy.getRow(editStrategyRow));
    await dlgStrategy.panelSettings.clickTab();
  });
 
  it(`Step 3 - ${StepDialog.updateDialogValues(DialogStrategy.title, updateNumPeriodsAvgDemandInvalid)} ${StepDialog.verifyOKDisabled(btnOkTooltip.numPeriodsForAverageDemand_Invalid('0'))}`, async () => {
    await dlgStrategy.updateDialogValues(updateNumPeriodsAvgDemandInvalid);
    await dlgStrategy.verifyOKDisabled(btnOkTooltip.numPeriodsForAverageDemand_Invalid('0'), fullMatchTooltip);
  });
 
  it(`Step 4 - ${StepDialog.updateDialogValues(DialogStrategy.title, updateNumPeriodsAvgDemandValid)} ${StepDialog.verifyOKEnabled()}`, async () => {
    await dlgStrategy.updateDialogValues(updateNumPeriodsAvgDemandValid);
    await dlgStrategy.verifyOKEnabled();
  });
 
  it(`Step 5 - ${StepDialog.updateDialogValues(DialogStrategy.title, updateNumSmartPlanInvalid)} ${StepDialog.verifyOKDisabled(btnOkTooltip.numPeriodsForSmartPlan_Invalid('0'))}`, async () => {
    await dlgStrategy.updateDialogValues(updateNumSmartPlanInvalid);
    await dlgStrategy.verifyOKDisabled(btnOkTooltip.numPeriodsForSmartPlan_Invalid('0'), fullMatchTooltip);
  });
 
  it(`Step 6 - ${StepDialog.updateDialogValues(DialogStrategy.title, updateNumSmartPlanValid)} ${StepDialog.verifyOKEnabled()}`, async () => {
    await dlgStrategy.updateDialogValues(updateNumSmartPlanValid);
    await dlgStrategy.verifyOKEnabled();
  });
 
  it(`Step 7 - ${StepDialog.clickTab('Advanced')} ${StepDialog.verifyDialogEnabled(DialogStrategy.title, verifySlidingWindowDisabled)}`, async () => {
    await dlgStrategy.panelAdvanced.clickTab();
    await dlgStrategy.verifyDialogEnabled(verifySlidingWindowDisabled);
  });
 
  it(`Step 8 - ${StepDialog.updateDialogValues(DialogStrategy.title, {UseSlidingWindow: 'true'})} ${StepDialog.verifyDialogEnabled(DialogStrategy.title, verifySlidingWindowEnabled)} ${StepDialog.verifyOKDisabled(btnOkTooltip.numPeriodsForSlidingWindow_Invalid('0'))}`, async () => {
    await dlgStrategy.updateDialogValues({UseSlidingWindow: 'true'});
    await dlgStrategy.verifyDialogEnabled(verifySlidingWindowEnabled);
    await dlgStrategy.verifyOKDisabled(btnOkTooltip.numPeriodsForSlidingWindow_Invalid('0'));
  });
 
  it(`Step 9 - ${StepDialog.updateDialogValues(DialogStrategy.title, updateSlidingWindowValid)} ${StepDialog.verifyOKEnabled()}`, async () => {
    await dlgStrategy.updateDialogValues(updateSlidingWindowValid);
    await dlgStrategy.verifyOKEnabled();
  });
 
  it(`Step 10 - ${StepDialog.updateDialogValues(DialogStrategy.title, updateSlidingWindowValid2)} ${StepDialog.clickOK()}`, async () => {
    await dlgStrategy.updateDialogValues(updateSlidingWindowValid2);
    await dlgStrategy.clickOK();
  });
 
  it(`Step 11 - ${StepList.selectRowAndClickMenu(ListStrategy.title, editStrategyRow, ListStrategyContextMenuItem.Edit.Label)}`, async () => {
    [dlgStrategy] = await listStrategy.selectContextMenu(ListStrategyContextMenuItem.Edit, await listStrategy.getRow(editStrategyRow));
  });
 
  it(`Step 12 - ${StepDialog.clickTab('Settings')} ${StepDialog.verifyDialogValues(DialogStrategy.title, verifyDlgValuesAfterEditTabSettings)}`, async () => {
    await dlgStrategy.panelSettings.clickTab();
    await dlgStrategy.verifyDialogValues(verifyDlgValuesAfterEditTabSettings);
  });
 
  it(`Step 13 - ${StepDialog.clickTab('Advanced')} ${StepDialog.verifyDialogValues(DialogStrategy.title, verifyDlgValuesAfterEditTabAdvanced)} ${StepDialog.clickCancel()}`, async () => {
    await dlgStrategy.panelAdvanced.clickTab();
    await dlgStrategy.verifyDialogValues(verifyDlgValuesAfterEditTabAdvanced);
    await dlgStrategy.clickCancel();
  });
});