gmandakini 4376d357ac [ADF-3962] sso download directive automated (#4452)
* sso download directive automated

* temp changes

* temp changes

* moving of services under lib testing and ADF-3962 automated

* removed the browser sleep

* cspell and linting fixes.

* codacy improvements

* export public-api update

* remove circular dep

* remove circular dep

* fixes

* fix user info test

* fix datatable

* random commit

* move other string

* fix lint

* fix lint

* fix prolem type

* fix failing test

* fix tag test

* fix problems after rebase

* fix lint

* remove space

* remove visibility method duplicated
2019-03-27 09:57:26 +00:00

158 lines
6.2 KiB
TypeScript

/*!
* @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 { element, by } from 'protractor';
import { FormControllersPage } from '../material/formControllersPage';
import { BrowserVisibility } from '@alfresco/adf-testing';
export class ShareDialog {
formControllersPage = new FormControllersPage();
shareDialog = element(by.css('adf-share-dialog'));
dialogTitle = element(by.css('[data-automation-id="adf-share-dialog-title"]'));
shareToggle = element(by.css('[data-automation-id="adf-share-toggle"] label'));
shareToggleChecked = element(by.css('mat-dialog-container mat-slide-toggle.mat-checked'));
shareToggleUnchecked = element(by.css('mat-dialog-container mat-slide-toggle:not(.mat-checked)'));
shareToggleDisabled = element(by.css('mat-dialog-container mat-slide-toggle.mat-disabled'));
shareLink = element(by.css('[data-automation-id="adf-share-link"]'));
closeButton = element(by.css('button[data-automation-id="adf-share-dialog-close"]'));
snackBar = element(by.css('simple-snack-bar'));
copySharedLinkButton = element(by.css('.adf-input-action'));
timeDatePickerButton = element(by.css('mat-datetimepicker-toggle button'));
dayPicker = element(by.css('mat-datetimepicker-month-view'));
clockPicker = element(by.css('mat-datetimepicker-clock'));
hoursPicker = element(by.css('.mat-datetimepicker-clock-hours'));
minutePicker = element(by.css('.mat-datetimepicker-clock-minutes'));
expirationDateInput = element(by.css('input[formcontrolname="time"]'));
confirmationDialog = element(by.css('adf-confirm-dialog'));
confirmationCancelButton = element(by.id('adf-confirm-cancel'));
confirmationRemoveButton = element(by.id('adf-confirm-accept'));
checkDialogIsDisplayed() {
return BrowserVisibility.waitUntilElementIsVisible(this.dialogTitle);
}
clickUnShareFile() {
this.formControllersPage.enableToggle(this.shareToggle);
}
clickConfirmationDialogCancelButton() {
BrowserVisibility.waitUntilElementIsVisible(this.confirmationCancelButton);
this.confirmationCancelButton.click();
}
clickConfirmationDialogRemoveButton() {
BrowserVisibility.waitUntilElementIsVisible(this.confirmationRemoveButton);
this.confirmationRemoveButton.click();
}
checkShareLinkIsDisplayed() {
return BrowserVisibility.waitUntilElementIsVisible(this.shareLink);
}
getShareLink() {
BrowserVisibility.waitUntilElementIsVisible(this.shareLink);
return this.shareLink.getAttribute('value');
}
clickCloseButton() {
BrowserVisibility.waitUntilElementIsVisible(this.closeButton);
return this.closeButton.click();
}
clickShareLinkButton() {
BrowserVisibility.waitUntilElementIsVisible(this.copySharedLinkButton);
return this.copySharedLinkButton.click();
}
shareToggleButtonIsChecked() {
BrowserVisibility.waitUntilElementIsPresent(this.shareToggleChecked);
}
shareToggleButtonIsDisabled() {
BrowserVisibility.waitUntilElementIsPresent(this.shareToggleDisabled);
}
shareToggleButtonIsUnchecked() {
BrowserVisibility.waitUntilElementIsVisible(this.shareToggleUnchecked);
}
checkNotificationWithMessage(message) {
BrowserVisibility.waitUntilElementIsVisible(
element(by.cssContainingText('simple-snack-bar', message))
);
}
waitForNotificationToClose() {
BrowserVisibility.waitUntilElementIsStale(element(by.css('simple-snack-bar')));
}
dialogIsClosed() {
BrowserVisibility.waitUntilElementIsStale(this.shareDialog);
}
clickDateTimePickerButton() {
BrowserVisibility.waitUntilElementIsVisible(this.timeDatePickerButton);
this.timeDatePickerButton.click();
}
calendarTodayDayIsDisabled() {
const today: any = this.dayPicker.element(by.css('.mat-datetimepicker-calendar-body-today')).getText();
BrowserVisibility.waitUntilElementIsPresent(element(by.cssContainingText('.mat-datetimepicker-calendar-body-disabled', today)));
}
setDefaultDay() {
const selector = '.mat-datetimepicker-calendar-body-cell:not(.mat-datetimepicker-calendar-body-disabled)';
BrowserVisibility.waitUntilElementIsVisible(this.dayPicker);
const tomorrow = new Date(new Date().getTime() + 48 * 60 * 60 * 1000).getDate().toString();
this.dayPicker.element(by.cssContainingText(selector, tomorrow)).click();
}
setDefaultHour() {
const selector = '.mat-datetimepicker-clock-cell:not(.mat-datetimepicker-clock-cell-disabled)';
BrowserVisibility.waitUntilElementIsVisible(this.clockPicker);
BrowserVisibility.waitUntilElementIsVisible(this.hoursPicker);
this.hoursPicker.all(by.css(selector)).first().click();
}
setDefaultMinutes() {
const selector = '.mat-datetimepicker-clock-cell:not(.mat-datetimepicker-clock-cell-disabled)';
BrowserVisibility.waitUntilElementIsVisible(this.minutePicker);
this.minutePicker.all(by.css(selector)).first().click();
}
dateTimePickerDialogIsClosed() {
BrowserVisibility.waitUntilElementIsStale(element(by.css('mat-datetimepicker-content')));
}
getExpirationDate() {
return this.expirationDateInput.getAttribute('value');
}
expirationDateInputHasValue(value) {
BrowserVisibility.waitUntilElementHasValue(this.expirationDateInput, value);
}
confirmationDialogIsDisplayed() {
return BrowserVisibility.waitUntilElementIsVisible(this.confirmationDialog);
}
confirmationDialogIsNotDisplayed() {
return BrowserVisibility.waitUntilElementIsNotVisible(this.confirmationDialog);
}
}