ACA Run the test against the remote env (#1669)

* Run the test against the remote env

* Use remote user

* exclude e2e and raise issue

* Exlude more

* small change to trigger travis

* add api method to get totalItems of various endpoints

* lint fix

* remove tests from excluded to see what fails

* - fix some issues with the screenshot plugin
- add methods to get total items for some endpoints
- fix some waitForApi calls to consider initial total items number
- sortByModified descending in order to find the item needed by the test when having items on multiple pages

* Try to fix screenshots

* a few more fixes

* Upload screenshots

* a few more fixes

* Delete e2e-output-${retry} at the end

* delete unused variable

* some changes

* lint

* try one more fix

* Try to fix retry

* a few more fixes

* Try to fix retry

* some more fixes

* Fix "on Recent Files" suite

* Move "on Search Results" at the beginning of the class in order to avoid waitForApi:catch

* Empty commit

* Empty commit

* Empty commit

* Run e2e with lite-server

* Exclude protractor report folder

* Remove useless config

* change browser size

* no message

* one more try

* Empty commit

* try to maximize

* fix upload Recent files tests

* revert maximizing the browser

* don't "Run e2e with lite-server"

* fix mark-favorite tests

* few more fixes

* fix viewer and share tests

* test the lite server with retry

* Verify suites with lite server

* some final fixes

* Try to use httpserver

* Print the file and use http server

* Use http-server to fix protractor retry

* more fixes

* forgot a space :|

* remove extra job not needed anymore
rename test data into more specific

* play with the screenshots

* try new run

* trigger one more run

* a few more little fixes

* Fix comments

* Remove comment

* Fix lint error

Co-authored-by: Adina Parpalita <Adina.Parpalita@ness.com>
Co-authored-by: Cristina Jalba <cristina.jalba@ness.com>
Co-authored-by: iuliaib <iulia.burca@ness.com>
This commit is contained in:
Maurizio Vitale
2020-09-18 12:01:55 +01:00
committed by GitHub
parent 88e94a4ec9
commit 9b0c31073a
53 changed files with 1270 additions and 787 deletions

View File

@@ -53,6 +53,8 @@ export class DataTable extends Component {
emptySearchText = this.byCss('.empty-search__text');
selectedRow = this.byCss('.adf-datatable-row.adf-is-selected');
columnModified = this.byCss('.adf-datatable-header [data-automation-id="auto_id_modifiedAt"]');
menu = new Menu();
constructor(ancestor?: string) {
@@ -85,6 +87,30 @@ export class DataTable extends Component {
return this.head.element(locator);
}
async sortBy(label: string, order: 'asc' | 'desc'): Promise<void> {
const sortColumn = await this.getSortedColumnHeaderText();
const sortOrder = await this.getSortingOrder();
if (sortColumn !== label) {
await this.getColumnHeaderByLabel(label).click();
if (sortOrder !== order) {
await this.getColumnHeaderByLabel(label).click();
}
}
}
async sortByModified(order: 'asc' | 'desc'): Promise<void> {
const sortOrder = await this.getSortingOrder();
const sortColumn = await this.getSortedColumnHeaderText();
if (sortColumn !== 'Modified') {
await this.columnModified.click();
if (sortOrder !== order) {
await this.columnModified.click();
}
}
}
private getSortedColumnHeader(): ElementFinder {
const locator = by.css(DataTable.selectors.sortedColumnHeader);
return this.head.element(locator);
@@ -202,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('--- catch: doubleClickOnRowByName : ', error);
}
}
@@ -213,7 +239,7 @@ export class DataTable extends Component {
const item = this.getRowFirstCell(name, location);
await item.click();
} catch (e) {
Logger.error('--- select item catch : ', e);
Logger.error(`--- select item catch : failed to select ${name} from location : ${location} : `, e);
}
}
}

View File

@@ -26,7 +26,7 @@
import { browser, by, ElementFinder } from 'protractor';
import { Logger } from '@alfresco/adf-testing';
import { USE_HASH_STRATEGY } from './../configs';
import { Utils, waitElement, waitForPresence, waitForVisibility } from '../utilities/utils';
import { Utils, waitElement, waitForPresence, waitForVisibility, isPresentAndDisplayed } from '../utilities/utils';
export abstract class Page {
appRoot = 'app-root';
@@ -41,6 +41,9 @@ export abstract class Page {
genericErrorIcon = this.byCss('aca-generic-error .mat-icon');
genericErrorTitle = this.byCss('.generic-error__title');
uploadDialog = this.byCss('.adf-upload-dialog');
closeUploadButton = this.byCss('.adf-upload-dialog [id="adf-upload-dialog-close"]');
constructor(public url: string = '') {}
protected byCss(css: string): ElementFinder {
@@ -71,6 +74,16 @@ export abstract class Page {
}
}
async isUploadDialogOpen(): Promise<boolean> {
return isPresentAndDisplayed(this.uploadDialog);
}
async closeUploadDialog(): Promise<void> {
if (await this.isUploadDialogOpen()) {
await this.closeUploadButton.click();
}
}
async refresh(): Promise<void> {
await browser.refresh();
await this.waitForApp();

View File

@@ -49,7 +49,7 @@ export class FavoritesApi extends RepoApi {
};
return await this.favoritesApi.createFavorite('-me-', data);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.addFavorite.name}`, error);
this.handleError(`FavoritesApi addFavorite : catch : `, error);
return null;
}
}
@@ -72,7 +72,7 @@ export class FavoritesApi extends RepoApi {
};
return await this.favoritesApi.createFavorite('-me-', data);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.addFavoriteById.name}`, error);
this.handleError(`FavoritesApi addFavoriteById : catch : `, error);
return null;
}
}
@@ -84,7 +84,7 @@ export class FavoritesApi extends RepoApi {
await this.addFavoriteById(nodeType, current);
}, Promise.resolve());
} catch (error) {
this.handleError(`${this.constructor.name} ${this.addFavoritesByIds.name}`, error);
this.handleError(`FavoritesApi addFavoritesByIds : catch : `, error);
}
}
@@ -93,17 +93,27 @@ export class FavoritesApi extends RepoApi {
await this.apiAuth();
return await this.favoritesApi.listFavorites(this.getUsername());
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getFavorites.name}`, error);
this.handleError(`FavoritesApi getFavorites : catch : `, error);
return null;
}
}
async getFavoritesTotalItems(): Promise<number> {
try {
await this.apiAuth();
return (await this.favoritesApi.listFavorites(this.getUsername())).list.pagination.totalItems;
} catch (error) {
this.handleError(`FavoritesApi getFavoritesTotalItems : catch : `, error);
return -1;
}
}
async getFavoriteById(nodeId: string) {
try {
await this.apiAuth();
return await this.favoritesApi.getFavorite('-me-', nodeId);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getFavoriteById.name}`, error);
this.handleError(`FavoritesApi getFavoriteById : catch : `, error);
return null;
}
}
@@ -112,7 +122,7 @@ export class FavoritesApi extends RepoApi {
try {
return JSON.stringify((await this.getFavorites()).list.entries).includes(nodeId);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.isFavorite.name}`, error);
this.handleError(`FavoritesApi isFavorite : catch : `, error);
return null;
}
}
@@ -129,9 +139,7 @@ export class FavoritesApi extends RepoApi {
}
};
return await Utils.retryCall(favorite);
} catch (error) {
// this.handleError(`${this.constructor.name} ${this.isFavoriteWithRetry.name}`, error);
}
} catch (error) {}
return isFavorite;
}
@@ -140,7 +148,7 @@ export class FavoritesApi extends RepoApi {
await this.apiAuth();
return await this.favoritesApi.deleteFavorite('-me-', nodeId);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.removeFavoriteById.name}`, error);
this.handleError(`FavoritesApi removeFavoriteById : catch : `, error);
}
}
@@ -151,14 +159,14 @@ export class FavoritesApi extends RepoApi {
await this.removeFavoriteById(current);
}, Promise.resolve());
} catch (error) {
this.handleError(`${this.constructor.name} ${this.removeFavoritesByIds.name}`, error);
this.handleError(`FavoritesApi removeFavoritesByIds : catch : `, error);
}
}
async waitForApi(data: { expect: number }) {
try {
const favoriteFiles = async () => {
const totalItems = (await this.getFavorites()).list.pagination.totalItems;
const totalItems = await this.getFavoritesTotalItems();
if (totalItems !== data.expect) {
return Promise.reject(totalItems);
} else {
@@ -167,7 +175,7 @@ export class FavoritesApi extends RepoApi {
};
return await Utils.retryCall(favoriteFiles);
} catch (error) {
Logger.error(`${this.constructor.name} ${this.waitForApi.name} catch: `);
Logger.error(`FavoritesApi waitForApi : catch : `);
Logger.error(`\tExpected: ${data.expect} items, but found ${error}`);
}
}

View File

@@ -45,11 +45,20 @@ export class QueriesApi extends RepoApi {
await this.apiAuth();
return this.queriesApi.findSites(searchTerm, data);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.findSites.name}`, error);
this.handleError(`QueriesApi findSites : catch : `, error);
return null;
}
}
async findSitesTotalItems(searchTerm: string): Promise<number> {
try {
return (await this.findSites(searchTerm)).list.pagination.totalItems;
} catch (error) {
this.handleError(`QueriesApi findSitesTotalItems : catch :`, error);
return -1;
}
}
async findNodes(searchTerm: string) {
const data = {
term: searchTerm,
@@ -60,7 +69,7 @@ export class QueriesApi extends RepoApi {
await this.apiAuth();
return this.queriesApi.findNodes(searchTerm, data);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.findNodes.name}`, error);
this.handleError(`QueriesApi findNodes : catch : `, error);
return null;
}
}
@@ -68,7 +77,7 @@ export class QueriesApi extends RepoApi {
async waitForSites(searchTerm: string, data: { expect: number }) {
try {
const sites = async () => {
const totalItems = (await this.findSites(searchTerm)).list.pagination.totalItems;
const totalItems = await this.findSitesTotalItems(searchTerm);
if (totalItems !== data.expect) {
return Promise.reject(totalItems);
} else {
@@ -78,7 +87,7 @@ export class QueriesApi extends RepoApi {
return await Utils.retryCall(sites);
} catch (error) {
Logger.error(`${this.constructor.name} ${this.waitForSites.name} catch: `);
Logger.error(`QueriesApi waitForSites : catch : `);
Logger.error(`\tExpected: ${data.expect} items, but found ${error}`);
}
}
@@ -96,7 +105,7 @@ export class QueriesApi extends RepoApi {
return await Utils.retryCall(nodes);
} catch (error) {
Logger.error(`${this.constructor.name} ${this.waitForFilesAndFolders.name} catch: `);
Logger.error(`QueriesApi waitForFilesAndFolders : catch : `);
Logger.error(`\tExpected: ${data.expect} items, but found ${error}`);
}
}

View File

@@ -52,11 +52,20 @@ export class SearchApi extends RepoApi {
await this.apiAuth();
return this.searchApi.search(data);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.queryRecentFiles.name}`, error);
this.handleError(`SearchApi queryRecentFiles : catch : `, error);
return null;
}
}
async getTotalItems(username: string): Promise<number> {
try {
return (await this.queryRecentFiles(username)).list.pagination.totalItems;
} catch (error) {
this.handleError(`SearchApi getTotalItems : catch : `, error);
return -1;
}
}
async queryNodesNames(searchTerm: string) {
const data = {
query: {
@@ -70,11 +79,20 @@ export class SearchApi extends RepoApi {
await this.apiAuth();
return this.searchApi.search(data);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.queryNodesNames.name}`, error);
this.handleError(`SearchApi queryNodesNames : catch : `, error);
return null;
}
}
async getSearchByTermTotalItems(searchTerm: string): Promise<number> {
try {
return (await this.queryNodesNames(searchTerm)).list.pagination.totalItems;
} catch (error) {
this.handleError(`SearchApi getSearchByTermTotalItems : catch : `, error);
return -1;
}
}
async queryNodesExactNames(searchTerm: string) {
const data = {
query: {
@@ -88,7 +106,7 @@ export class SearchApi extends RepoApi {
await this.apiAuth();
return this.searchApi.search(data);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.queryNodesExactNames.name}`, error);
this.handleError(`SearchApi queryNodesExactNames : catch : `, error);
return null;
}
}
@@ -96,7 +114,7 @@ export class SearchApi extends RepoApi {
async waitForApi(username: string, data: { expect: number }) {
try {
const recentFiles = async () => {
const totalItems = (await this.queryRecentFiles(username)).list.pagination.totalItems;
const totalItems = await this.getTotalItems(username);
if (totalItems !== data.expect) {
return Promise.reject(totalItems);
} else {
@@ -106,7 +124,7 @@ export class SearchApi extends RepoApi {
return await Utils.retryCall(recentFiles);
} catch (error) {
Logger.error(`${this.constructor.name} ${this.waitForApi.name} catch: `);
Logger.error(`SearchApi waitForApi : catch : `);
Logger.error(`\tExpected: ${data.expect} items, but found ${error}`);
}
}
@@ -114,7 +132,7 @@ export class SearchApi extends RepoApi {
async waitForNodes(searchTerm: string, data: { expect: number }) {
try {
const nodes = async () => {
const totalItems = (await this.queryNodesNames(searchTerm)).list.pagination.totalItems;
const totalItems = await this.getSearchByTermTotalItems(searchTerm);
if (totalItems !== data.expect) {
return Promise.reject(totalItems);
} else {
@@ -124,7 +142,7 @@ export class SearchApi extends RepoApi {
return await Utils.retryCall(nodes);
} catch (error) {
Logger.error(`${this.constructor.name} ${this.waitForNodes.name} catch: `);
Logger.error(`SearchApi waitForNodes : catch : `);
Logger.error(`\tExpected: ${data.expect} items, but found ${error}`);
}
}

View File

@@ -44,7 +44,7 @@ export class SharedLinksApi extends RepoApi {
};
return await this.sharedlinksApi.createSharedLink(data);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.shareFileById.name}`, error);
this.handleError(`SharedLinksApi shareFileById : catch : `, error);
return null;
}
}
@@ -56,17 +56,17 @@ export class SharedLinksApi extends RepoApi {
return this.shareFileById(current);
}, Promise.resolve());
} catch (error) {
this.handleError(`${this.constructor.name} ${this.shareFilesByIds.name}`, error);
this.handleError(`SharedLinksApi shareFilesByIds : catch : `, error);
}
}
async getSharedIdOfNode(name: string) {
async getSharedIdOfNode(name: string): Promise<string> {
try {
const sharedLinks = (await this.getSharedLinks()).list.entries;
const found = sharedLinks.find((sharedLink) => sharedLink.entry.name === name);
const sharedLinksEntries = (await this.getSharedLinks())?.list.entries;
const found = sharedLinksEntries.find((sharedLink) => sharedLink.entry.name === name);
return (found || { entry: { id: null } }).entry.id;
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getSharedIdOfNode.name}`, error);
this.handleError(`SharedLinksApi getSharedIdOfNode : catch : `, error);
return null;
}
}
@@ -76,24 +76,41 @@ export class SharedLinksApi extends RepoApi {
const id = await this.getSharedIdOfNode(name);
return await this.sharedlinksApi.deleteSharedLink(id);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.unshareFile.name}`, error);
this.handleError(`SharedLinksApi unshareFile : catch : `, error);
}
}
async getSharedLinks() {
try {
await this.apiAuth();
return await this.sharedlinksApi.listSharedLinks();
const opts = {
maxItems: 250
};
return await this.sharedlinksApi.listSharedLinks(opts);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getSharedLinks.name}`, error);
this.handleError(`SharedLinksApi getSharedLinks : catch : `, error);
return null;
}
}
async getSharedLinksTotalItems(): Promise<number> {
try {
await this.apiAuth();
const opts = {
maxItems: 250
};
const sharedList = await this.sharedlinksApi.listSharedLinks(opts);
return sharedList.list.entries.length;
} catch (error) {
this.handleError(`SharedLinksApi getSharedLinksTotalItems : catch : `, error);
return -1;
}
}
async waitForApi(data: { expect: number }) {
try {
const sharedFiles = async () => {
const totalItems = (await this.getSharedLinks()).list.pagination.totalItems;
const totalItems = await this.getSharedLinksTotalItems();
if (totalItems !== data.expect) {
return Promise.reject(totalItems);
} else {
@@ -103,7 +120,7 @@ export class SharedLinksApi extends RepoApi {
return await Utils.retryCall(sharedFiles);
} catch (error) {
Logger.error(`${this.constructor.name} ${this.waitForApi.name} catch: `);
Logger.error(`SharedLinksApi waitForApi : catch : `);
Logger.error(`\tExpected: ${data.expect} items, but found ${error}`);
}
}

View File

@@ -49,7 +49,7 @@ export class SitesApi extends RepoApi {
await this.apiAuth();
return await this.sitesApi.getSite(siteId);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getSite.name}`, error);
this.handleError(`SitesApi getSite : catch : `, error);
return null;
}
}
@@ -59,17 +59,27 @@ export class SitesApi extends RepoApi {
await this.apiAuth();
return await this.sitesApi.listSiteMembershipsForPerson(this.getUsername());
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getSites.name}`, error);
this.handleError(`SitesApi getSites : catch : `, error);
return null;
}
}
async getDocLibId(siteId: string) {
async getSitesTotalItems(): Promise<number> {
try {
await this.apiAuth();
return (await this.sitesApi.listSiteMembershipsForPerson(this.getUsername())).list.pagination.totalItems;
} catch (error) {
this.handleError(`SitesApi getSitesTotalItems : catch : `, error);
return -1;
}
}
async getDocLibId(siteId: string): Promise<string> {
try {
await this.apiAuth();
return (await this.sitesApi.listSiteContainers(siteId)).list.entries[0].entry.id;
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getDocLibId.name}`, error);
this.handleError(`SitesApi getDocLibId : catch : `, error);
return null;
}
}
@@ -79,7 +89,7 @@ export class SitesApi extends RepoApi {
const site = await this.getSite(siteId);
return site.entry.visibility;
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getVisibility.name}`, error);
this.handleError(`SitesApi getVisibility : catch : `, error);
return null;
}
}
@@ -89,7 +99,7 @@ export class SitesApi extends RepoApi {
const site = await this.getSite(siteId);
return site.entry.description;
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getDescription.name}`, error);
this.handleError(`SitesApi getDescription : catch : `, error);
return null;
}
}
@@ -99,7 +109,7 @@ export class SitesApi extends RepoApi {
const site = await this.getSite(siteId);
return site.entry.title;
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getTitle.name}`, error);
this.handleError(`SitesApi getTitle : catch : `, error);
return null;
}
}
@@ -116,7 +126,7 @@ export class SitesApi extends RepoApi {
await this.apiAuth();
return await this.sitesApi.createSite(site);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.createSite.name}`, error);
this.handleError(`SitesApi createSite : catch : `, error);
return null;
}
}
@@ -136,7 +146,7 @@ export class SitesApi extends RepoApi {
return this.createSite(current, visibility);
}, Promise.resolve());
} catch (error) {
this.handleError(`${this.constructor.name} ${this.createSites.name}`, error);
this.handleError(`SitesApi createSites : catch : `, error);
}
}
@@ -149,7 +159,7 @@ export class SitesApi extends RepoApi {
await this.apiAuth();
return await this.sitesApi.deleteSite(siteId, { permanent });
} catch (error) {
this.handleError(`${this.constructor.name} ${this.deleteSite.name}`, error);
this.handleError(`SitesApi deleteSite : catch : `, error);
}
}
@@ -160,7 +170,7 @@ export class SitesApi extends RepoApi {
return this.deleteSite(current, permanent);
}, Promise.resolve());
} catch (error) {
this.handleError(`${this.constructor.name} ${this.deleteSites.name}`, error);
this.handleError(`SitesApi deleteSites : catch : `, error);
}
}
@@ -173,7 +183,7 @@ export class SitesApi extends RepoApi {
return this.deleteSite(current, permanent);
}, Promise.resolve());
} catch (error) {
this.handleError(`${this.constructor.name} ${this.deleteAllUserSites.name}`, error);
this.handleError(`SitesApi deleteAllUserSites : catch : `, error);
}
}
@@ -186,7 +196,7 @@ export class SitesApi extends RepoApi {
await this.apiAuth();
return await this.sitesApi.updateSiteMembership(siteId, userId, siteRole);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.updateSiteMember.name}`, error);
this.handleError(`SitesApi updateSiteMember : catch : `, error);
return null;
}
}
@@ -201,8 +211,12 @@ export class SitesApi extends RepoApi {
await this.apiAuth();
return await this.sitesApi.createSiteMembership(siteId, memberBody);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.addSiteMember.name}`, error);
return null;
if (error.status === 409) {
return this.updateSiteMember(siteId, userId, role);
} else {
this.handleError(`SitesApi addSiteMember : catch : `, error);
return null;
}
}
}
@@ -227,7 +241,7 @@ export class SitesApi extends RepoApi {
await this.apiAuth();
return await this.sitesApi.deleteSiteMembership(siteId, userId);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.deleteSiteMember.name}`, error);
this.handleError(`SitesApi deleteSiteMember : catch : `, error);
}
}
@@ -240,7 +254,7 @@ export class SitesApi extends RepoApi {
await this.apiAuth();
return await this.sitesApi.createSiteMembershipRequestForPerson('-me-', body);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.requestToJoin.name}`, error);
this.handleError(`SitesApi requestToJoin : catch : `, error);
return null;
}
}
@@ -251,7 +265,7 @@ export class SitesApi extends RepoApi {
const requests = (await this.sitesApi.getSiteMembershipRequests('-me-')).list.entries.map((e) => e.entry.id);
return requests.includes(siteId);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.hasMembershipRequest.name}`, error);
this.handleError(`SitesApi hasMembershipRequest : catch : `, error);
return null;
}
}
@@ -259,7 +273,7 @@ export class SitesApi extends RepoApi {
async waitForApi(data: { expect: number }) {
try {
const sites = async () => {
const totalItems = (await this.getSites()).list.pagination.totalItems;
const totalItems = await this.getSitesTotalItems();
if (totalItems !== data.expect) {
return Promise.reject(totalItems);
} else {
@@ -269,7 +283,7 @@ export class SitesApi extends RepoApi {
return await Utils.retryCall(sites);
} catch (error) {
Logger.error(`${this.constructor.name} ${this.waitForApi.name} catch: `);
Logger.error(`SitesApi waitForApi : catch : `);
Logger.error(`\tExpected: ${data.expect} items, but found ${error}`);
}
}

View File

@@ -40,7 +40,7 @@ export class TrashcanApi extends RepoApi {
await this.apiAuth();
return await this.trashcanApi.deleteDeletedNode(id);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.permanentlyDelete.name}`, error);
this.handleError(`TrashcanApi permanentlyDelete : catch : `, error);
}
}
@@ -49,7 +49,7 @@ export class TrashcanApi extends RepoApi {
await this.apiAuth();
return await this.trashcanApi.restoreDeletedNode(id);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.restore.name}`, error);
this.handleError(`TrashcanApi restore : catch : `, error);
return null;
}
}
@@ -62,11 +62,24 @@ export class TrashcanApi extends RepoApi {
await this.apiAuth();
return await this.trashcanApi.listDeletedNodes(opts);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getDeletedNodes.name}`, error);
this.handleError(`TrashcanApi getDeletedNodes : catch : `, error);
return null;
}
}
async getDeletedNodesTotalItems(): Promise<number> {
const opts = {
maxItems: 1000
};
try {
await this.apiAuth();
return (await this.trashcanApi.listDeletedNodes(opts)).list.pagination.totalItems;
} catch (error) {
this.handleError(`TrashcanApi getDeletedNodesTotalItems : catch : `, error);
return -1;
}
}
async emptyTrash() {
try {
const ids = (await this.getDeletedNodes()).list.entries.map((entries) => entries.entry.id);
@@ -76,14 +89,14 @@ export class TrashcanApi extends RepoApi {
return this.permanentlyDelete(current);
}, Promise.resolve());
} catch (error) {
this.handleError(`${this.constructor.name} ${this.emptyTrash.name}`, error);
this.handleError(`TrashcanApi emptyTrash : catch : `, error);
}
}
async waitForApi(data: { expect: number }) {
try {
const deletedFiles = async () => {
const totalItems = (await this.getDeletedNodes()).list.pagination.totalItems;
const totalItems = await this.getDeletedNodesTotalItems();
if (totalItems !== data.expect) {
return Promise.reject(totalItems);
} else {
@@ -93,7 +106,7 @@ export class TrashcanApi extends RepoApi {
return await Utils.retryCall(deletedFiles);
} catch (error) {
Logger.error(`${this.constructor.name} ${this.waitForApi.name} catch: `);
Logger.error(`TrashcanApi waitForApi : catch : `);
Logger.error(`\tExpected: ${data.expect} items, but found ${error}`);
}
}

View File

@@ -119,7 +119,7 @@ export class Utils {
await browser.executeScript(`window.sessionStorage.setItem('app.extension.config', ${fileContent});`);
}
static retryCall(fn: () => Promise<any>, retry: number = 30, delay: number = 1000): Promise<any> {
static retryCall(fn: () => Promise<any>, retry: number = 30, delay: number = 1500): Promise<any> {
const pause = (duration: number) => new Promise((res) => setTimeout(res, duration));
const run = (retries: number): Promise<any> => {