| /** | 
|  * @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); | 
|   }); | 
| }); |