mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACA-1920] automate tests for Create file from template (#1303)
* change component ancestor from ElementFinder to string for better usability better naming for some methods small code cleanup * add test components and automate tests for Create File from Template action * ignore e2e-downloads folder * add return types * enable check * enable check after issue got fixed
This commit is contained in:
committed by
Cilibiu Bogdan
parent
0bc4a3453b
commit
569ee98e8d
@@ -74,67 +74,89 @@ export class Menu extends Component {
|
||||
shareEditAction: ElementFinder = this.component.element(by.cssContainingText(Menu.selectors.item, 'Shared Link Settings'));
|
||||
uploadFileAction: ElementFinder = this.component.element(by.cssContainingText(Menu.selectors.item, 'Upload File'));
|
||||
uploadFolderAction: ElementFinder = this.component.element(by.cssContainingText(Menu.selectors.item, 'Upload Folder'));
|
||||
createFileFromTemplateAction: ElementFinder = this.component.element(by.cssContainingText(Menu.selectors.item, 'Create file from template'));
|
||||
viewAction: ElementFinder = this.component.element(by.cssContainingText(Menu.selectors.item, 'View'));
|
||||
viewDetailsAction: ElementFinder = this.component.element(by.cssContainingText(Menu.selectors.item, 'View Details'));
|
||||
|
||||
constructor(ancestor?: ElementFinder) {
|
||||
constructor(ancestor?: string) {
|
||||
super(Menu.selectors.root, ancestor);
|
||||
}
|
||||
|
||||
async waitForMenuToOpen() {
|
||||
async waitForMenuToOpen(): Promise<void> {
|
||||
await browser.wait(EC.presenceOf(browser.element(by.css('.cdk-overlay-container .mat-menu-panel'))), BROWSER_WAIT_TIMEOUT);
|
||||
await browser.wait(EC.visibilityOf(this.items.get(0)), BROWSER_WAIT_TIMEOUT);
|
||||
}
|
||||
|
||||
async waitForMenuToClose() {
|
||||
async waitForMenuToClose(): Promise<void> {
|
||||
await browser.wait(EC.not(EC.presenceOf(browser.element(by.css('.cdk-overlay-container .mat-menu-panel')))), BROWSER_WAIT_TIMEOUT);
|
||||
}
|
||||
|
||||
async closeMenu() {
|
||||
async closeMenu(): Promise<void> {
|
||||
await Utils.pressEscape();
|
||||
await this.waitForMenuToClose();
|
||||
}
|
||||
|
||||
getNthItem(nth: number) {
|
||||
getNthItem(nth: number): ElementFinder {
|
||||
return this.items.get(nth - 1);
|
||||
}
|
||||
|
||||
getItemByLabel(menuItem: string) {
|
||||
getItemByLabel(menuItem: string): ElementFinder {
|
||||
return this.component.element(by.cssContainingText(Menu.selectors.item, menuItem));
|
||||
}
|
||||
|
||||
getSubItemByLabel(subMenuItem: string) {
|
||||
getSubItemByLabel(subMenuItem: string): ElementFinder {
|
||||
return this.component.element(by.cssContainingText(Menu.selectors.submenu, subMenuItem));
|
||||
}
|
||||
|
||||
getItemById(id: string) {
|
||||
getItemById(id: string): ElementFinder {
|
||||
return this.component.element(by.id(id));
|
||||
}
|
||||
|
||||
async getItemTooltip(menuItem: string) {
|
||||
async getItemTooltip(menuItem: string): Promise<string> {
|
||||
return this.getItemByLabel(menuItem).getAttribute('title');
|
||||
}
|
||||
|
||||
async getItemIconText(menuItem: string) {
|
||||
async getTooltipForUploadFile(): Promise<string> {
|
||||
return this.getItemTooltip('Upload File');
|
||||
}
|
||||
|
||||
async getTooltipForUploadFolder(): Promise<string> {
|
||||
return this.getItemTooltip('Upload Folder');
|
||||
}
|
||||
|
||||
async getTooltipForCreateFolder(): Promise<string> {
|
||||
return this.getItemTooltip('Create Folder');
|
||||
}
|
||||
|
||||
async getTooltipForCreateLibrary(): Promise<string> {
|
||||
return this.getItemTooltip('Create Library');
|
||||
}
|
||||
|
||||
async getTooltipForCreateFileFromTemplate(): Promise<string> {
|
||||
return this.getItemTooltip('Create file from template');
|
||||
}
|
||||
|
||||
async getItemIconText(menuItem: string): Promise<string> {
|
||||
return this.getItemByLabel(menuItem).element(by.css(Menu.selectors.icon)).getText();
|
||||
}
|
||||
|
||||
async getItemIdAttribute(menuItem: string) {
|
||||
async getItemIdAttribute(menuItem: string): Promise<string> {
|
||||
return this.getItemByLabel(menuItem).getAttribute('id');
|
||||
}
|
||||
|
||||
async getItemsCount() {
|
||||
async getItemsCount(): Promise<number> {
|
||||
return this.items.count();
|
||||
}
|
||||
|
||||
async getMenuItems(): Promise<string[]> {
|
||||
return this.items.map(async (elem) => {
|
||||
const text = await elem.element(by.css('span')).getText();
|
||||
return text;
|
||||
const items: string[] = await this.items.map(async (elem) => {
|
||||
const span: ElementFinder = elem.element(by.css('span'));
|
||||
return span.getText();
|
||||
});
|
||||
return items;
|
||||
}
|
||||
|
||||
async clickNthItem(nth: number) {
|
||||
async clickNthItem(nth: number): Promise<void> {
|
||||
try {
|
||||
const elem = this.getNthItem(nth);
|
||||
await browser.wait(EC.elementToBeClickable(elem), BROWSER_WAIT_TIMEOUT, 'timeout waiting for menu item to be clickable');
|
||||
@@ -146,7 +168,7 @@ export class Menu extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
async clickMenuItem(menuItem: string) {
|
||||
async clickMenuItem(menuItem: string): Promise<void> {
|
||||
try {
|
||||
const elem = this.getItemByLabel(menuItem);
|
||||
await browser.wait(EC.elementToBeClickable(elem), BROWSER_WAIT_TIMEOUT, 'timeout waiting for menu item to be clickable');
|
||||
@@ -156,7 +178,7 @@ export class Menu extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
async mouseOverMenuItem(menuItem: string) {
|
||||
async mouseOverMenuItem(menuItem: string): Promise<void> {
|
||||
try {
|
||||
const elem = this.getItemByLabel(menuItem);
|
||||
await browser.wait(EC.elementToBeClickable(elem), BROWSER_WAIT_TIMEOUT);
|
||||
@@ -179,7 +201,7 @@ export class Menu extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
async clickSubMenuItem(subMenuItem: string) {
|
||||
async clickSubMenuItem(subMenuItem: string): Promise<void> {
|
||||
try {
|
||||
const elem = this.getSubItemByLabel(subMenuItem);
|
||||
await browser.wait(EC.elementToBeClickable(elem), BROWSER_WAIT_TIMEOUT);
|
||||
@@ -189,15 +211,15 @@ export class Menu extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
async isMenuItemPresent(title: string) {
|
||||
async isMenuItemPresent(title: string): Promise<boolean> {
|
||||
return browser.element(by.cssContainingText(Menu.selectors.item, title)).isPresent();
|
||||
}
|
||||
|
||||
async isSubMenuItemPresent(title: string) {
|
||||
async isSubMenuItemPresent(title: string): Promise<boolean> {
|
||||
return browser.element(by.cssContainingText(Menu.selectors.submenu, title)).isPresent();
|
||||
}
|
||||
|
||||
async getSubmenuItemsCount() {
|
||||
async getSubmenuItemsCount(): Promise<number> {
|
||||
return this.submenus.count();
|
||||
}
|
||||
|
||||
@@ -212,172 +234,158 @@ export class Menu extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
uploadFile() {
|
||||
uploadFile(): ElementFinder {
|
||||
return this.uploadFiles;
|
||||
}
|
||||
|
||||
async clickEditFolder() {
|
||||
async clickEditFolder(): Promise<void> {
|
||||
await this.editFolderAction.click();
|
||||
}
|
||||
|
||||
async clickShare() {
|
||||
async clickShare(): Promise<void> {
|
||||
const action = this.shareAction;
|
||||
await action.click();
|
||||
}
|
||||
|
||||
async clickSharedLinkSettings() {
|
||||
async clickSharedLinkSettings(): Promise<void> {
|
||||
const action = this.shareEditAction;
|
||||
await action.click();
|
||||
}
|
||||
|
||||
|
||||
async isViewPresent() {
|
||||
async isViewPresent(): Promise<boolean> {
|
||||
return this.viewAction.isPresent();
|
||||
}
|
||||
|
||||
async isDownloadPresent() {
|
||||
async isDownloadPresent(): Promise<boolean> {
|
||||
return this.downloadAction.isPresent();
|
||||
}
|
||||
|
||||
async isEditFolderPresent() {
|
||||
async isEditFolderPresent(): Promise<boolean> {
|
||||
return this.editFolderAction.isPresent();
|
||||
}
|
||||
|
||||
async isEditOfflinePresent() {
|
||||
async isEditOfflinePresent(): Promise<boolean> {
|
||||
return this.editOfflineAction.isPresent();
|
||||
}
|
||||
|
||||
async isCancelEditingPresent() {
|
||||
async isCancelEditingPresent(): Promise<boolean> {
|
||||
return this.cancelEditingAction.isPresent();
|
||||
}
|
||||
|
||||
async isCopyPresent() {
|
||||
async isCopyPresent(): Promise<boolean> {
|
||||
return this.copyAction.isPresent();
|
||||
}
|
||||
|
||||
async isMovePresent() {
|
||||
async isMovePresent(): Promise<boolean> {
|
||||
return this.moveAction.isPresent();
|
||||
}
|
||||
|
||||
async isDeletePresent() {
|
||||
async isDeletePresent(): Promise<boolean> {
|
||||
return this.deleteAction.isPresent();
|
||||
}
|
||||
|
||||
async isManagePermissionsPresent() {
|
||||
async isManagePermissionsPresent(): Promise<boolean> {
|
||||
return this.managePermissionsAction.isPresent();
|
||||
}
|
||||
|
||||
async isManageVersionsPresent() {
|
||||
async isManageVersionsPresent(): Promise<boolean> {
|
||||
return this.manageVersionsAction.isPresent();
|
||||
}
|
||||
|
||||
async isUploadNewVersionPresent() {
|
||||
async isUploadNewVersionPresent(): Promise<boolean> {
|
||||
return this.uploadNewVersionAction.isPresent();
|
||||
}
|
||||
|
||||
async isFavoritePresent() {
|
||||
async isFavoritePresent(): Promise<boolean> {
|
||||
return this.favoriteAction.isPresent();
|
||||
}
|
||||
|
||||
async isRemoveFavoritePresent() {
|
||||
async isRemoveFavoritePresent(): Promise<boolean> {
|
||||
return this.removeFavoriteAction.isPresent();
|
||||
}
|
||||
|
||||
async isToggleFavoritePresent() {
|
||||
async isToggleFavoritePresent(): Promise<boolean> {
|
||||
return this.toggleFavoriteAction.isPresent();
|
||||
}
|
||||
|
||||
async isToggleRemoveFavoritePresent() {
|
||||
async isToggleRemoveFavoritePresent(): Promise<boolean> {
|
||||
return this.toggleRemoveFavoriteAction.isPresent();
|
||||
}
|
||||
|
||||
async isJoinLibraryPresent() {
|
||||
async isJoinLibraryPresent(): Promise<boolean> {
|
||||
return this.joinAction.isPresent();
|
||||
}
|
||||
|
||||
async isCancelJoinPresent() {
|
||||
async isCancelJoinPresent(): Promise<boolean> {
|
||||
return this.cancelJoinAction.isPresent();
|
||||
}
|
||||
|
||||
async isLeaveLibraryPresent() {
|
||||
async isLeaveLibraryPresent(): Promise<boolean> {
|
||||
return this.leaveAction.isPresent();
|
||||
}
|
||||
|
||||
async isPermanentDeletePresent() {
|
||||
async isPermanentDeletePresent(): Promise<boolean> {
|
||||
return this.permanentDeleteAction.isPresent();
|
||||
}
|
||||
|
||||
async isRestorePresent() {
|
||||
async isRestorePresent(): Promise<boolean> {
|
||||
return this.restoreAction.isPresent();
|
||||
}
|
||||
|
||||
async isSharePresent() {
|
||||
async isSharePresent(): Promise<boolean> {
|
||||
return this.shareAction.isPresent();
|
||||
}
|
||||
|
||||
async isSharedLinkSettingsPresent() {
|
||||
async isSharedLinkSettingsPresent(): Promise<boolean> {
|
||||
return this.shareEditAction.isPresent();
|
||||
}
|
||||
|
||||
async isViewDetailsPresent() {
|
||||
async isViewDetailsPresent(): Promise<boolean> {
|
||||
return this.viewDetailsAction.isPresent();
|
||||
}
|
||||
|
||||
async isCreateFolderPresent() {
|
||||
return this.createFolderAction.isPresent();
|
||||
}
|
||||
async isCreateFolderEnabled() {
|
||||
return this.createFolderAction.isEnabled();
|
||||
async isCreateFolderEnabled(): Promise<boolean> {
|
||||
return (await this.createFolderAction.isPresent()) && (await this.createFolderAction.isEnabled());
|
||||
}
|
||||
|
||||
async isCreateLibraryPresent() {
|
||||
return this.createLibraryAction.isPresent();
|
||||
}
|
||||
async isCreateLibraryEnabled() {
|
||||
return this.createLibraryAction.isEnabled();
|
||||
async isCreateLibraryEnabled(): Promise<boolean> {
|
||||
return (await this.createLibraryAction.isPresent()) && (await this.createLibraryAction.isEnabled());
|
||||
}
|
||||
|
||||
async isUploadFilePresent() {
|
||||
return this.uploadFileAction.isPresent();
|
||||
}
|
||||
async isUploadFileEnabled() {
|
||||
return this.uploadFileAction.isEnabled();
|
||||
async isUploadFileEnabled(): Promise<boolean> {
|
||||
return (await this.uploadFileAction.isPresent()) && (await this.uploadFileAction.isEnabled());
|
||||
}
|
||||
|
||||
async isUploadFolderPresent() {
|
||||
return this.uploadFolderAction.isPresent();
|
||||
}
|
||||
async isUploadFolderEnabled() {
|
||||
return this.uploadFolderAction.isEnabled();
|
||||
async isUploadFolderEnabled(): Promise<boolean> {
|
||||
return (await this.uploadFolderAction.isPresent()) && (await this.uploadFolderAction.isEnabled());
|
||||
}
|
||||
|
||||
async isCancelEditingActionPresent(): Promise<boolean> {
|
||||
return this.cancelEditingAction.isPresent();
|
||||
async isCreateFileFromTemplateEnabled(): Promise<boolean> {
|
||||
return (await this.createFileFromTemplateAction.isPresent()) && (await this.createFileFromTemplateAction.isEnabled());
|
||||
}
|
||||
|
||||
async isEditOfflineActionPresent(): Promise<boolean> {
|
||||
return this.editOfflineAction.isPresent();
|
||||
}
|
||||
|
||||
|
||||
async clickCreateFolder() {
|
||||
async clickCreateFolder(): Promise<void> {
|
||||
const action = this.createFolderAction;
|
||||
await action.click();
|
||||
}
|
||||
|
||||
async clickCreateLibrary() {
|
||||
async clickCreateLibrary(): Promise<void> {
|
||||
const action = this.createLibraryAction;
|
||||
await action.click();
|
||||
}
|
||||
|
||||
async clickUploadFile() {
|
||||
async clickUploadFile(): Promise<void> {
|
||||
const action = this.uploadFileAction;
|
||||
await action.click();
|
||||
}
|
||||
|
||||
async clickUploadFolder() {
|
||||
async clickUploadFolder(): Promise<void> {
|
||||
const action = this.uploadFolderAction;
|
||||
await action.click();
|
||||
}
|
||||
|
||||
async clickCreateFileFromTemplate(): Promise<void> {
|
||||
const action = this.createFileFromTemplateAction;
|
||||
await action.click();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user