From 7c084883230d1b9bd6a3e7cf8601dd0a71cb9c61 Mon Sep 17 00:00:00 2001 From: Adina Parpalita Date: Sat, 11 Aug 2018 00:12:57 +0300 Subject: [PATCH] [ACA-1637] update searchApi to use alfresco-js-api-node (#561) --- .../repo-client/apis/search/search-api.ts | 38 ++++++++----------- e2e/utilities/repo-client/repo-client.ts | 2 +- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/e2e/utilities/repo-client/apis/search/search-api.ts b/e2e/utilities/repo-client/apis/search/search-api.ts index bb09fabd4..e2549dc39 100755 --- a/e2e/utilities/repo-client/apis/search/search-api.ts +++ b/e2e/utilities/repo-client/apis/search/search-api.ts @@ -23,19 +23,16 @@ * along with Alfresco. If not, see . */ -import { RepoApi } from '../repo-api'; +import { RepoApiNew } from '../repo-api-new'; import { Utils } from '../../../../utilities/utils'; -export class SearchApi extends RepoApi { - apiDefinition = 'search'; +export class SearchApi extends RepoApiNew { - search(data: any[]): Promise { - return this - .post(`/search`, { data }, this.apiDefinition) - .catch(this.handleError); + constructor(username?, password?) { + super(username, password); } - queryRecentFiles(username: string): Promise { + async queryRecentFiles(username: string) { const data = { query: { query: '*', @@ -48,22 +45,19 @@ export class SearchApi extends RepoApi { ] }; - return this - .post(`/search`, { data }, this.apiDefinition) - .catch(this.handleError); + await this.apiAuth(); + return this.alfrescoJsApi.search.searchApi.search(data); + } - waitForApi(username, data) { - const recentFiles = () => { - return this.queryRecentFiles(username) - .then(response => response.data.list.pagination.totalItems) - .then(totalItems => { - if ( totalItems < data.expect) { - return Promise.reject(totalItems); - } else { - return Promise.resolve(totalItems); - } - }); + async waitForApi(username, data) { + 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); + } }; return Utils.retryCall(recentFiles); diff --git a/e2e/utilities/repo-client/repo-client.ts b/e2e/utilities/repo-client/repo-client.ts index 8cdbe542d..b9edf5f76 100755 --- a/e2e/utilities/repo-client/repo-client.ts +++ b/e2e/utilities/repo-client/repo-client.ts @@ -70,7 +70,7 @@ export class RepoClient { } get search() { - return new SearchApi(this.auth, this.config); + return new SearchApi(this.auth.username, this.auth.password); } }