Fix for tests - row.spec.ts needs to pick correct table create.
This commit is contained in:
parent
d0f989597a
commit
983091e901
|
@ -138,14 +138,22 @@ describe.each([
|
|||
}
|
||||
: undefined
|
||||
|
||||
beforeAll(async () => {
|
||||
const tableConfig = generateTableConfig()
|
||||
async function createTable(
|
||||
cfg: Omit<SaveTableRequest, "sourceId" | "sourceType">,
|
||||
opts?: { skipReassigning: boolean }
|
||||
) {
|
||||
let table
|
||||
if (dsProvider) {
|
||||
table = await config.createExternalTable(tableConfig)
|
||||
table = await config.createExternalTable(cfg, opts)
|
||||
} else {
|
||||
table = await config.createTable(tableConfig)
|
||||
table = await config.createTable(cfg, opts)
|
||||
}
|
||||
return table
|
||||
}
|
||||
|
||||
beforeAll(async () => {
|
||||
const tableConfig = generateTableConfig()
|
||||
let table = await createTable(tableConfig)
|
||||
tableId = table._id!
|
||||
})
|
||||
|
||||
|
@ -174,7 +182,7 @@ describe.each([
|
|||
const queryUsage = await getQueryUsage()
|
||||
|
||||
const tableConfig = generateTableConfig()
|
||||
const newTable = await config.createTable(
|
||||
const newTable = await createTable(
|
||||
{
|
||||
...tableConfig,
|
||||
name: "TestTableAuto",
|
||||
|
@ -251,7 +259,7 @@ describe.each([
|
|||
})
|
||||
|
||||
it("should list all rows for given tableId", async () => {
|
||||
const table = await config.createTable(generateTableConfig(), {
|
||||
const table = await createTable(generateTableConfig(), {
|
||||
skipReassigning: true,
|
||||
})
|
||||
const tableId = table._id!
|
||||
|
@ -332,7 +340,7 @@ describe.each([
|
|||
inclusion: ["Alpha", "Beta", "Gamma"],
|
||||
},
|
||||
}
|
||||
const table = await config.createTable({
|
||||
const table = await createTable({
|
||||
name: "TestTable2",
|
||||
type: "table",
|
||||
schema: {
|
||||
|
@ -447,7 +455,7 @@ describe.each([
|
|||
|
||||
describe("view save", () => {
|
||||
it("views have extra data trimmed", async () => {
|
||||
const table = await config.createTable({
|
||||
const table = await createTable({
|
||||
type: "table",
|
||||
name: "orders",
|
||||
primary: ["OrderID"],
|
||||
|
@ -504,7 +512,7 @@ describe.each([
|
|||
describe("patch", () => {
|
||||
beforeAll(async () => {
|
||||
const tableConfig = generateTableConfig()
|
||||
table = await config.createTable(tableConfig)
|
||||
table = await createTable(tableConfig)
|
||||
})
|
||||
|
||||
it("should update only the fields that are supplied", async () => {
|
||||
|
@ -558,7 +566,7 @@ describe.each([
|
|||
describe("destroy", () => {
|
||||
beforeAll(async () => {
|
||||
const tableConfig = generateTableConfig()
|
||||
table = await config.createTable(tableConfig)
|
||||
table = await createTable(tableConfig)
|
||||
})
|
||||
|
||||
it("should be able to delete a row", async () => {
|
||||
|
@ -576,7 +584,7 @@ describe.each([
|
|||
describe("validate", () => {
|
||||
beforeAll(async () => {
|
||||
const tableConfig = generateTableConfig()
|
||||
table = await config.createTable(tableConfig)
|
||||
table = await createTable(tableConfig)
|
||||
})
|
||||
|
||||
it("should return no errors on valid row", async () => {
|
||||
|
@ -613,7 +621,7 @@ describe.each([
|
|||
describe("bulkDelete", () => {
|
||||
beforeAll(async () => {
|
||||
const tableConfig = generateTableConfig()
|
||||
table = await config.createTable(tableConfig)
|
||||
table = await createTable(tableConfig)
|
||||
})
|
||||
|
||||
it("should be able to delete a bulk set of rows", async () => {
|
||||
|
@ -697,7 +705,7 @@ describe.each([
|
|||
describe("fetchView", () => {
|
||||
beforeEach(async () => {
|
||||
const tableConfig = generateTableConfig()
|
||||
table = await config.createTable(tableConfig)
|
||||
table = await createTable(tableConfig)
|
||||
})
|
||||
|
||||
it("should be able to fetch tables contents via 'view'", async () => {
|
||||
|
@ -745,7 +753,7 @@ describe.each([
|
|||
describe("fetchEnrichedRows", () => {
|
||||
beforeAll(async () => {
|
||||
const tableConfig = generateTableConfig()
|
||||
table = await config.createTable(tableConfig)
|
||||
table = await createTable(tableConfig)
|
||||
})
|
||||
|
||||
it("should allow enriching some linked rows", async () => {
|
||||
|
@ -818,7 +826,7 @@ describe.each([
|
|||
describe("attachments", () => {
|
||||
beforeAll(async () => {
|
||||
const tableConfig = generateTableConfig()
|
||||
table = await config.createTable(tableConfig)
|
||||
table = await createTable(tableConfig)
|
||||
})
|
||||
|
||||
it("should allow enriching attachment rows", async () => {
|
||||
|
@ -849,7 +857,7 @@ describe.each([
|
|||
describe("exportData", () => {
|
||||
beforeAll(async () => {
|
||||
const tableConfig = generateTableConfig()
|
||||
table = await config.createTable(tableConfig)
|
||||
table = await createTable(tableConfig)
|
||||
})
|
||||
|
||||
it("should allow exporting all columns", async () => {
|
||||
|
@ -937,7 +945,7 @@ describe.each([
|
|||
|
||||
describe("create", () => {
|
||||
it("should persist a new row with only the provided view fields", async () => {
|
||||
const table = await config.createTable(await userTable())
|
||||
const table = await createTable(await userTable())
|
||||
const view = await config.createView({
|
||||
schema: {
|
||||
name: { visible: true },
|
||||
|
@ -972,7 +980,7 @@ describe.each([
|
|||
|
||||
describe("patch", () => {
|
||||
it("should update only the view fields for a row", async () => {
|
||||
const table = await config.createTable(await userTable())
|
||||
const table = await createTable(await userTable())
|
||||
const tableId = table._id!
|
||||
const view = await config.createView({
|
||||
schema: {
|
||||
|
@ -1013,7 +1021,7 @@ describe.each([
|
|||
|
||||
describe("destroy", () => {
|
||||
it("should be able to delete a row", async () => {
|
||||
const table = await config.createTable(await userTable())
|
||||
const table = await createTable(await userTable())
|
||||
const tableId = table._id!
|
||||
const view = await config.createView({
|
||||
schema: {
|
||||
|
@ -1037,7 +1045,7 @@ describe.each([
|
|||
})
|
||||
|
||||
it("should be able to delete multiple rows", async () => {
|
||||
const table = await config.createTable(await userTable())
|
||||
const table = await createTable(await userTable())
|
||||
const tableId = table._id!
|
||||
const view = await config.createView({
|
||||
schema: {
|
||||
|
@ -1102,7 +1110,7 @@ describe.each([
|
|||
}
|
||||
|
||||
it("returns empty rows from view when no schema is passed", async () => {
|
||||
const table = await config.createTable(await userTable())
|
||||
const table = await createTable(await userTable())
|
||||
const rows = await Promise.all(
|
||||
Array.from({ length: 10 }, () =>
|
||||
config.api.row.save(table._id!, { tableId: table._id })
|
||||
|
@ -1133,7 +1141,7 @@ describe.each([
|
|||
})
|
||||
|
||||
it("searching respects the view filters", async () => {
|
||||
const table = await config.createTable(await userTable())
|
||||
const table = await createTable(await userTable())
|
||||
|
||||
await Promise.all(
|
||||
Array.from({ length: 10 }, () =>
|
||||
|
@ -1257,7 +1265,7 @@ describe.each([
|
|||
|
||||
describe("sorting", () => {
|
||||
beforeAll(async () => {
|
||||
const table = await config.createTable(await userTable())
|
||||
const table = await createTable(await userTable())
|
||||
const users = [
|
||||
{ name: "Alice", age: 25 },
|
||||
{ name: "Bob", age: 30 },
|
||||
|
@ -1324,7 +1332,7 @@ describe.each([
|
|||
})
|
||||
|
||||
it("when schema is defined, defined columns and row attributes are returned", async () => {
|
||||
const table = await config.createTable(await userTable())
|
||||
const table = await createTable(await userTable())
|
||||
const rows = await Promise.all(
|
||||
Array.from({ length: 10 }, () =>
|
||||
config.api.row.save(table._id!, {
|
||||
|
@ -1355,7 +1363,7 @@ describe.each([
|
|||
})
|
||||
|
||||
it("views without data can be returned", async () => {
|
||||
const table = await config.createTable(await userTable())
|
||||
const table = await createTable(await userTable())
|
||||
|
||||
const createViewResponse = await config.createView()
|
||||
const response = await config.api.viewV2.search(createViewResponse.id)
|
||||
|
@ -1364,7 +1372,7 @@ describe.each([
|
|||
})
|
||||
|
||||
it("respects the limit parameter", async () => {
|
||||
await config.createTable(await userTable())
|
||||
await createTable(await userTable())
|
||||
await Promise.all(Array.from({ length: 10 }, () => config.createRow()))
|
||||
|
||||
const limit = generator.integer({ min: 1, max: 8 })
|
||||
|
@ -1379,7 +1387,7 @@ describe.each([
|
|||
})
|
||||
|
||||
it("can handle pagination", async () => {
|
||||
await config.createTable(await userTable())
|
||||
await createTable(await userTable())
|
||||
await Promise.all(Array.from({ length: 10 }, () => config.createRow()))
|
||||
|
||||
const createViewResponse = await config.createView()
|
||||
|
@ -1457,7 +1465,7 @@ describe.each([
|
|||
let tableId: string
|
||||
|
||||
beforeAll(async () => {
|
||||
await config.createTable(await userTable())
|
||||
await createTable(await userTable())
|
||||
await Promise.all(
|
||||
Array.from({ length: 10 }, () => config.createRow())
|
||||
)
|
||||
|
@ -1535,13 +1543,13 @@ describe.each([
|
|||
let o2mTable: Table
|
||||
let m2mTable: Table
|
||||
beforeAll(async () => {
|
||||
o2mTable = await config.createTable(
|
||||
o2mTable = await createTable(
|
||||
{ ...generateTableConfig(), name: "o2m" },
|
||||
{
|
||||
skipReassigning: true,
|
||||
}
|
||||
)
|
||||
m2mTable = await config.createTable(
|
||||
m2mTable = await createTable(
|
||||
{ ...generateTableConfig(), name: "m2m" },
|
||||
{
|
||||
skipReassigning: true,
|
||||
|
|
|
@ -71,7 +71,7 @@ type DefaultUserValues = {
|
|||
csrfToken: string
|
||||
}
|
||||
|
||||
interface TableToBuild extends Omit<Table, "sourceId" | "sourceType"> {
|
||||
export interface TableToBuild extends Omit<Table, "sourceId" | "sourceType"> {
|
||||
sourceId?: string
|
||||
sourceType?: TableSourceType
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue