[ACA-1762] async await pagination (#687)

* use async / await in pagination tests

* add catch in waitForApi
This commit is contained in:
Adina Parpalita
2018-10-05 14:51:53 +03:00
committed by Denys Vuika
parent ac99f5397d
commit 4f4a69338f
13 changed files with 975 additions and 1131 deletions

View File

@@ -90,15 +90,20 @@ export class FavoritesApi extends RepoApi {
}
async waitForApi(data) {
try {
const favoriteFiles = async () => {
const totalItems = (await this.getFavorites()).list.pagination.totalItems;
if ( totalItems < data.expect) {
return Promise.reject(totalItems);
} else {
return Promise.resolve(totalItems);
}
const totalItems = (await this.getFavorites()).list.pagination.totalItems;
if ( totalItems !== data.expect) {
return Promise.reject(totalItems);
} else {
return Promise.resolve(totalItems);
}
};
return await Utils.retryCall(favoriteFiles);
} catch (error) {
console.log('-----> catch favorites: ', error);
}
}
}

View File

@@ -51,15 +51,19 @@ export class SearchApi extends RepoApi {
}
async waitForApi(username, data) {
try {
const recentFiles = async () => {
const totalItems = (await this.queryRecentFiles(username)).list.pagination.totalItems;
if ( totalItems < data.expect) {
return Promise.reject(totalItems);
} else {
return Promise.resolve(totalItems);
}
};
const totalItems = (await this.queryRecentFiles(username)).list.pagination.totalItems;
if ( totalItems !== data.expect) {
return Promise.reject(totalItems);
} else {
return Promise.resolve(totalItems);
}
};
return await Utils.retryCall(recentFiles);
return await Utils.retryCall(recentFiles);
} catch (error) {
console.log('-----> catch search: ', error);
}
}
}

View File

@@ -62,15 +62,19 @@ export class SharedLinksApi extends RepoApi {
}
async waitForApi(data) {
try {
const sharedFiles = async () => {
const totalItems = (await this.getSharedLinks()).list.pagination.totalItems;
if ( totalItems < data.expect ) {
return Promise.reject(totalItems);
} else {
return Promise.resolve(totalItems);
}
};
const totalItems = (await this.getSharedLinks()).list.pagination.totalItems;
if ( totalItems !== data.expect ) {
return Promise.reject(totalItems);
} else {
return Promise.resolve(totalItems);
}
};
return await Utils.retryCall(sharedFiles);
return await Utils.retryCall(sharedFiles);
} catch (error) {
console.log('-----> catch shared: ', error);
}
}
}

View File

@@ -105,9 +105,10 @@ export class SitesApi extends RepoApi {
}
async waitForApi(data) {
const sites = async () => {
try {
const sites = async () => {
const totalItems = (await this.getSites()).list.pagination.totalItems;
if ( totalItems < data.expect ) {
if ( totalItems !== data.expect ) {
return Promise.reject(totalItems);
} else {
return Promise.resolve(totalItems);
@@ -115,5 +116,8 @@ export class SitesApi extends RepoApi {
};
return await Utils.retryCall(sites);
} catch (error) {
console.log('-----> catch sites: ', error);
}
}
}

View File

@@ -60,9 +60,10 @@ export class TrashcanApi extends RepoApi {
}
async waitForApi(data) {
const deletedFiles = async () => {
try {
const deletedFiles = async () => {
const totalItems = (await this.getDeletedNodes()).list.pagination.totalItems;
if ( totalItems < data.expect) {
if ( totalItems !== data.expect) {
return Promise.reject(totalItems);
} else {
return Promise.resolve(totalItems);
@@ -70,5 +71,8 @@ export class TrashcanApi extends RepoApi {
};
return await Utils.retryCall(deletedFiles);
} catch (error) {
console.log('-----> catch trash: ', error);
}
}
}