From b9bd007a0b09c7bfb1a877a638eaa59a908860da Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Fri, 28 Oct 2022 16:48:29 +0100 Subject: [PATCH] Add missing test to app flow --- .../internal-api/TestConfiguration/applications.ts | 11 +++++++++++ .../fixtures/types/unpublishAppResponse.ts | 7 +++++++ .../tests/internal-api/applications/create.spec.ts | 6 +++++- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 qa-core/src/config/internal-api/fixtures/types/unpublishAppResponse.ts diff --git a/qa-core/src/config/internal-api/TestConfiguration/applications.ts b/qa-core/src/config/internal-api/TestConfiguration/applications.ts index c5e81f3718..dd98936d3c 100644 --- a/qa-core/src/config/internal-api/TestConfiguration/applications.ts +++ b/qa-core/src/config/internal-api/TestConfiguration/applications.ts @@ -7,6 +7,7 @@ import { RouteConfig } from "../fixtures/types/routing" import { AppPackageResponse } from "../fixtures/types/appPackage" import { DeployConfig } from "../fixtures/types/deploy" import { responseMessage } from "../fixtures/types/responseMessage" +import { UnpublishAppResponse } from "../fixtures/types/unpublishAppResponse" export default class AppApi { api: InternalAPIClient @@ -100,4 +101,14 @@ export default class AppApi { const json = await response.json() return [response, json] } + + async unpublish(appId: string): Promise<[Response, UnpublishAppResponse]> { + const response = await this.api.del(`/applications/${appId}?unpublish=1`) + expect(response).toHaveStatusCode(200) + const json = await response.json() + expect(json.data.ok).toBe(true) + expect(json.ok).toBe(true) + expect(json.status).toBe(200) + return [response, json] + } } diff --git a/qa-core/src/config/internal-api/fixtures/types/unpublishAppResponse.ts b/qa-core/src/config/internal-api/fixtures/types/unpublishAppResponse.ts new file mode 100644 index 0000000000..83b0c50352 --- /dev/null +++ b/qa-core/src/config/internal-api/fixtures/types/unpublishAppResponse.ts @@ -0,0 +1,7 @@ +export interface UnpublishAppResponse { + data: { + ok: boolean + }, + ok: boolean, + status: number +} diff --git a/qa-core/src/tests/internal-api/applications/create.spec.ts b/qa-core/src/tests/internal-api/applications/create.spec.ts index ee46bebf8f..59815923cf 100644 --- a/qa-core/src/tests/internal-api/applications/create.spec.ts +++ b/qa-core/src/tests/internal-api/applications/create.spec.ts @@ -63,7 +63,7 @@ describe("Internal API - /applications endpoints", () => { }) }) - it("POST - Create an application from a template, publish and check it renders", async () => { + it("Publish app flow", async () => { // create the app const appName = generator.word() const app = await createAppFromTemplate() @@ -83,6 +83,10 @@ describe("Internal API - /applications endpoints", () => { const [publishedAppResponse, publishedAppRenders] = await config.applications.canRender() expect(publishedAppRenders).toBe(true) + + // unpublish app + await config.applications.unpublish(app.appId) + }) it("POST - Sync application before deployment", async () => {