1
0
Fork 0
mirror of synced 2024-08-14 01:21:41 +12:00

Fix types in table migration tests

This commit is contained in:
Andrew Kingston 2022-11-29 16:27:06 +00:00
parent 0b6c459fbd
commit a0776ac73a

View file

@ -1,4 +1,4 @@
import { App, Screen, ScreenProps, Component } from "@budibase/types"
import { App, Screen } from "@budibase/types"
import { db as dbCore } from "@budibase/backend-core"
import TestConfig from "../../../tests/utilities/TestConfiguration"
@ -7,7 +7,7 @@ import { run as runMigration } from "../tableSettings"
describe("run", () => {
const config = new TestConfig(false)
let app: App
let screen: Component
let screen: Screen
beforeAll(async () => {
await config.init()
@ -19,14 +19,18 @@ describe("run", () => {
it("migrates table block row on click settings", async () => {
// Add legacy table block as first child
screen.props._children[0] = {
_component: "@budibase/standard-components/tableblock",
_id: "foo",
linkRows: true,
linkURL: "/rows/:id",
linkPeek: true,
linkColumn: "name",
}
screen.props._children = [
{
_instanceName: "Table Block",
_styles: {},
_component: "@budibase/standard-components/tableblock",
_id: "foo",
linkRows: true,
linkURL: "/rows/:id",
linkPeek: true,
linkColumn: "name",
},
]
await config.createScreen(screen)
// Run migration
@ -36,7 +40,7 @@ describe("run", () => {
})
// Verify new "onClick" setting
const onClick = screen.props._children[0].onClick
const onClick = screen.props._children?.[0].onClick
expect(onClick).toBeDefined()
expect(onClick.length).toBe(1)
expect(onClick[0]["##eventHandlerType"]).toBe("Navigate To")
@ -48,14 +52,18 @@ describe("run", () => {
it("migrates table row on click settings", async () => {
// Add legacy table block as first child
screen.props._children[0] = {
_component: "@budibase/standard-components/table",
_id: "foo",
linkRows: true,
linkURL: "/rows/:id",
linkPeek: true,
linkColumn: "name",
}
screen.props._children = [
{
_instanceName: "Table",
_styles: {},
_component: "@budibase/standard-components/table",
_id: "foo",
linkRows: true,
linkURL: "/rows/:id",
linkPeek: true,
linkColumn: "name",
},
]
await config.createScreen(screen)
// Run migration
@ -65,7 +73,7 @@ describe("run", () => {
})
// Verify new "onClick" setting
const onClick = screen.props._children[0].onClick
const onClick = screen.props._children?.[0].onClick
expect(onClick).toBeDefined()
expect(onClick.length).toBe(1)
expect(onClick[0]["##eventHandlerType"]).toBe("Navigate To")
@ -77,13 +85,17 @@ describe("run", () => {
it("migrates table block title button settings", async () => {
// Add legacy table block as first child
screen.props._children[0] = {
_component: "@budibase/standard-components/tableblock",
_id: "foo",
showTitleButton: true,
titleButtonURL: "/url",
titleButtonPeek: true,
}
screen.props._children = [
{
_instanceName: "Table Block",
_styles: {},
_component: "@budibase/standard-components/tableblock",
_id: "foo",
showTitleButton: true,
titleButtonURL: "/url",
titleButtonPeek: true,
},
]
await config.createScreen(screen)
// Run migration
@ -93,7 +105,7 @@ describe("run", () => {
})
// Verify new "onClickTitleButton" setting
const onClick = screen.props._children[0].onClickTitleButton
const onClick = screen.props._children?.[0].onClickTitleButton
expect(onClick).toBeDefined()
expect(onClick.length).toBe(1)
expect(onClick[0]["##eventHandlerType"]).toBe("Navigate To")
@ -103,16 +115,20 @@ describe("run", () => {
it("ignores components that have already been migrated", async () => {
// Add legacy table block as first child
screen.props._children[0] = {
_component: "@budibase/standard-components/tableblock",
_id: "foo",
linkRows: true,
linkURL: "/rows/:id",
linkPeek: true,
linkColumn: "name",
onClick: "foo",
}
const initialDefinition = JSON.stringify(screen.props._children[0])
screen.props._children = [
{
_instanceName: "Table Block",
_styles: {},
_component: "@budibase/standard-components/tableblock",
_id: "foo",
linkRows: true,
linkURL: "/rows/:id",
linkPeek: true,
linkColumn: "name",
onClick: "foo",
},
]
const initialDefinition = JSON.stringify(screen.props._children?.[0])
await config.createScreen(screen)
// Run migration
@ -122,7 +138,7 @@ describe("run", () => {
})
// Verify new "onClick" setting
const newDefinition = JSON.stringify(screen.props._children[0])
const newDefinition = JSON.stringify(screen.props._children?.[0])
expect(initialDefinition).toEqual(newDefinition)
})
})