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
/**
 * @file        ADSO-9979
 * @description Create one occurrence event
 * @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, ListEventCategory, ListEventCategoryColumn, ListCommonEventColumn, PanelCommonEventsList, ListEventCategoryContextMenuItem } from '../../libmp/forms/commoncalendar';
import { StepGanttChart } from '../../libappsop/ganttchartsop';
import { CalendarEventRepeat, DialogCalendarEvent, PanelCalendarEventFields, StepDialogCalendarEvent } from '../../libmp/dialogs/calendarevent';
import { startOfPlanningYear } from '../../libmp/data/data.period';
import { StepDialog } from '../../libappsop/dialogsop';
import { ColorList } from '../../libappsop/colorsop';
 
describe('ADSO-9979 - Create one occurrence event', () => {
  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 eventName = 'Event 1';
  const inputDialogEvents: PanelCalendarEventFields = {
    Name: eventName,
    Description: 'Event Description 1',
    Type: DataEventTypeName.Unavailable, // Don't update Category as we already right click on it in list to bring up dialog
    ApplyToNewResources: 'false',
    StartDate: `03-Jan-${startOfPlanningYear}`,
    IsAllDay: 'true',
  };
  const expectedEndDateDialogEvents: PanelCalendarEventFields = { EndDate: `04-Jan-${startOfPlanningYear}` };
 
  const rowListCommonCalendar: ListCommonEventColumn = { Name: eventName, NrOfOccurrences: '1' };
  const parentListCommonCalendar: ListCommonEventColumn[] = [{ Category: DataEventCategoryName.Unavailable }];
 
  const itemUnavailableListCategory: ListEventCategoryColumn = { Name: DataEventCategoryName.Unavailable };
 
  const startDate = new Date(`03-Jan-${startOfPlanningYear}`);
  const endDate = new Date(`04-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 - Bug CTQC-4779: End date becomes unreasonably large thus we need update it for now. ${StepDialog.updateDialogValues(DialogCalendarEvent.title, expectedEndDateDialogEvents)}`, async () => {
    // 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".
    // Once the bug solved, this whole step can be removed
    await dlgCommonEvents.updateDialogValues(expectedEndDateDialogEvents);
    await dlgCommonEvents.verifyDialogValues(expectedEndDateDialogEvents);
  });
 
  it(`Step 6 - ${StepDialogCalendarEvent.setEventRepeat(CalendarEventRepeat.Once)}`, async () => {
    await dlgCommonEvents.setEventRepeat(CalendarEventRepeat.Once);
  });
 
  it(`Step 7 - ${StepDialog.clickOK()}`, async () => {
    await dlgCommonEvents.clickOK();
  });
 
  it(`Step 8 - ${StepGanttChart.ensureVisible(GanttChartCommonEvent.title, startDate.toDateString())}`, async () => {
    await gcCommonEvents.ensureVisible(startDate);
  });
 
  it(`Step 9 - ${StepGanttChart.verifyNodeExists(GanttChartCommonEvent.title, eventName, startDate, endDate, ColorList.gray().Color)}`, async () => {
    await gcCommonEvents.verifyNodeExists(eventName, startDate, endDate, ColorList.gray());
  });
 
  it(`Step 10 - ${StepDialog.clickTab(PanelCommonEventsList.title)}`, async () => {
    await panelCommonEventsList.clickTab();
  });
 
  it(`Step 11 - ${StepList.verifyRowExists(ListCommonEvent.title, rowListCommonCalendar, parentListCommonCalendar)}`, async () => {
    await listCommonEvents.verifyRowExists(rowListCommonCalendar, parentListCommonCalendar);
  });
});