Fix types in table migration tests
This commit is contained in:
parent
a3cb7e9516
commit
bc33af13f9
|
@ -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] = {
|
||||
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] = {
|
||||
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] = {
|
||||
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,7 +115,10 @@ describe("run", () => {
|
|||
|
||||
it("ignores components that have already been migrated", async () => {
|
||||
// Add legacy table block as first child
|
||||
screen.props._children[0] = {
|
||||
screen.props._children = [
|
||||
{
|
||||
_instanceName: "Table Block",
|
||||
_styles: {},
|
||||
_component: "@budibase/standard-components/tableblock",
|
||||
_id: "foo",
|
||||
linkRows: true,
|
||||
|
@ -111,8 +126,9 @@ describe("run", () => {
|
|||
linkPeek: true,
|
||||
linkColumn: "name",
|
||||
onClick: "foo",
|
||||
}
|
||||
const initialDefinition = JSON.stringify(screen.props._children[0])
|
||||
},
|
||||
]
|
||||
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)
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue