From d042b80386b5f4236040982fbf75ec7a6099a0fc Mon Sep 17 00:00:00 2001 From: MichalKinas <113341662+MichalKinas@users.noreply.github.com> Date: Wed, 19 Apr 2023 15:37:55 +0200 Subject: [PATCH] [ACS-4425] Improved share file with expiration date test (#3133) --- e2e/protractor.excludes.json | 3 +- e2e/suites/actions/share/share-file.test.ts | 2 +- .../datetime-picker/datetime-picker.ts | 49 +++++++++++++++---- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/e2e/protractor.excludes.json b/e2e/protractor.excludes.json index 1d6d12645d..eb7e376ad1 100644 --- a/e2e/protractor.excludes.json +++ b/e2e/protractor.excludes.json @@ -1,6 +1,5 @@ { "C589205": "https://alfresco.atlassian.net/browse/ACA-4353", "C261153": "https://alfresco.atlassian.net/browse/AAE-7517", - "C306959": "https://alfresco.atlassian.net/browse/ACA-4620", - "C286332": "https://alfresco.atlassian.net/browse/ACS-4425" + "C306959": "https://alfresco.atlassian.net/browse/ACA-4620" } diff --git a/e2e/suites/actions/share/share-file.test.ts b/e2e/suites/actions/share/share-file.test.ts index 3d035cc38e..79324f5710 100755 --- a/e2e/suites/actions/share/share-file.test.ts +++ b/e2e/suites/actions/share/share-file.test.ts @@ -197,7 +197,7 @@ describe('Share a file', () => { await BrowserActions.click(shareDialog.datetimePickerButton); expect(await shareDialog.dateTimePicker.isCalendarOpen()).toBe(true, 'Calendar not opened'); - const date = await shareDialog.dateTimePicker.setDefaultDay(); + const date = await shareDialog.dateTimePicker.pickDateTime(); await shareDialog.dateTimePicker.waitForDateTimePickerToClose(); const setDate = `${date}`.replace(',', ''); diff --git a/projects/aca-testing-shared/src/components/datetime-picker/datetime-picker.ts b/projects/aca-testing-shared/src/components/datetime-picker/datetime-picker.ts index c565ef1719..339e5df5ac 100755 --- a/projects/aca-testing-shared/src/components/datetime-picker/datetime-picker.ts +++ b/projects/aca-testing-shared/src/components/datetime-picker/datetime-picker.ts @@ -25,14 +25,17 @@ import { by, browser } from 'protractor'; import { Component } from '../component'; import { isPresentAndDisplayed, waitForStaleness } from '../../utilities/utils'; -const moment = require('moment'); import { BrowserActions } from '@alfresco/adf-testing'; export class DateTimePicker extends Component { calendar = this.byCss('.mat-datetimepicker-popup', browser); + headerTime = this.byCss('.mat-datetimepicker-calendar-header-time'); headerDate = this.byCss('.mat-datetimepicker-calendar-header-date'); headerYear = this.byCss('.mat-datetimepicker-calendar-header-year'); dayPicker = this.byCss('mat-datetimepicker-month-view'); + hourPicker = this.byCss('.mat-datetimepicker-clock-hours'); + minutePicker = this.byCss('.mat-datetimepicker-clock-minutes'); + nextMonthBtn = this.byCss('.mat-datetimepicker-calendar-next-button'); rootElemLocator = by.css('.mat-datetimepicker-popup'); constructor(ancestor?: string) { @@ -49,15 +52,43 @@ export class DateTimePicker extends Component { return isPresentAndDisplayed(element); } - async setDefaultDay(): Promise { - const today = moment(); - const tomorrow = today.add(1, 'day'); - const dayOfTomorrow = tomorrow.date(); + async pickDateTime(): Promise { + const today = new Date() + const nextAvailableDay = new Date(); + nextAvailableDay.setDate(today.getDate() + 2); + if (nextAvailableDay.getMonth() !== today.getMonth()) { + await BrowserActions.click(this.nextMonthBtn); + } + await this.selectDay(nextAvailableDay.getDate()); + await this.selectHour(nextAvailableDay.getHours()); + + // getting data from header here since date picker will close after selecting minutes const date = await this.headerDate.getText(); const year = await this.headerYear.getText(); - const firstActiveDay = '.mat-datetimepicker-calendar-body-active .mat-datetimepicker-calendar-body-cell-content'; - const elem = this.dayPicker.element(by.cssContainingText(firstActiveDay, `${dayOfTomorrow}`)); - await BrowserActions.click(elem); - return `${date} ${year}`; + let time = await this.headerTime.getText(); + const parts = time.split(':'); + parts[1] = '00'; + time = parts.join(':'); + + await this.selectMinute(0); + return `${date} ${year} ${time}`; + } + + async selectDay(day: number): Promise { + const firstActiveDay = '.mat-datetimepicker-calendar-body-cell-content'; + const firstActiveDayElem = this.dayPicker.element(by.cssContainingText(firstActiveDay, `${day}`)); + await BrowserActions.click(firstActiveDayElem); + } + + async selectHour(hour: number): Promise { + const clockCellClass = '.mat-datetimepicker-clock-cell'; + const selectedHourElem = this.hourPicker.element(by.cssContainingText(clockCellClass, `${hour}`)); + await BrowserActions.click(selectedHourElem); + } + + async selectMinute(minute: number): Promise { + const clockCellClass = '.mat-datetimepicker-clock-cell'; + const selectedMinuteElem = this.minutePicker.element(by.cssContainingText(clockCellClass, `${minute}`)); + await BrowserActions.click(selectedMinuteElem); } }