Update table migration test to use imports, and update TestConfiguration to work with type parameters

This commit is contained in:
Andrew Kingston 2022-11-29 12:19:37 +00:00
parent 3c3c2325e7
commit 4279d3687e
2 changed files with 21 additions and 21 deletions

View File

@ -1,8 +1,8 @@
import { App, Screen, ScreenProps } from "@budibase/types"
const { db: dbCore } = require("@budibase/backend-core")
const TestConfig = require("../../../tests/utilities/TestConfiguration")
const migration = require("../tableSettings")
import { db as dbCore } from "@budibase/backend-core"
import TestConfig from "../../../tests/utilities/TestConfiguration"
import { run as runMigration } from "../tableSettings"
// Local type for allowing any child components inside screens
type MigratingScreenProps = ScreenProps & { _children: any[] }
@ -35,7 +35,7 @@ describe("run", () => {
// Run migration
screen = await dbCore.doWithDB(app.appId, async (db: any) => {
await migration.run(db)
await runMigration(db)
return await db.get(screen._id)
})
@ -64,7 +64,7 @@ describe("run", () => {
// Run migration
screen = await dbCore.doWithDB(app.appId, async (db: any) => {
await migration.run(db)
await runMigration(db)
return await db.get(screen._id)
})
@ -92,7 +92,7 @@ describe("run", () => {
// Run migration
screen = await dbCore.doWithDB(app.appId, async (db: any) => {
await migration.run(db)
await runMigration(db)
return await db.get(screen._id)
})
@ -121,7 +121,7 @@ describe("run", () => {
// Run migration
screen = await dbCore.doWithDB(app.appId, async (db: any) => {
await migration.run(db)
await runMigration(db)
return await db.get(screen._id)
})

View File

@ -87,7 +87,7 @@ class TestConfiguration {
}
return tenancy.doInTenant(TENANT_ID, () => {
// check if already in a context
if (context.getAppId() == null && appId !== null) {
if (context.getAppId() == null && appId != null) {
return context.doInAppContext(appId, async () => {
return task()
})
@ -196,7 +196,7 @@ class TestConfiguration {
}
async createUser(
id = null,
id,
firstName = FIRSTNAME,
lastName = LASTNAME,
email = EMAIL,
@ -366,25 +366,25 @@ class TestConfiguration {
// TABLE
async updateTable(config = null) {
async updateTable(config) {
config = config || basicTable()
this.table = await this._req(config, null, controllers.table.save)
return this.table
}
async createTable(config = null) {
async createTable(config) {
if (config != null && config._id) {
delete config._id
}
return this.updateTable(config)
}
async getTable(tableId = null) {
async getTable(tableId) {
tableId = tableId || this.table._id
return this._req(null, { tableId }, controllers.table.find)
}
async createLinkedTable(relationshipType = null, links = ["link"]) {
async createLinkedTable(relationshipType, links = ["link"]) {
if (!this.table) {
throw "Must have created a table first."
}
@ -416,7 +416,7 @@ class TestConfiguration {
// ROW
async createRow(config = null) {
async createRow(config) {
if (!this.table) {
throw "Test requires table to be configured."
}
@ -438,7 +438,7 @@ class TestConfiguration {
// ROLE
async createRole(config = null) {
async createRole(config) {
config = config || basicRole()
return this._req(config, null, controllers.role.save)
}
@ -485,7 +485,7 @@ class TestConfiguration {
return this._req(null, null, controllers.automation.fetch)
}
async deleteAutomation(automation = null) {
async deleteAutomation(automation) {
automation = automation || this.automation
if (!automation) {
return
@ -497,7 +497,7 @@ class TestConfiguration {
)
}
async createWebhook(config = null) {
async createWebhook(config) {
if (!this.automation) {
throw "Must create an automation before creating webhook."
}
@ -507,7 +507,7 @@ class TestConfiguration {
// DATASOURCE
async createDatasource(config = null) {
async createDatasource(config) {
config = config || basicDatasource()
const response = await this._req(config, null, controllers.datasource.save)
this.datasource = response.datasource
@ -574,7 +574,7 @@ class TestConfiguration {
.expect(200)
}
async createQuery(config = null) {
async createQuery(config) {
if (!this.datasource && !config) {
throw "No datasource created for query."
}
@ -584,14 +584,14 @@ class TestConfiguration {
// SCREEN
async createScreen(config = null) {
async createScreen(config) {
config = config || basicScreen()
return this._req(config, null, controllers.screen.save)
}
// LAYOUT
async createLayout(config = null) {
async createLayout(config) {
config = config || basicLayout()
return await this._req(config, null, controllers.layout.save)
}