diff --git a/lib/testing/src/lib/process-services-cloud/actions/application.ts b/lib/testing/src/lib/process-services-cloud/actions/application.ts index f138466af8..d9c4250522 100644 --- a/lib/testing/src/lib/process-services-cloud/actions/application.ts +++ b/lib/testing/src/lib/process-services-cloud/actions/application.ts @@ -19,6 +19,7 @@ import { E2eRequestApiHelper } from '../../core/actions/e2e-request-api.helper'; import { Logger } from '../../core/utils/logger'; import { ResultSetPaging } from '@alfresco/js-api'; import { ApiService } from '../../core/actions/api.service'; +import { ApiUtil } from '../../core/actions/api.util'; export class Application { @@ -40,8 +41,25 @@ export class Application { } async undeploy(applicationName: string): Promise { - await this.requestApiHelper.delete(`${this.endPoint}${applicationName}`); - Logger.info(`[Application] Application ${applicationName} was undeployed successfully.`); + const isApplicationUndeployed = (response: any) => { + if (JSON.stringify(response) === '{}') { + Logger.info(`[Application] Application was undeployed successfully`); + return true; + } else { + Logger.warn(`[Application] Application was not undeployed`); + return false; + } + }; + + const apiCall = async () => { + try { + Logger.info(`[Application] Undeploy application ${applicationName} ...`); + return this.requestApiHelper.delete(`${this.endPoint}${applicationName}`); + } catch (error) { + Logger.error(`[Application] Undeploy application ${applicationName} failed with error: ${error.message}`); + } + }; + return ApiUtil.waitForApi(apiCall, isApplicationUndeployed, 10, 3000); } async deleteDescriptor(name: string): Promise { diff --git a/lib/testing/src/lib/process-services-cloud/actions/descriptor.ts b/lib/testing/src/lib/process-services-cloud/actions/descriptor.ts index ae8f3be3ec..05c37c20c1 100644 --- a/lib/testing/src/lib/process-services-cloud/actions/descriptor.ts +++ b/lib/testing/src/lib/process-services-cloud/actions/descriptor.ts @@ -44,13 +44,26 @@ export class Descriptor { } async delete(name: string): Promise { - try { - await this.retryUntilDescriptorIsInStatus(name, `DescriptorCreated`); - await this.requestApiHelper.delete(`${this.endPoint}${name}`); - Logger.info(`[Descriptor] Descriptor '${name}' was deleted successfully.`); - } catch (error) { - Logger.error(`[Descriptor] Delete descriptor ${name} failed with message: ${error.message}`); - } + const isDescriptorDeleted = (response: any) => { + if (JSON.stringify(response) === '{}') { + Logger.info(`[Descriptor] Descriptor was deleted successfully`); + return true; + } else { + Logger.warn(`[Descriptor] Descriptor was not deleted`); + return false; + } + }; + + const apiCall = async () => { + try { + await this.retryUntilDescriptorIsInStatus(name, `DescriptorCreated`); + Logger.info(`[Descriptor] Deleting descriptor ${name} ...`); + return this.requestApiHelper.delete(`${this.endPoint}${name}`); + } catch (error) { + Logger.error(`[Descriptor] Delete descriptor ${name} failed with error: ${error.message}`); + } + }; + return ApiUtil.waitForApi(apiCall, isDescriptorDeleted, 10, 3000); } async get(name: string): Promise { @@ -64,8 +77,10 @@ export class Descriptor { async retryUntilDescriptorIsInStatus(name: string, expectedStatus: string): Promise { const predicate = (result: { status: string }) => { + Logger.info(`[Descriptor] Descriptor ${name} status is: ${result.status}`); return result.status === expectedStatus; }; + const apiCall = async () => this.get(name); return ApiUtil.waitForApi(apiCall, predicate);