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 = [
|
||||||
_component: "@budibase/standard-components/tableblock",
|
{
|
||||||
_id: "foo",
|
_instanceName: "Table Block",
|
||||||
linkRows: true,
|
_styles: {},
|
||||||
linkURL: "/rows/:id",
|
_component: "@budibase/standard-components/tableblock",
|
||||||
linkPeek: true,
|
_id: "foo",
|
||||||
linkColumn: "name",
|
linkRows: true,
|
||||||
}
|
linkURL: "/rows/:id",
|
||||||
|
linkPeek: true,
|
||||||
|
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 = [
|
||||||
_component: "@budibase/standard-components/table",
|
{
|
||||||
_id: "foo",
|
_instanceName: "Table",
|
||||||
linkRows: true,
|
_styles: {},
|
||||||
linkURL: "/rows/:id",
|
_component: "@budibase/standard-components/table",
|
||||||
linkPeek: true,
|
_id: "foo",
|
||||||
linkColumn: "name",
|
linkRows: true,
|
||||||
}
|
linkURL: "/rows/:id",
|
||||||
|
linkPeek: true,
|
||||||
|
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 = [
|
||||||
_component: "@budibase/standard-components/tableblock",
|
{
|
||||||
_id: "foo",
|
_instanceName: "Table Block",
|
||||||
showTitleButton: true,
|
_styles: {},
|
||||||
titleButtonURL: "/url",
|
_component: "@budibase/standard-components/tableblock",
|
||||||
titleButtonPeek: true,
|
_id: "foo",
|
||||||
}
|
showTitleButton: true,
|
||||||
|
titleButtonURL: "/url",
|
||||||
|
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,16 +115,20 @@ 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 = [
|
||||||
_component: "@budibase/standard-components/tableblock",
|
{
|
||||||
_id: "foo",
|
_instanceName: "Table Block",
|
||||||
linkRows: true,
|
_styles: {},
|
||||||
linkURL: "/rows/:id",
|
_component: "@budibase/standard-components/tableblock",
|
||||||
linkPeek: true,
|
_id: "foo",
|
||||||
linkColumn: "name",
|
linkRows: true,
|
||||||
onClick: "foo",
|
linkURL: "/rows/:id",
|
||||||
}
|
linkPeek: true,
|
||||||
const initialDefinition = JSON.stringify(screen.props._children[0])
|
linkColumn: "name",
|
||||||
|
onClick: "foo",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
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