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-9806
 * @description Create shift pattern
 * @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 { MatrixEditorShiftPattern, MatrixEditorShiftPatternContextMenuItem } from '../../libmp/forms/form.shiftpattern';
import { btnOkTooltip, DialogShiftPattern, DialogShiftPatternFields } from '../../libmp/dialogs/dialog.shiftpattern';
import { StepMatrix } from '../../libappsop/matrixeditorsop';
import { StepDialog } from '../../libappsop/dialogsop';
import { friday, monday, saturday, sunday, thursday, tuesday, wednesday } from '../../libmp/data/data.period';
import { DataMetalBaseShiftPattern } from '../../libmp/data/data.shiftpattern';
import { StepActionBarPage } from '../../libappsop/actionbarpagesop';
 
describe('ADSO-9806 - Create shift pattern', () => {
  const appMP = AppMP.getInstance();
  const meShiftPattern = appMP.viewCapacitiesTime.formShiftPattern.meShiftPattern;
  let dlgShiftPattern: DialogShiftPattern;
  const abpData = appMP.abpData;
 
  const nameShiftPattern12x5 = DataMetalBaseShiftPattern.TwelveTimesFive;
  const input12x5: DialogShiftPatternFields = { Name: nameShiftPattern12x5 };
  const input8x5: DialogShiftPatternFields = { Name: DataMetalBaseShiftPattern.EightTimesFive };
  const expectedValue = '0:00:00';
 
  beforeAll(async () => {
    jasmine.addMatchers(qCustomMatcher);
    await appMP.login();
  });
 
  afterAll(async () => {
    await appMP.resetActiveView(appMP.viewCapacitiesTime);
    await appMP.cleanupAndLogout();
  });
 
  afterEach(async () => {
    await appMP.checkToastMessage();
  });
 
  it(`Step 1 - ${AppMP.getDemoDataPath(Demo.Metals, Scenario.Base)}`, async () => {
    await appMP.createDemoDataset(Demo.Metals, Scenario.Base, false);
  });
 
  it(`Step 2 - Open view ${appMP.viewCapacitiesTime.viewPath}.`, async () => {
    await appMP.viewCapacitiesTime.switchTo();
  });
 
  it(`Step 3 - ${StepMatrix.rightClickMatrixSelectContextmenu(MatrixEditorShiftPattern.title, MatrixEditorShiftPatternContextMenuItem.Create.Label)}`, async () => {
    dlgShiftPattern = await meShiftPattern.rightClickMatrixSelectContextmenu(MatrixEditorShiftPatternContextMenuItem.Create.Name);
  });
 
  it(`Step 4 - ${StepDialog.verifyOKDisabled('OK', btnOkTooltip.missingName())}`, async () => {
    await dlgShiftPattern.verifyOKDisabled(btnOkTooltip.missingName());
  });
 
  it(`Step 5 - ${StepDialog.updateDialogValues(DialogShiftPattern.title, input12x5)} ${StepDialog.clickOK()}`, async () => {
    await dlgShiftPattern.updateDialogValues(input12x5);
    await dlgShiftPattern.clickOK();
  });
 
  it(`Step 6 - ${StepMatrix.verifyCellValue(MatrixEditorShiftPattern.title, nameShiftPattern12x5, monday, expectedValue)} ${StepMatrix.verifyCellValue(MatrixEditorShiftPattern.title, nameShiftPattern12x5, tuesday, expectedValue)} ${StepMatrix.verifyCellValue(MatrixEditorShiftPattern.title, nameShiftPattern12x5, wednesday, expectedValue)} ${StepMatrix.verifyCellValue(MatrixEditorShiftPattern.title, nameShiftPattern12x5, thursday, expectedValue)} ${StepMatrix.verifyCellValue(MatrixEditorShiftPattern.title, nameShiftPattern12x5, friday, expectedValue)} ${StepMatrix.verifyCellValue(MatrixEditorShiftPattern.title, nameShiftPattern12x5, saturday, expectedValue)} ${StepMatrix.verifyCellValue(MatrixEditorShiftPattern.title, nameShiftPattern12x5, sunday, expectedValue)}`, async () => {
    await meShiftPattern.verifyCellValue(nameShiftPattern12x5, 0, monday, expectedValue);
    await meShiftPattern.verifyCellValue(nameShiftPattern12x5, 0, tuesday, expectedValue);
    await meShiftPattern.verifyCellValue(nameShiftPattern12x5, 0, wednesday, expectedValue);
    await meShiftPattern.verifyCellValue(nameShiftPattern12x5, 0, thursday, expectedValue);
    await meShiftPattern.verifyCellValue(nameShiftPattern12x5, 0, friday, expectedValue);
    await meShiftPattern.verifyCellValue(nameShiftPattern12x5, 0, saturday, expectedValue);
    await meShiftPattern.verifyCellValue(nameShiftPattern12x5, 0, sunday, expectedValue);
  });
 
  it(`Step 7 - ${StepActionBarPage.clickButton('Create')}`, async () => {
    await abpData.btnCreate.click();
  });
 
  it(`Step 8 - ${StepDialog.updateDialogValues(DialogShiftPattern.title, input12x5)} ${StepDialog.verifyOKDisabled('OK', btnOkTooltip.uniqueName(nameShiftPattern12x5))}`, async () => {
    await dlgShiftPattern.updateDialogValues(input12x5);
    await dlgShiftPattern.verifyOKDisabled(btnOkTooltip.uniqueName(nameShiftPattern12x5));
  });
 
  it(`Step 9 - ${StepDialog.updateDialogValues(DialogShiftPattern.title, input8x5)} ${StepDialog.verifyOKEnabled()} ${StepDialog.clickCancel()}`, async () => {
    await dlgShiftPattern.updateDialogValues(input8x5);
    await dlgShiftPattern.verifyOKEnabled();
    await dlgShiftPattern.clickCancel();
  });
});