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