From 9094da347ef376761920e05017f9f66600488c64 Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Tue, 11 Oct 2022 16:47:02 +0100 Subject: [PATCH] Add types for Responses --- .../TestConfiguration/applications.ts | 15 ++++++--------- .../internal-api/fixtures/types/appPackage.ts | 9 +++++++++ .../internal-api/fixtures/types/deploy.ts | 6 ++++++ .../internal-api/fixtures/types/routing.ts | 17 +++++++++++++++++ 4 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 qa-core/src/config/internal-api/fixtures/types/appPackage.ts create mode 100644 qa-core/src/config/internal-api/fixtures/types/deploy.ts create mode 100644 qa-core/src/config/internal-api/fixtures/types/routing.ts diff --git a/qa-core/src/config/internal-api/TestConfiguration/applications.ts b/qa-core/src/config/internal-api/TestConfiguration/applications.ts index 7d17250e2b..36abb7db36 100644 --- a/qa-core/src/config/internal-api/TestConfiguration/applications.ts +++ b/qa-core/src/config/internal-api/TestConfiguration/applications.ts @@ -3,6 +3,9 @@ import { App } from "@budibase/types" import { Response } from "node-fetch" import InternalAPIClient from "./InternalAPIClient" import FormData from "form-data" +import { RouteConfig } from "../fixtures/types/routing" +import { AppPackageResponse } from "../fixtures/types/appPackage" +import { DeployConfig } from "../fixtures/types/deploy" type messageResponse = { message: string } @@ -25,13 +28,13 @@ export default class AppApi { return [response, Object.keys(json.routes).length > 0] } - async getAppPackage(appId: string): Promise<[Response, any]> { + async getAppPackage(appId: string): Promise<[Response, AppPackageResponse]> { const response = await this.api.get(`/applications/${appId}/appPackage`) const json = await response.json() return [response, json] } - async publish(): Promise<[Response, any]> { + async publish(): Promise<[Response, DeployConfig]> { const response = await this.api.post("/deploy") const json = await response.json() return [response, json] @@ -73,12 +76,6 @@ export default class AppApi { return [response, json] } - async getAppDefinition(appId: string): Promise<[Response, any]> { - const response = await this.api.get(`/applications/${appId}/definition`) - const json = await response.json() - return [response, json] - } - async update(appId: string, body: any): Promise<[Response, Application]> { const response = await this.api.put(`/applications/${appId}`, { body }) const json = await response.json() @@ -91,7 +88,7 @@ export default class AppApi { return [response, json] } - async getRoutes(): Promise<[Response, any]> { + async getRoutes(): Promise<[Response, RouteConfig]> { const response = await this.api.get(`/routing`) const json = await response.json() return [response, json] diff --git a/qa-core/src/config/internal-api/fixtures/types/appPackage.ts b/qa-core/src/config/internal-api/fixtures/types/appPackage.ts new file mode 100644 index 0000000000..e21e91f78f --- /dev/null +++ b/qa-core/src/config/internal-api/fixtures/types/appPackage.ts @@ -0,0 +1,9 @@ +import { Application } from "@budibase/server/api/controllers/public/mapping/types" +import { Layout } from "@budibase/types" +import { Screen } from "@budibase/types" +// Create type for getAppPackage response +export interface AppPackageResponse { + application: Partial, + layout: Layout, + screens: Screen[] +} diff --git a/qa-core/src/config/internal-api/fixtures/types/deploy.ts b/qa-core/src/config/internal-api/fixtures/types/deploy.ts new file mode 100644 index 0000000000..f859f3255b --- /dev/null +++ b/qa-core/src/config/internal-api/fixtures/types/deploy.ts @@ -0,0 +1,6 @@ + +export interface DeployConfig { + appUrl: string, + status: string, + "_id": string +} diff --git a/qa-core/src/config/internal-api/fixtures/types/routing.ts b/qa-core/src/config/internal-api/fixtures/types/routing.ts new file mode 100644 index 0000000000..0cddcdffb9 --- /dev/null +++ b/qa-core/src/config/internal-api/fixtures/types/routing.ts @@ -0,0 +1,17 @@ +export interface RouteConfig { + routes: Record +} + +export interface Route { + subpaths: Record +} + +export interface Subpath { + screens: ScreenRouteConfig +} + +export interface ScreenRouteConfig { + BASIC?: string + POWER?: string + ADMIN?: string +} \ No newline at end of file