Fixes
This commit is contained in:
parent
45ddd46f4c
commit
c26a4c3a11
|
@ -49,7 +49,23 @@ describe.each([
|
||||||
await config.init()
|
await config.init()
|
||||||
})
|
})
|
||||||
|
|
||||||
const generateTableConfig: () => SaveTableRequest = () => ({
|
const tableDatasourceConfig = async () => {
|
||||||
|
const result: Partial<SaveTableRequest> = {}
|
||||||
|
if (dsProvider) {
|
||||||
|
datasource = await config.api.datasource.create(
|
||||||
|
await dsProvider.getDsConfig()
|
||||||
|
)
|
||||||
|
|
||||||
|
result.sourceId = datasource._id
|
||||||
|
if (datasource.plus) {
|
||||||
|
result.type = "external"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
const generateTableConfig: () => Promise<SaveTableRequest> = async () => {
|
||||||
|
return {
|
||||||
name: generator.guid(),
|
name: generator.guid(),
|
||||||
type: "table",
|
type: "table",
|
||||||
primary: ["id"],
|
primary: ["id"],
|
||||||
|
@ -77,23 +93,13 @@ describe.each([
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
...(await tableDatasourceConfig()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
mocks.licenses.useCloudFree()
|
mocks.licenses.useCloudFree()
|
||||||
const tableConfig = generateTableConfig()
|
const tableConfig = await generateTableConfig()
|
||||||
|
|
||||||
if (dsProvider) {
|
|
||||||
datasource = await config.api.datasource.create(
|
|
||||||
await dsProvider.getDsConfig()
|
|
||||||
)
|
|
||||||
|
|
||||||
tableConfig.sourceId = datasource._id
|
|
||||||
if (datasource.plus) {
|
|
||||||
tableConfig.type = "external"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
table = await config.api.table.create(tableConfig)
|
table = await config.api.table.create(tableConfig)
|
||||||
config.table = table
|
config.table = table
|
||||||
config.datasource = datasource
|
config.datasource = datasource
|
||||||
|
@ -901,9 +907,9 @@ describe.each([
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("view 2.0", () => {
|
describe("view 2.0", () => {
|
||||||
function userTable(): Table {
|
async function userTable(): Promise<Table> {
|
||||||
return {
|
return {
|
||||||
name: "user",
|
name: `users_${generator.guid()}`,
|
||||||
type: "table",
|
type: "table",
|
||||||
primary: ["id"],
|
primary: ["id"],
|
||||||
schema: {
|
schema: {
|
||||||
|
@ -936,6 +942,7 @@ describe.each([
|
||||||
name: "jobTitle",
|
name: "jobTitle",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
...(await tableDatasourceConfig()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -949,7 +956,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(userTable())
|
const table = await config.createTable(await userTable())
|
||||||
const view = await config.api.viewV2.create({
|
const view = await config.api.viewV2.create({
|
||||||
tableId: table._id!,
|
tableId: table._id!,
|
||||||
schema: {
|
schema: {
|
||||||
|
@ -985,7 +992,7 @@ describe.each([
|
||||||
|
|
||||||
describe("patch", () => {
|
describe("patch", () => {
|
||||||
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(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.api.viewV2.create({
|
||||||
tableId,
|
tableId,
|
||||||
|
@ -1027,7 +1034,7 @@ describe.each([
|
||||||
|
|
||||||
describe("destroy", () => {
|
describe("destroy", () => {
|
||||||
it("should be able to delete a row", async () => {
|
it("should be able to delete a row", async () => {
|
||||||
const table = await config.createTable(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.api.viewV2.create({
|
||||||
tableId,
|
tableId,
|
||||||
|
@ -1037,7 +1044,7 @@ describe.each([
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const createdRow = await config.createRow()
|
const createdRow = await createRow()
|
||||||
const rowUsage = await getRowUsage()
|
const rowUsage = await getRowUsage()
|
||||||
const queryUsage = await getQueryUsage()
|
const queryUsage = await getQueryUsage()
|
||||||
|
|
||||||
|
@ -1052,7 +1059,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(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.api.viewV2.create({
|
||||||
tableId,
|
tableId,
|
||||||
|
@ -1063,9 +1070,9 @@ describe.each([
|
||||||
})
|
})
|
||||||
|
|
||||||
const rows = [
|
const rows = [
|
||||||
await config.createRow(),
|
await createRow(tableId),
|
||||||
await config.createRow(),
|
await createRow(tableId),
|
||||||
await config.createRow(),
|
await createRow(tableId),
|
||||||
]
|
]
|
||||||
const rowUsage = await getRowUsage()
|
const rowUsage = await getRowUsage()
|
||||||
const queryUsage = await getQueryUsage()
|
const queryUsage = await getQueryUsage()
|
||||||
|
|
Loading…
Reference in New Issue