diff --git a/e2e/e2e-config/utils/upload-output.js b/e2e/e2e-config/utils/upload-output.js index b8276e90d8..081be59c61 100644 --- a/e2e/e2e-config/utils/upload-output.js +++ b/e2e/e2e-config/utils/upload-output.js @@ -4,10 +4,6 @@ const AlfrescoApi = require('@alfresco/js-api').AlfrescoApiCompatibility; const buildNumber = require('./build-number'); const outputDir = path.resolve(__dirname, '../../../e2e-output/'); -async function uploadOutput(retryCount = 1) { - await saveScreenshots(retryCount); -}; - async function saveScreenshots(retryCount) { const folderName = process.env.TRAVIS_JOB_NAME.replace(/[^a-z0-9]/gi, '_').toLowerCase(); console.log(`Start uploading report in ${folderName}`); @@ -63,5 +59,5 @@ async function saveScreenshots(retryCount) { } module.exports = { - uploadOutput: uploadOutput + saveScreenshots: saveScreenshots }; diff --git a/e2e/suites/actions-available/files-folders/folders-actions.test.ts b/e2e/suites/actions-available/files-folders/folders-actions.test.ts index 013837bc8e..1ee0bce5b6 100755 --- a/e2e/suites/actions-available/files-folders/folders-actions.test.ts +++ b/e2e/suites/actions-available/files-folders/folders-actions.test.ts @@ -64,6 +64,7 @@ describe('Folders - available actions : ', () => { await userApi.favorites.addFavoritesByIds('folder', [folderFavId, folderFav2Id]); await userApi.favorites.addFavoritesByIds('file', [fileFavId]); await userApi.favorites.waitForApi({ expect: initialFavoritesTotalItems + 3 }); + await userApi.search.waitForNodes(random, { expect: 5 }); await loginPage.loginWith(username); }); diff --git a/e2e/suites/actions-available/files-folders/locked-files-actions.test.ts b/e2e/suites/actions-available/files-folders/locked-files-actions.test.ts index 9593adab6f..b0acb26dfc 100755 --- a/e2e/suites/actions-available/files-folders/locked-files-actions.test.ts +++ b/e2e/suites/actions-available/files-folders/locked-files-actions.test.ts @@ -71,6 +71,7 @@ describe('Locked Files - available actions : ', () => { await userApi.nodes.lockFile(fileSharedFavLockedId); await userApi.shared.waitForFilesToBeShared([fileSharedLockedId, fileSharedFavLockedId]); + await userApi.search.waitForApi(username, { expect: 4 }); await loginPage.loginWith(username); }); diff --git a/e2e/suites/actions-available/files-folders/multiple-files-actions.test.ts b/e2e/suites/actions-available/files-folders/multiple-files-actions.test.ts index 51765e4dc2..a9e1db84e0 100755 --- a/e2e/suites/actions-available/files-folders/multiple-files-actions.test.ts +++ b/e2e/suites/actions-available/files-folders/multiple-files-actions.test.ts @@ -77,6 +77,7 @@ describe('Multiple Files - available actions : ', () => { await userApi.shared.shareFilesByIds([file1Id, file2Id, file3LockedId, file1LockedFavId, file2LockedFavId]); await userApi.shared.waitForFilesToBeShared([file1Id, file2Id, file3LockedId, file1LockedFavId, file2LockedFavId]); + await userApi.search.waitForApi(username, { expect: 5 }); await loginPage.loginWith(username); }); diff --git a/projects/aca-testing-shared/src/utilities/repo-client/apis/search/search-api.ts b/projects/aca-testing-shared/src/utilities/repo-client/apis/search/search-api.ts index 94b33a4bc2..83fbc76fe3 100755 --- a/projects/aca-testing-shared/src/utilities/repo-client/apis/search/search-api.ts +++ b/projects/aca-testing-shared/src/utilities/repo-client/apis/search/search-api.ts @@ -24,7 +24,7 @@ */ import { RepoApi } from '../repo-api'; -import { Logger } from '@alfresco/adf-testing'; +import { ApiUtil, Logger } from '@alfresco/adf-testing'; import { Utils } from '../../../../utilities/utils'; import { SearchApi as AdfSearchApi } from '@alfresco/js-api'; @@ -130,17 +130,18 @@ export class SearchApi extends RepoApi { } async waitForNodes(searchTerm: string, data: { expect: number }) { - try { - const nodes = async () => { - const totalItems = await this.getSearchByTermTotalItems(searchTerm); - if (totalItems !== data.expect) { - return Promise.reject(totalItems); - } else { - return Promise.resolve(totalItems); - } - }; + const predicate = (totalItems: number) => totalItems === data.expect; - return await Utils.retryCall(nodes); + const apiCall = async () => { + try { + return await this.getSearchByTermTotalItems(searchTerm); + } catch (error) { + return 0; + } + }; + + try { + await ApiUtil.waitForApi(apiCall, predicate, 30, 2500); } catch (error) { Logger.error(`SearchApi waitForNodes : catch : `); Logger.error(`\tExpected: ${data.expect} items, but found ${error}`); diff --git a/protractor.conf.js b/protractor.conf.js index 4287de3abe..3058a667f9 100755 --- a/protractor.conf.js +++ b/protractor.conf.js @@ -5,7 +5,7 @@ require('dotenv').config({path: process.env.ENV_FILE}); const path = require('path'); const {SpecReporter} = require('jasmine-spec-reporter'); const retry = require('protractor-retry-angular-cli').retry; -const {uploadScreenshot} = require('./e2e/e2e-config/utils/upload-output'); +const {saveScreenshots} = require('./e2e/e2e-config/utils/upload-output'); const smartRunnerFactory = require('./e2e/smartrunner-factory'); const argv = require('yargs').argv; @@ -213,7 +213,7 @@ exports.config = { } try { - await uploadScreenshot(retryCount, (process.env.FOLDER || '')); + await saveScreenshots(retryCount, (process.env.FOLDER || '')); console.log('Screenshots saved successfully.'); } catch (e) { console.log('Error happened while trying to upload screenshots and test reports: ', e);