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
/**
 * @file        ADSO-10408
 * @description Restore smart plan settings to defaults
 * @author      Kong Ching Shien (ckg6@3ds.com)
 * @copyright   Dassault Systèmes
 */
import { qCustomMatcher } from '../../e2elib/lib/src/main/qmatchers.const';
import { AppMP, Demo, Scenario } from '../../libmp/appmp';
import { startOfPlanningYear } from '../../libmp/data/data.period';
import { DataFoodStrategyName } from '../../libmp/data/data.strategy';
import { MatrixEditorProductPlanning, MatrixEditorProductPlanningContextMenuItem } from '../../libmp/forms/form.productplanning';
import { StepMatrix } from '../../libappsop/matrixeditorsop';
import { StepDialog } from '../../libappsop/dialogsop';
import { DialogSmartPlan, DialogSmartPlanDirectionRadioButton, DialogSmartPlanFields } from '../../libmp/dialogs/dialog.smartplan';
 
describe('ADSO-10408 -  Restore smart plan settings to defaults', () => {
  const appMP = AppMP.getInstance();
  let dlgSmartPlan: DialogSmartPlan;
  const generalFields: DialogSmartPlanFields = {Strategy: DataFoodStrategyName.MaximizeEBITDA, OverrideLockedPlan: 'true'};
  const advancedFields: DialogSmartPlanFields = {SmartPlanDirection: DialogSmartPlanDirectionRadioButton.MiddleOut, LimitUnits: 'true'};
  const defaultGeneralFields: DialogSmartPlanFields = {Strategy: DataFoodStrategyName.Default, OverrideLockedPlan: 'false'};
  const defaultAdvancedFields: DialogSmartPlanFields = {SmartPlanDirection: DialogSmartPlanDirectionRadioButton.MiddleOut, LimitUnits: 'false' };
 
  beforeAll(async () => {
    jasmine.addMatchers(qCustomMatcher);
    await appMP.login();
  });
 
  afterAll(async () => {
    await appMP.resetActiveView(appMP.viewSupplyPlanning);
    await appMP.cleanupAndLogout();
  });
 
  afterEach(async () => {
    await appMP.checkToastMessage();
  });
 
  it(`Step 1 - ${AppMP.getDemoDataPath(Demo.Food, Scenario.Base)}`, async () => {
    await appMP.createDemoDataset(Demo.Food, Scenario.Base, false);
  });
 
  it(`Step 2 - Open view ${appMP.viewSupplyPlanning.viewPath}`, async () => {
    await appMP.viewSupplyPlanning.switchTo();
  });
 
  it(`Step 3 - ${StepMatrix.rightClickMatrixSelectContextmenu(MatrixEditorProductPlanning.title, MatrixEditorProductPlanningContextMenuItem.SmartPlan)} ${StepDialog.updateDialogValues(DialogSmartPlan.title, generalFields)}`, async () => {
    dlgSmartPlan = await appMP.viewSupplyPlanning.frmProductPlanning.meProductPlanning.startSettingSmartPlanDirection(0, `1-Jan-${startOfPlanningYear}`);
    await dlgSmartPlan.updateDialogValues(generalFields);
  });
 
  it(`Step 4 - ${StepDialog.clickTab('Advanced')} ${StepDialog.updateDialogValues(DialogSmartPlan.title, advancedFields)}`, async () => {
    await dlgSmartPlan.pnlAdvanced.clickTab();
    await dlgSmartPlan.updateDialogValues(advancedFields);
  });
 
  it(`Step 5 - ${StepDialog.clickButton(DialogSmartPlan.btnSavePreferences)} ${StepDialog.clickOK()}`, async () => {
    await dlgSmartPlan.btnSavePreferences.click();
    await dlgSmartPlan.clickOK();
  });
 
  it(`Step 6 - ${StepMatrix.rightClickMatrixSelectContextmenu(MatrixEditorProductPlanning.title, MatrixEditorProductPlanningContextMenuItem.SmartPlan)}`, async () => {
    dlgSmartPlan = await appMP.viewSupplyPlanning.frmProductPlanning.meProductPlanning.startSettingSmartPlanDirection(0, `1-Jan-${startOfPlanningYear}`);
  });
 
  it(`Step 7 - ${StepDialog.verifyButtonDisabled(DialogSmartPlan.btnSavePreferences)} ${StepDialog.verifyButtonEnabled(DialogSmartPlan.btnRestoreDafault)}`, async () => {
    await dlgSmartPlan.verifyButtonDisabled(dlgSmartPlan.btnSavePreferences);
    await dlgSmartPlan.verifyButtonEnabled(dlgSmartPlan.btnRestoreDefault);
  });
 
  it(`Step 8 - ${StepDialog.clickButton(DialogSmartPlan.btnRestoreDafault)} ${StepDialog.verifyButtonDisabled(DialogSmartPlan.btnSavePreferences)} ${StepDialog.verifyButtonDisabled(DialogSmartPlan.btnRestoreDafault)}`, async () => {
    await dlgSmartPlan.btnRestoreDefault.click();
    await dlgSmartPlan.verifyButtonDisabled(dlgSmartPlan.btnSavePreferences);
    await dlgSmartPlan.verifyButtonDisabled(dlgSmartPlan.btnRestoreDefault);
  });
 
  it(`Step 9 - ${StepDialog.verifyDialogValues(DialogSmartPlan.title, defaultGeneralFields)}`, async () => {
    await dlgSmartPlan.verifyDialogValues(defaultGeneralFields);
  });
 
  it(`Step 10 - ${StepDialog.clickTab('Advanced')} ${StepDialog.verifyDialogValues(DialogSmartPlan.title, defaultAdvancedFields)}`, async () => {
    await dlgSmartPlan.pnlAdvanced.clickTab();
    await dlgSmartPlan.verifyDialogValues(defaultAdvancedFields);
  });
 
  it(`Step 11 - ${StepDialog.clickCancel()}`, async () => {
    await dlgSmartPlan.clickCancel();
  });
});