/*! * @license * Copyright 2019 Alfresco Software, Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { $$, $ } from 'protractor'; import { BrowserVisibility, TogglePage, BrowserActions, DateTimePickerPage } from '@alfresco/adf-testing'; import * as moment from 'moment'; export class ShareDialogPage { togglePage = new TogglePage(); dateTimePickerPage = new DateTimePickerPage(); shareDialog = $('adf-share-dialog'); dialogTitle = $$('[data-automation-id="adf-share-dialog-title"]').first(); shareToggle = $('[data-automation-id="adf-share-toggle"] label'); expireToggle = $(`[data-automation-id="adf-expire-toggle"] label`); shareToggleChecked = $('mat-dialog-container mat-slide-toggle.mat-checked'); shareLink = $('[data-automation-id="adf-share-link"]'); closeButton = $('button[data-automation-id="adf-share-dialog-close"]'); copySharedLinkButton = $('.adf-input-action'); expirationDateInput = $('input[formcontrolname="time"]'); confirmationDialog = $('adf-confirm-dialog'); confirmationCancelButton = $('#adf-confirm-cancel'); confirmationRemoveButton = $('#adf-confirm-accept'); async checkDialogIsDisplayed(): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.dialogTitle); } async clickUnShareFile() { await this.togglePage.enableToggle(this.shareToggle); } async clickExpireToggle() { await this.togglePage.enableToggle(this.expireToggle); } async clickConfirmationDialogCancelButton(): Promise { await BrowserActions.click(this.confirmationCancelButton); } async clickConfirmationDialogRemoveButton(): Promise { await BrowserActions.click(this.confirmationRemoveButton); } async checkShareLinkIsDisplayed(): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.shareLink); } async getShareLink(): Promise { return BrowserActions.getInputValue(this.shareLink); } async clickCloseButton(): Promise { await BrowserActions.click(this.closeButton); } async clickShareLinkButton(): Promise { await BrowserActions.click(this.copySharedLinkButton); } async shareToggleButtonIsChecked(): Promise { await BrowserVisibility.waitUntilElementIsPresent(this.shareToggleChecked); } async dialogIsClosed(): Promise { await BrowserVisibility.waitUntilElementIsStale(this.shareDialog); } async clickDateTimePickerButton(): Promise { await this.dateTimePickerPage.clickDateTimePicker(); } async calendarTodayDayIsDisabled(): Promise { const tomorrow = moment().add(1, 'days').format('D'); if (tomorrow !== '1') { await this.dateTimePickerPage.checkCalendarTodayDayIsDisabled(); } } async setDefaultDay(): Promise { const tomorrow = moment().add(1, 'days').format('D'); await this.dateTimePickerPage.setDate(tomorrow); } async setDefaultHour(): Promise { await this.dateTimePickerPage.dateTime.setDefaultEnabledHour(); } async setDefaultMinutes() { await this.dateTimePickerPage.dateTime.setDefaultEnabledMinutes(); } async dateTimePickerDialogIsClosed(): Promise { await BrowserVisibility.waitUntilElementIsStale($('mat-datetimepicker-content')); } async getExpirationDate(): Promise { return BrowserActions.getInputValue(this.expirationDateInput); } async expirationDateInputHasValue(value): Promise { await BrowserVisibility.waitUntilElementHasValue(this.expirationDateInput, value); } async confirmationDialogIsDisplayed(): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.confirmationDialog); } }