limj
2023-10-24 93652435728de839582440eefd5122c281181d35
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/**
 * @file        ADSO-9980
 * @description Create event with occurrences
 * @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 { DataEventCategoryName, DataEventTypeName } from '../../libmp/data/data.calendar';
import { StepList } from '../../libappsop/listsop';
import { GanttChartCommonEvent, ListCommonEvent, ListCommonEventColumn, ListCommonEventOccurrence, ListEventCategory, ListEventCategoryColumn, ListEventCategoryContextMenuItem, ListCommonEventOccurrenceColumn, PanelCommonEventsList } from '../../libmp/forms/commoncalendar';
import { StepGanttChart } from '../../libappsop/ganttchartsop';
import { startOfPlanningYear } from '../../libmp/data/data.period';
import { StepDialog } from '../../libappsop/dialogsop';
import { CalendarEventRepeat, DialogCalendarEvent, PanelCalendarEventFields, StepDialogCalendarEvent, StepPanelRecurrenceWeekly } from '../../libmp/dialogs/calendarevent';
import { ColorList } from '../../libappsop/colorsop';
 
describe('ADSO-9980 - Create event with occurrences', () => {
  const appMP = AppMP.getInstance();
  const listEventCategories = appMP.viewCalendar.formCommonCalendar.listEventCategory;
  const panelCommonEventsGanttChart = appMP.viewCalendar.formCommonCalendar.pnlCommonEventsGanttChart;
  const panelCommonEventsList = appMP.viewCalendar.formCommonCalendar.pnlCommonEventsList;
  const gcCommonEvents = panelCommonEventsGanttChart.gcCommonCalendarEvent;
  const listCommonEvents = panelCommonEventsList.listCommonEvent;
  const dlgCommonEvents = listCommonEvents.dlgCreateEdit;
  const listOccurrence = panelCommonEventsList.listCommonEventOccurrence;
 
  const eventName = 'Weekly Maintenance';
  const inputDialogEvents: PanelCalendarEventFields = {
    Name: eventName,
    Description: 'Machine unavailable due to maintenance.',
    Type: DataEventTypeName.Unavailable,
    ApplyToNewResources: 'true',
    StartDate: `03-Jan-${startOfPlanningYear}`,
    IsAllDay: 'true',
    // TODO: https://jira.delmia.dsone.3ds.com/browse/CTQC-4779. Work around for the bug where the year changes into a random value upon selecting "all day".
    EndDate: `04-Jan-${startOfPlanningYear}`,
  };
 
  const startDate1 = new Date(`03-Jan-${startOfPlanningYear}`);
  const endDate1 = new Date(`04-Jan-${startOfPlanningYear}`);
  const startDate2 = new Date(`10-Jan-${startOfPlanningYear}`);
  const endDate2 = new Date(`11-Jan-${startOfPlanningYear}`);
  const startDate3 = new Date(`17-Jan-${startOfPlanningYear}`);
  const endDate3 = new Date(`18-Jan-${startOfPlanningYear}`);
 
  const inputPanelReccurenceWeekly: PanelCalendarEventFields = {
    RecurWeeklyRepeatEvery: '1',
    RecurWeeklyEndBy: 'true',
    RecurWeeklyEndByDate: `17-Jan-${startOfPlanningYear}`,
  };
  const repeatOnDays: number[] = [startDate1.getDay()];
 
  const itemUnavailableListCategory: ListEventCategoryColumn = { Name: DataEventCategoryName.Unavailable };
 
  const rowListCommonCalendar: ListCommonEventColumn = { Name: eventName, NrOfOccurrences: '3' };
  const parentListCommonCalendar: ListCommonEventColumn[] = [{ Category: DataEventCategoryName.Unavailable }];
 
  const rowOccurrenceList1: ListCommonEventOccurrenceColumn = { Start: `3-Jan-${startOfPlanningYear}`, End: `4-Jan-${startOfPlanningYear}` };
  const rowOccurrenceList2: ListCommonEventOccurrenceColumn = { Start: `10-Jan-${startOfPlanningYear}`, End: `11-Jan-${startOfPlanningYear}` };
  const rowOccurrenceList3: ListCommonEventOccurrenceColumn = { Start: `17-Jan-${startOfPlanningYear}`, End: `18-Jan-${startOfPlanningYear}` };
 
  beforeAll(async () => {
    jasmine.addMatchers(qCustomMatcher);
    await appMP.login();
  });
 
  afterAll(async () => {
    await appMP.resetActiveView(appMP.viewCalendar);
    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.viewCalendar.viewPath}.`, async () => {
    await appMP.viewCalendar.switchTo();
  });
 
  it(`Step 3 - ${StepList.selectRowAndClickMenu(ListEventCategory.title, itemUnavailableListCategory, ListEventCategoryContextMenuItem.CreateEvent.Label)}`, async () => {
    const row = await listEventCategories.getRow(itemUnavailableListCategory);
    await listEventCategories.selectContextMenu(ListEventCategoryContextMenuItem.CreateEvent, row);
  });
 
  it(`Step 4 - ${StepDialog.updateDialogValues(DialogCalendarEvent.title, inputDialogEvents)}`, async () => {
    await dlgCommonEvents.updateDialogValues(inputDialogEvents);
  });
 
  it(`Step 5 - ${StepDialogCalendarEvent.setEventRepeat(CalendarEventRepeat.Weekly)}`, async () => {
    await dlgCommonEvents.setEventRepeat(CalendarEventRepeat.Weekly);
  });
 
  it(`Step 6 - ${StepDialogCalendarEvent.clickCustomizeRepetition()}`, async () => {
    await dlgCommonEvents.clickCustomizeRepetition();
  });
 
  it(`Step 7 - ${StepDialog.updateDialogValues(DialogCalendarEvent.title, inputPanelReccurenceWeekly)}`, async () => {
    await dlgCommonEvents.updateDialogValues(inputPanelReccurenceWeekly);
  });
 
  it(`Step 8 - ${StepPanelRecurrenceWeekly.setRepeatWeeklyOnDays(repeatOnDays)}`, async () => {
    await dlgCommonEvents.pnlRecurrenceWeekly.setRepeatWeeklyOnDays(repeatOnDays);
  });
 
  it(`Step 9 - ${StepDialog.clickOK()}`, async () => {
    await dlgCommonEvents.clickOK();
  });
 
  it(`Step 10 - ${StepGanttChart.ensureVisible(GanttChartCommonEvent.title, startDate1.toDateString())} ${StepGanttChart.verifyNodeExists(GanttChartCommonEvent.title, eventName, startDate1, endDate1, ColorList.gray().Color)}`, async () => {
    await gcCommonEvents.ensureVisible(startDate1);
    await gcCommonEvents.verifyNodeExists(eventName, startDate1, endDate1, ColorList.gray());
  });
 
  it(`Step 11 - ${StepGanttChart.ensureVisible(GanttChartCommonEvent.title, startDate2.toDateString())} ${StepGanttChart.verifyNodeExists(GanttChartCommonEvent.title, eventName, startDate2, endDate2, ColorList.gray().Color)}`, async () => {
    await gcCommonEvents.ensureVisible(startDate2);
    await gcCommonEvents.verifyNodeExists(eventName, startDate2, endDate2, ColorList.gray());
  });
 
  it(`Step 12 - ${StepGanttChart.ensureVisible(GanttChartCommonEvent.title, startDate3.toDateString())} ${StepGanttChart.verifyNodeExists(GanttChartCommonEvent.title, eventName, startDate3, endDate3, ColorList.gray().Color)}`, async () => {
    await gcCommonEvents.ensureVisible(startDate3);
    await gcCommonEvents.verifyNodeExists(eventName, startDate3, endDate3, ColorList.gray());
  });
 
  it(`Step 13 - ${StepDialog.clickTab(PanelCommonEventsList.title)}`, async () => {
    await panelCommonEventsList.clickTab();
  });
 
  it(`Step 14 - ${StepList.verifyRowExists(ListCommonEvent.title, rowListCommonCalendar, parentListCommonCalendar)}`, async () => {
    await listCommonEvents.verifyRowExists(rowListCommonCalendar, parentListCommonCalendar);
  });
 
  it(`Step 15 - ${StepList.selectRow(ListCommonEvent.title, rowListCommonCalendar)}`, async () => {
    await listCommonEvents.selectRow(rowListCommonCalendar);
  });
 
  it(`Step 16 - ${StepList.verifyRowExists(ListCommonEventOccurrence.title, rowOccurrenceList1)} ${StepList.verifyRowExists(ListCommonEventOccurrence.title, rowOccurrenceList2)} ${StepList.verifyRowExists(ListCommonEventOccurrence.title, rowOccurrenceList3)}`, async () => {
    await listOccurrence.verifyRowExists(rowOccurrenceList1);
    await listOccurrence.verifyRowExists(rowOccurrenceList2);
    await listOccurrence.verifyRowExists(rowOccurrenceList3);
  });
});