From 1d66110d0161c6df3e94da755548e61cb1062880 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 18 Jan 2023 10:45:42 +0000 Subject: [PATCH] More typings --- .../src/tests/utilities/TestConfiguration.ts | 20 ++++++++++--------- .../server/src/tests/utilities/structures.ts | 13 ++++++------ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/packages/server/src/tests/utilities/TestConfiguration.ts b/packages/server/src/tests/utilities/TestConfiguration.ts index ce4fa287a0..03ed5ccee2 100644 --- a/packages/server/src/tests/utilities/TestConfiguration.ts +++ b/packages/server/src/tests/utilities/TestConfiguration.ts @@ -39,7 +39,7 @@ import newid from "../../db/newid" import { generateUserMetadataID } from "../../db/utils" import { startup } from "../../startup" import supertest from "supertest" -import { Table } from "@budibase/types" +import { Datasource, SourceName, Table } from "@budibase/types" const GLOBAL_USER_ID = "us_uuid1" const EMAIL = "babs@babs.com" @@ -554,9 +554,13 @@ class TestConfiguration { // DATASOURCE - async createDatasource(config?: any) { + async createDatasource(config?: Datasource): Promise { config = config || basicDatasource() - const response = await this._req(config, null, controllers.datasource.save) + const response = await this._req( + { datasource: config }, + null, + controllers.datasource.save + ) this.datasource = response.datasource return this.datasource } @@ -573,18 +577,16 @@ class TestConfiguration { async restDatasource(cfg?: any) { return this.createDatasource({ - datasource: { - ...basicDatasource().datasource, - source: "REST", - config: cfg || {}, - }, + ...basicDatasource(), + source: SourceName.REST, + config: cfg || {}, }) } async dynamicVariableDatasource() { let datasource = await this.restDatasource() const basedOnQuery = await this.createQuery({ - ...basicQuery(datasource._id), + ...basicQuery(datasource._id!), fields: { path: "www.google.com", }, diff --git a/packages/server/src/tests/utilities/structures.ts b/packages/server/src/tests/utilities/structures.ts index a412be4931..2e453e86e5 100644 --- a/packages/server/src/tests/utilities/structures.ts +++ b/packages/server/src/tests/utilities/structures.ts @@ -3,6 +3,7 @@ import { createHomeScreen } from "../../constants/screens" import { EMPTY_LAYOUT } from "../../constants/layouts" import { cloneDeep } from "lodash/fp" import { TRIGGER_DEFINITIONS, ACTION_DEFINITIONS } from "../../automations" +import { Datasource, SourceName } from "@budibase/types" const { v4: uuidv4 } = require("uuid") export const TENANT_ID = "default" @@ -144,14 +145,12 @@ export function basicRole() { } } -export function basicDatasource() { +export function basicDatasource(): Datasource { return { - datasource: { - type: "datasource", - name: "Test", - source: "POSTGRES", - config: {}, - }, + type: "datasource", + name: "Test", + source: SourceName.POSTGRES, + config: {}, } }