Fix tests
This commit is contained in:
parent
ed9e0ed2ff
commit
24332f2f45
|
@ -10,7 +10,6 @@ import {
|
||||||
ViewV2,
|
ViewV2,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { generator } from "@budibase/backend-core/tests"
|
import { generator } from "@budibase/backend-core/tests"
|
||||||
import { buildExternalTableId } from "../../../integrations/utils"
|
|
||||||
import { generateDatasourceID } from "../../../db/utils"
|
import { generateDatasourceID } from "../../../db/utils"
|
||||||
|
|
||||||
function priceTable(): Table {
|
function priceTable(): Table {
|
||||||
|
@ -41,7 +40,7 @@ beforeAll(async () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe.each([
|
describe.each([
|
||||||
// ["internal ds", () => config.createTable(priceTable())],
|
["internal ds", () => config.createTable(priceTable())],
|
||||||
[
|
[
|
||||||
"external ds",
|
"external ds",
|
||||||
async () => {
|
async () => {
|
||||||
|
@ -175,7 +174,8 @@ describe.each([
|
||||||
let view: ViewV2
|
let view: ViewV2
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await config.createTable(priceTable())
|
table = await tableBuilder()
|
||||||
|
|
||||||
view = await config.api.viewV2.create({ name: "View A" })
|
view = await config.api.viewV2.create({ name: "View A" })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -186,19 +186,12 @@ describe.each([
|
||||||
query: [{ operator: "equal", field: "newField", value: "thatValue" }],
|
query: [{ operator: "equal", field: "newField", value: "thatValue" }],
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(await config.api.table.get(tableId)).toEqual({
|
expect((await config.api.table.get(tableId)).views).toEqual({
|
||||||
...config.table,
|
[view.name]: {
|
||||||
views: {
|
...view,
|
||||||
[view.name]: {
|
query: [{ operator: "equal", field: "newField", value: "thatValue" }],
|
||||||
...view,
|
schema: expect.anything(),
|
||||||
query: [
|
|
||||||
{ operator: "equal", field: "newField", value: "thatValue" },
|
|
||||||
],
|
|
||||||
schema: expect.anything(),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
_rev: expect.any(String),
|
|
||||||
updatedAt: expect.any(String),
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -231,24 +224,19 @@ describe.each([
|
||||||
}
|
}
|
||||||
await config.api.viewV2.update(updatedData)
|
await config.api.viewV2.update(updatedData)
|
||||||
|
|
||||||
expect(await config.api.table.get(tableId)).toEqual({
|
expect((await config.api.table.get(tableId)).views).toEqual({
|
||||||
...config.table,
|
[view.name]: {
|
||||||
views: {
|
...updatedData,
|
||||||
[view.name]: {
|
schema: {
|
||||||
...updatedData,
|
...table.schema,
|
||||||
schema: {
|
Category: expect.objectContaining({
|
||||||
...table.schema,
|
visible: false,
|
||||||
Category: expect.objectContaining({
|
}),
|
||||||
visible: false,
|
Price: expect.objectContaining({
|
||||||
}),
|
visible: false,
|
||||||
Price: expect.objectContaining({
|
}),
|
||||||
visible: false,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
_rev: expect.any(String),
|
|
||||||
updatedAt: expect.any(String),
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -401,7 +389,6 @@ describe.each([
|
||||||
let view: ViewV2
|
let view: ViewV2
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await config.createTable(priceTable())
|
|
||||||
view = await config.api.viewV2.create()
|
view = await config.api.viewV2.create()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -420,8 +407,6 @@ describe.each([
|
||||||
|
|
||||||
describe("fetch view (through table)", () => {
|
describe("fetch view (through table)", () => {
|
||||||
it("should be able to fetch a view V2", async () => {
|
it("should be able to fetch a view V2", async () => {
|
||||||
const table = await config.createTable(priceTable())
|
|
||||||
|
|
||||||
const newView: CreateViewRequest = {
|
const newView: CreateViewRequest = {
|
||||||
name: generator.name(),
|
name: generator.name(),
|
||||||
tableId: table._id!,
|
tableId: table._id!,
|
||||||
|
|
Loading…
Reference in New Issue