diff --git a/qa-core/src/config/internal-api/TestConfiguration/index.ts b/qa-core/src/config/internal-api/TestConfiguration/index.ts index b433fd98ea..2e88316b4f 100644 --- a/qa-core/src/config/internal-api/TestConfiguration/index.ts +++ b/qa-core/src/config/internal-api/TestConfiguration/index.ts @@ -1,14 +1,17 @@ import ApplicationApi from "./applications" import AuthApi from "./auth" import InternalAPIClient from "./InternalAPIClient" +import TablesApi from "./tables" export default class TestConfiguration { applications: ApplicationApi auth: AuthApi context: T + tables: TablesApi constructor(apiClient: InternalAPIClient) { this.applications = new ApplicationApi(apiClient) + this.tables = new TablesApi(apiClient) this.auth = new AuthApi(apiClient) this.context = {} } diff --git a/qa-core/src/config/internal-api/TestConfiguration/tables.ts b/qa-core/src/config/internal-api/TestConfiguration/tables.ts new file mode 100644 index 0000000000..62ea7d5e15 --- /dev/null +++ b/qa-core/src/config/internal-api/TestConfiguration/tables.ts @@ -0,0 +1,37 @@ +import { Response } from "node-fetch" +import { Table } from "@budibase/types" +import InternalAPIClient from "./InternalAPIClient" + + +export default class TablesApi { + api: InternalAPIClient + + constructor(apiClient: InternalAPIClient) { + this.api = apiClient + } + + async getTables(): Promise<[Response, Table[]]> { + const response = await this.api.get(`/tables`) + const json = await response.json() + return [response, json] + } + + async getTable(tableId: string): Promise<[Response, Table]> { + const response = await this.api.get(`/tables/${tableId}`) + const json = await response.json() + return [response, json] + } + + async createTable(body: any): Promise<[Response, Table]> { + const response = await this.api.post(`/tables`, { body }) + const json = await response.json() + return [response, json] + } + + async deleteTable(tableId: string, revId: string): Promise<[Response, Table]> { + const response = await this.api.del(`/tables/${tableId}/${revId}`) + const json = await response.json() + return [response, json] + } + +} \ No newline at end of file