Use configs
This commit is contained in:
parent
3843581e56
commit
fccb2f625c
|
@ -474,8 +474,8 @@ describe.each([
|
||||||
it("views have extra data trimmed", async () => {
|
it("views have extra data trimmed", async () => {
|
||||||
const table = await config.createTable(await orderTable())
|
const table = await config.createTable(await orderTable())
|
||||||
|
|
||||||
const createViewResponse = await config.api.viewV2.create({
|
const createViewResponse = await config.createView({
|
||||||
tableId: table._id,
|
name: generator.word(),
|
||||||
schema: {
|
schema: {
|
||||||
Country: {
|
Country: {
|
||||||
visible: true,
|
visible: true,
|
||||||
|
@ -960,8 +960,7 @@ describe.each([
|
||||||
describe("create", () => {
|
describe("create", () => {
|
||||||
it("should persist a new row with only the provided view fields", async () => {
|
it("should persist a new row with only the provided view fields", async () => {
|
||||||
const table = await config.createTable(await userTable())
|
const table = await config.createTable(await userTable())
|
||||||
const view = await config.api.viewV2.create({
|
const view = await config.createView({
|
||||||
tableId: table._id!,
|
|
||||||
schema: {
|
schema: {
|
||||||
name: { visible: true },
|
name: { visible: true },
|
||||||
surname: { visible: true },
|
surname: { visible: true },
|
||||||
|
@ -997,8 +996,7 @@ describe.each([
|
||||||
it("should update only the view fields for a row", async () => {
|
it("should update only the view fields for a row", async () => {
|
||||||
const table = await config.createTable(await userTable())
|
const table = await config.createTable(await userTable())
|
||||||
const tableId = table._id!
|
const tableId = table._id!
|
||||||
const view = await config.api.viewV2.create({
|
const view = await config.createView({
|
||||||
tableId,
|
|
||||||
schema: {
|
schema: {
|
||||||
name: { visible: true },
|
name: { visible: true },
|
||||||
address: { visible: true },
|
address: { visible: true },
|
||||||
|
@ -1039,8 +1037,7 @@ describe.each([
|
||||||
it("should be able to delete a row", async () => {
|
it("should be able to delete a row", async () => {
|
||||||
const table = await config.createTable(await userTable())
|
const table = await config.createTable(await userTable())
|
||||||
const tableId = table._id!
|
const tableId = table._id!
|
||||||
const view = await config.api.viewV2.create({
|
const view = await config.createView({
|
||||||
tableId,
|
|
||||||
schema: {
|
schema: {
|
||||||
name: { visible: true },
|
name: { visible: true },
|
||||||
address: { visible: true },
|
address: { visible: true },
|
||||||
|
@ -1064,8 +1061,7 @@ describe.each([
|
||||||
it("should be able to delete multiple rows", async () => {
|
it("should be able to delete multiple rows", async () => {
|
||||||
const table = await config.createTable(await userTable())
|
const table = await config.createTable(await userTable())
|
||||||
const tableId = table._id!
|
const tableId = table._id!
|
||||||
const view = await config.api.viewV2.create({
|
const view = await config.createView({
|
||||||
tableId,
|
|
||||||
schema: {
|
schema: {
|
||||||
name: { visible: true },
|
name: { visible: true },
|
||||||
address: { visible: true },
|
address: { visible: true },
|
||||||
|
@ -1134,9 +1130,7 @@ describe.each([
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const createViewResponse = await config.api.viewV2.create({
|
const createViewResponse = await config.createView()
|
||||||
tableId: table._id,
|
|
||||||
})
|
|
||||||
const response = await config.api.viewV2.search(createViewResponse.id)
|
const response = await config.api.viewV2.search(createViewResponse.id)
|
||||||
|
|
||||||
expect(response.body.rows).toHaveLength(10)
|
expect(response.body.rows).toHaveLength(10)
|
||||||
|
@ -1174,8 +1168,7 @@ describe.each([
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
const createViewResponse = await config.api.viewV2.create({
|
const createViewResponse = await config.createView({
|
||||||
tableId: table._id!,
|
|
||||||
query: [{ operator: "equal", field: "age", value: 40 }],
|
query: [{ operator: "equal", field: "age", value: 40 }],
|
||||||
schema: viewSchema,
|
schema: viewSchema,
|
||||||
})
|
})
|
||||||
|
@ -1286,8 +1279,7 @@ describe.each([
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const createViewResponse = await config.api.viewV2.create({
|
const createViewResponse = await config.createView({
|
||||||
tableId: table._id,
|
|
||||||
sort: sortParams,
|
sort: sortParams,
|
||||||
schema: viewSchema,
|
schema: viewSchema,
|
||||||
})
|
})
|
||||||
|
@ -1318,8 +1310,7 @@ describe.each([
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const createViewResponse = await config.api.viewV2.create({
|
const createViewResponse = await config.createView({
|
||||||
tableId: table._id,
|
|
||||||
sort: {
|
sort: {
|
||||||
field: "name",
|
field: "name",
|
||||||
order: SortOrder.ASCENDING,
|
order: SortOrder.ASCENDING,
|
||||||
|
@ -1358,8 +1349,7 @@ describe.each([
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const view = await config.api.viewV2.create({
|
const view = await config.createView({
|
||||||
tableId: table._id,
|
|
||||||
schema: { name: { visible: true } },
|
schema: { name: { visible: true } },
|
||||||
})
|
})
|
||||||
const response = await config.api.viewV2.search(view.id)
|
const response = await config.api.viewV2.search(view.id)
|
||||||
|
@ -1381,9 +1371,7 @@ describe.each([
|
||||||
it("views without data can be returned", async () => {
|
it("views without data can be returned", async () => {
|
||||||
const table = await config.createTable(await userTable())
|
const table = await config.createTable(await userTable())
|
||||||
|
|
||||||
const createViewResponse = await config.api.viewV2.create({
|
const createViewResponse = await config.createView()
|
||||||
tableId: table._id,
|
|
||||||
})
|
|
||||||
const response = await config.api.viewV2.search(createViewResponse.id)
|
const response = await config.api.viewV2.search(createViewResponse.id)
|
||||||
|
|
||||||
expect(response.body.rows).toHaveLength(0)
|
expect(response.body.rows).toHaveLength(0)
|
||||||
|
@ -1397,9 +1385,7 @@ describe.each([
|
||||||
}
|
}
|
||||||
const limit = generator.integer({ min: 1, max: 8 })
|
const limit = generator.integer({ min: 1, max: 8 })
|
||||||
|
|
||||||
const createViewResponse = await config.api.viewV2.create({
|
const createViewResponse = await config.createView()
|
||||||
tableId: table._id,
|
|
||||||
})
|
|
||||||
const response = await config.api.viewV2.search(createViewResponse.id, {
|
const response = await config.api.viewV2.search(createViewResponse.id, {
|
||||||
limit,
|
limit,
|
||||||
query: {},
|
query: {},
|
||||||
|
@ -1415,9 +1401,7 @@ describe.each([
|
||||||
rows.push(await config.createRow())
|
rows.push(await config.createRow())
|
||||||
}
|
}
|
||||||
|
|
||||||
const createViewResponse = await config.api.viewV2.create({
|
const createViewResponse = await config.createView()
|
||||||
tableId: table._id,
|
|
||||||
})
|
|
||||||
const allRows = (await config.api.viewV2.search(createViewResponse.id))
|
const allRows = (await config.api.viewV2.search(createViewResponse.id))
|
||||||
.body.rows
|
.body.rows
|
||||||
|
|
||||||
|
@ -1481,9 +1465,7 @@ describe.each([
|
||||||
rows.push(await config.createRow())
|
rows.push(await config.createRow())
|
||||||
}
|
}
|
||||||
|
|
||||||
const createViewResponse = await config.api.viewV2.create({
|
const createViewResponse = await config.createView()
|
||||||
tableId: table._id,
|
|
||||||
})
|
|
||||||
|
|
||||||
tableId = table._id!
|
tableId = table._id!
|
||||||
viewId = createViewResponse.id
|
viewId = createViewResponse.id
|
||||||
|
|
|
@ -53,6 +53,8 @@ import {
|
||||||
View,
|
View,
|
||||||
FieldType,
|
FieldType,
|
||||||
RelationshipType,
|
RelationshipType,
|
||||||
|
ViewV2,
|
||||||
|
CreateViewRequest,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
|
|
||||||
import API from "./api"
|
import API from "./api"
|
||||||
|
@ -651,6 +653,25 @@ class TestConfiguration {
|
||||||
return this._req(view, null, controllers.view.v1.save)
|
return this._req(view, null, controllers.view.v1.save)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async createView(
|
||||||
|
config?: Omit<CreateViewRequest, "tableId" | "name"> & {
|
||||||
|
name?: string
|
||||||
|
tableId?: string
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
if (!this.table && !config?.tableId) {
|
||||||
|
throw "Test requires table to be configured."
|
||||||
|
}
|
||||||
|
|
||||||
|
const view: CreateViewRequest = {
|
||||||
|
...config,
|
||||||
|
tableId: config?.tableId || this.table!._id!,
|
||||||
|
name: config?.name || generator.word(),
|
||||||
|
}
|
||||||
|
|
||||||
|
return await this.api.viewV2.create(view)
|
||||||
|
}
|
||||||
|
|
||||||
// AUTOMATION
|
// AUTOMATION
|
||||||
|
|
||||||
async createAutomation(config?: any) {
|
async createAutomation(config?: any) {
|
||||||
|
|
Loading…
Reference in New Issue