Skip to content

Commit

Permalink
[ACS-4425] Improved share file with expiration date test (#3133)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalKinas authored Apr 19, 2023
1 parent d3e5661 commit d042b80
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
3 changes: 1 addition & 2 deletions e2e/protractor.excludes.json
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 1 addition & 1 deletion e2e/suites/actions/share/share-file.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(',', '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -49,15 +52,43 @@ export class DateTimePicker extends Component {
return isPresentAndDisplayed(element);
}

async setDefaultDay(): Promise<string> {
const today = moment();
const tomorrow = today.add(1, 'day');
const dayOfTomorrow = tomorrow.date();
async pickDateTime(): Promise<string> {
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<void> {
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<void> {
const clockCellClass = '.mat-datetimepicker-clock-cell';
const selectedHourElem = this.hourPicker.element(by.cssContainingText(clockCellClass, `${hour}`));
await BrowserActions.click(selectedHourElem);
}

async selectMinute(minute: number): Promise<void> {
const clockCellClass = '.mat-datetimepicker-clock-cell';
const selectedMinuteElem = this.minutePicker.element(by.cssContainingText(clockCellClass, `${minute}`));
await BrowserActions.click(selectedMinuteElem);
}
}

0 comments on commit d042b80

Please sign in to comment.