[ACA-4288] Fix API errors from logs (#2006)

* Add API login in afterAll - part 1

* viewer,infoDrawer,extensions - afterAll API login

* deleteActions - afterAll API login

* Improve before and after methods

* add Promise type to methods - part1

* remove unneeded done() method and add try-catch

* delete wrong import

* Login through API

* small change over log errors

* small improvement over the logs
This commit is contained in:
Iulia Burcă
2021-04-16 17:57:50 +03:00
committed by GitHub
parent 9427c0fc7d
commit d17744bfd9
49 changed files with 844 additions and 719 deletions

View File

@@ -228,7 +228,7 @@ export class DataTable extends Component {
await browser.actions().mouseMove(item).perform();
await browser.actions().doubleClick().perform();
} catch (error) {
Logger.error('--- catch: doubleClickOnRowByName : ', error);
Logger.error(`--- doubleClickOnRowByName catch : failed to double click on ${name} from location : ${location} : `, error);
}
}
@@ -252,7 +252,7 @@ export class DataTable extends Component {
const item = this.getRowFirstCell(name, location);
await item.click();
} catch (e) {
Logger.error('--- unselect item catch : ', e);
Logger.error(`--- unselect item catch : failed to unselect ${name} from location : ${location} : `, e);
}
}
}

View File

@@ -25,7 +25,7 @@
import { ElementFinder, by, browser, Locator } from 'protractor';
import { isPresentAndDisplayed, waitForPresence, waitForStaleness } from '../../utilities/utils';
import { BrowserVisibility } from '@alfresco/adf-testing';
import { BrowserVisibility, Logger } from '@alfresco/adf-testing';
export abstract class GenericDialog {
protected constructor(private rootCssSelector?: string) {}
@@ -53,7 +53,11 @@ export abstract class GenericDialog {
}
async waitForDialogToClose(): Promise<void> {
await waitForStaleness(this.content);
try {
await waitForStaleness(this.content);
} catch (error) {
Logger.error(`GenericDialog waitForDialogToClose : catch : ${error}`);
}
}
async isDialogOpen(): Promise<boolean> {

View File

@@ -128,7 +128,7 @@ export class Menu extends Component {
const elem = this.getItemByLabel(menuItem);
await BrowserActions.click(elem);
} catch (e) {
Logger.error('___click menu item catch___', e);
Logger.error(`___click menu item catch : failed to click on ${menuItem}___`, e);
}
}
@@ -139,7 +139,7 @@ export class Menu extends Component {
await browser.actions().mouseMove(elem).perform();
await browser.sleep(500);
} catch (error) {
Logger.error('----- mouse over error: ', error);
Logger.error(`----- mouse over error : failed to mouse over ${menuItem} : `, error);
}
}

View File

@@ -58,7 +58,7 @@ export class Sidenav extends Component {
await element(by.css('.mat-expansion-panel-body')).isPresent();
}
} catch (e) {
Logger.error('---- sidebar navigation catch expandMenu: ', e);
Logger.error(`---- sidebar navigation catch expandMenu: failed to expand ${name} menu : `, e);
}
}
@@ -144,7 +144,7 @@ export class Sidenav extends Component {
const link = this.getLinkLabel(name);
await BrowserActions.click(link);
} catch (error) {
Logger.error('---- sidebar navigation clickLink catch error: ', error);
Logger.error(`---- clickLink catch : sidebar navigation failed to click on - ${name} : `, error);
}
}

View File

@@ -27,7 +27,7 @@ import { LoginComponent } from '../components/components';
import { Page } from './page';
import { APP_ROUTES } from '../configs';
import { waitForPresence } from '../utilities/utils';
import { BrowserActions } from '@alfresco/adf-testing';
import { BrowserActions, Logger } from '@alfresco/adf-testing';
export class LoginPage extends Page {
login = new LoginComponent(this.appRoot);
@@ -47,13 +47,17 @@ export class LoginPage extends Page {
}
async loginWith(username: string, password?: string) {
const pass = password || username;
try {
const pass = password || username;
await this.load();
await this.load();
await this.login.enterCredentials(username, pass);
await BrowserActions.click(this.login.submitButton);
await this.waitForApp();
await this.login.enterCredentials(username, pass);
await BrowserActions.click(this.login.submitButton);
await this.waitForApp();
} catch (error) {
Logger.error(`----- loginWith catch : failed to login with user: ${username} : ${error}`);
}
}
async loginWithAdmin() {

View File

@@ -57,7 +57,7 @@ export abstract class Page {
return browser.get(path);
}
async waitForApp() {
async waitForApp(): Promise<void> {
await waitForPresence(this.layout);
}
@@ -67,15 +67,15 @@ export abstract class Page {
await BrowserVisibility.waitUntilElementIsPresent(browser.element(by.css('[class*="login-content"] input#username')));
}
async waitForDialog() {
async waitForDialog(): Promise<void> {
await BrowserVisibility.waitUntilElementIsVisible(this.dialogContainer);
}
async isDialogOpen() {
return browser.isElementPresent(this.dialogContainer);
async isDialogOpen(): Promise<boolean> {
return isPresentAndDisplayed(this.dialogContainer);
}
async closeOpenDialogs() {
async closeOpenDialogs(): Promise<void> {
while (await this.isDialogOpen()) {
await Utils.pressEscape();
}

View File

@@ -26,7 +26,7 @@
import { RepoApi } from '../repo-api';
import { Logger } from '@alfresco/adf-testing';
import { Utils } from '../../../../utilities/utils';
import { SharedlinksApi as AdfSharedlinksApi, SharedLinkEntry } from '@alfresco/js-api';
import { SharedlinksApi as AdfSharedlinksApi, SharedLinkEntry, SharedLinkPaging } from '@alfresco/js-api';
export class SharedLinksApi extends RepoApi {
sharedlinksApi = new AdfSharedlinksApi(this.alfrescoJsApi);
@@ -75,7 +75,7 @@ export class SharedLinksApi extends RepoApi {
}
}
async unshareFileById(fileId: string) {
async unshareFileById(fileId: string): Promise<any> {
try {
const sharedId = await this.getSharedIdOfNode(fileId);
return await this.sharedlinksApi.deleteSharedLink(sharedId);
@@ -84,7 +84,7 @@ export class SharedLinksApi extends RepoApi {
}
}
async getSharedLinks(maxItems: number = 250) {
async getSharedLinks(maxItems: number = 250): Promise<SharedLinkPaging | null> {
try {
await this.apiAuth();
const opts = {
@@ -111,7 +111,7 @@ export class SharedLinksApi extends RepoApi {
}
}
async waitForApi(data: { expect: number }) {
async waitForApi(data: { expect: number }): Promise<any> {
try {
const sharedFiles = async () => {
const totalItems = await this.getSharedLinksTotalItems();
@@ -129,7 +129,7 @@ export class SharedLinksApi extends RepoApi {
}
}
async waitForFilesToBeShared(filesIds: string[]) {
async waitForFilesToBeShared(filesIds: string[]): Promise<any> {
try {
const sharedFile = async () => {
const sharedFiles = (await this.getSharedLinks()).list.entries.map((link) => link.entry.nodeId);
@@ -143,12 +143,12 @@ export class SharedLinksApi extends RepoApi {
return await Utils.retryCall(sharedFile);
} catch (error) {
Logger.error(`SharedLinksApi waitForFilesToBeShared : catch : `);
Logger.error(`SharedLinksApi waitForFilesToBeShared : catch : ${error}`);
Logger.error(`\tWait timeout reached waiting for files to be shared`);
}
}
async waitForFilesToNotBeShared(filesIds: string[]) {
async waitForFilesToNotBeShared(filesIds: string[]): Promise<any> {
try {
const sharedFile = async () => {
const sharedFiles = (await this.getSharedLinks()).list.entries.map((link) => link.entry.nodeId);
@@ -166,7 +166,7 @@ export class SharedLinksApi extends RepoApi {
return await Utils.retryCall(sharedFile);
} catch (error) {
Logger.error(`SharedLinksApi waitForFilesToNotBeShared : catch : `);
Logger.error(`SharedLinksApi waitForFilesToNotBeShared : catch : ${error}`);
Logger.error(`\tWait timeout reached waiting for files to no longer be shared`);
}
}

View File

@@ -168,12 +168,16 @@ export class SitesApi extends RepoApi {
}
async deleteSites(siteIds: string[], permanent: boolean = true) {
if (siteIds && siteIds.length > 0) {
await this.apiAuth();
try {
if (siteIds && siteIds.length > 0) {
await this.apiAuth();
for (const siteId of siteIds) {
await this.sitesApi.deleteSite(siteId, { permanent });
for (const siteId of siteIds) {
await this.sitesApi.deleteSite(siteId, { permanent });
}
}
} catch (error) {
this.handleError(`SitesApi deleteSites : catch : `, error);
}
}
@@ -287,7 +291,7 @@ export class SitesApi extends RepoApi {
return await Utils.retryCall(site);
} catch (error) {
Logger.error(`SitesApi waitForSitesToBeCreated : catch : `);
Logger.error(`SitesApi waitForSitesToBeCreated : catch : ${error}`);
Logger.error(`\tWait timeout reached waiting for sites to be created`);
}
}

View File

@@ -142,7 +142,7 @@ export class Utils {
if (fileExists) {
fs.rename(oldFilePath, newFilePath, function (err: any) {
if (err) {
Logger.error('==== rename err: ', err);
Logger.error(`==== rename err : failed to rename file from ${oldName} to ${newName} : `, err);
}
});
}
@@ -159,7 +159,7 @@ export class Utils {
});
await zip.on('error', (err: any) => {
Logger.error('=== unzip err: ', err);
Logger.error(`=== unzip err : failed to unzip ${filename} - ${unzippedName} :`, err);
});
await zip.on('ready', async () => {