Fix jest issues

This commit is contained in:
Adria Navarro 2024-08-23 14:15:23 +02:00
parent 99bd057160
commit 8929b4a336
1 changed files with 122 additions and 122 deletions

View File

@ -2427,137 +2427,137 @@ describe.each([
}) })
}) })
describe("relationships", () => { // Upserting isn't yet supported in MSSQL or Oracle, see:
let tableId: string // https://github.com/knex/knex/pull/6050
!isMSSQL &&
!isOracle &&
describe("relationships", () => {
let tableId: string
let auxData: Row[] = [] let auxData: Row[] = []
beforeAll(async () => { beforeAll(async () => {
const aux2Table = await config.api.table.save(saveTableRequest()) const aux2Table = await config.api.table.save(saveTableRequest())
const aux2Data = await config.api.row.save(aux2Table._id!, {}) const aux2Data = await config.api.row.save(aux2Table._id!, {})
const auxTable = await config.api.table.save( const auxTable = await config.api.table.save(
saveTableRequest({ saveTableRequest({
primaryDisplay: "name", primaryDisplay: "name",
schema: { schema: {
name: { name: {
name: "name", name: "name",
type: FieldType.STRING, type: FieldType.STRING,
constraints: { presence: true }, constraints: { presence: true },
},
age: {
name: "age",
type: FieldType.NUMBER,
constraints: { presence: true },
},
address: {
name: "address",
type: FieldType.STRING,
constraints: { presence: true },
visible: false,
},
link: {
name: "link",
type: FieldType.LINK,
tableId: aux2Table._id!,
relationshipType: RelationshipType.MANY_TO_MANY,
fieldName: "fk_aux",
constraints: { presence: true },
},
formula: {
name: "formula",
type: FieldType.FORMULA,
formula: "{{ any }}",
constraints: { presence: true },
},
}, },
age: {
name: "age",
type: FieldType.NUMBER,
constraints: { presence: true },
},
address: {
name: "address",
type: FieldType.STRING,
constraints: { presence: true },
visible: false,
},
link: {
name: "link",
type: FieldType.LINK,
tableId: aux2Table._id!,
relationshipType: RelationshipType.MANY_TO_MANY,
fieldName: "fk_aux",
constraints: { presence: true },
},
formula: {
name: "formula",
type: FieldType.FORMULA,
formula: "{{ any }}",
constraints: { presence: true },
},
},
})
)
const auxTableId = auxTable._id!
for (const name of generator.unique(() => generator.name(), 10)) {
auxData.push(
await config.api.row.save(auxTableId, {
name,
age: generator.age(),
address: generator.address(),
link: [aux2Data],
}) })
) )
} const auxTableId = auxTable._id!
const table = await config.api.table.save( for (const name of generator.unique(() => generator.name(), 10)) {
saveTableRequest({ auxData.push(
schema: { await config.api.row.save(auxTableId, {
title: { name,
name: "title", age: generator.age(),
type: FieldType.STRING, address: generator.address(),
constraints: { presence: true }, link: [aux2Data],
}, })
relWithNoSchema: { )
name: "relWithNoSchema", }
relationshipType: RelationshipType.ONE_TO_MANY,
type: FieldType.LINK, const table = await config.api.table.save(
tableId: auxTableId, saveTableRequest({
fieldName: "fk_relWithNoSchema", schema: {
constraints: { presence: true }, title: {
}, name: "title",
relWithEmptySchema: { type: FieldType.STRING,
name: "relWithEmptySchema", constraints: { presence: true },
relationshipType: RelationshipType.ONE_TO_MANY, },
type: FieldType.LINK, relWithNoSchema: {
tableId: auxTableId, name: "relWithNoSchema",
fieldName: "fk_relWithEmptySchema", relationshipType: RelationshipType.ONE_TO_MANY,
constraints: { presence: true }, type: FieldType.LINK,
schema: {}, tableId: auxTableId,
}, fieldName: "fk_relWithNoSchema",
relWithFullSchema: { constraints: { presence: true },
name: "relWithFullSchema", },
relationshipType: RelationshipType.ONE_TO_MANY, relWithEmptySchema: {
type: FieldType.LINK, name: "relWithEmptySchema",
tableId: auxTableId, relationshipType: RelationshipType.ONE_TO_MANY,
fieldName: "fk_relWithFullSchema", type: FieldType.LINK,
constraints: { presence: true }, tableId: auxTableId,
schema: Object.keys(auxTable.schema).reduce( fieldName: "fk_relWithEmptySchema",
(acc, c) => ({ ...acc, [c]: { visible: true } }), constraints: { presence: true },
{} schema: {},
), },
}, relWithFullSchema: {
relWithHalfSchema: { name: "relWithFullSchema",
name: "relWithHalfSchema", relationshipType: RelationshipType.ONE_TO_MANY,
relationshipType: RelationshipType.ONE_TO_MANY, type: FieldType.LINK,
type: FieldType.LINK, tableId: auxTableId,
tableId: auxTableId, fieldName: "fk_relWithFullSchema",
fieldName: "fk_relWithHalfSchema", constraints: { presence: true },
constraints: { presence: true }, schema: Object.keys(auxTable.schema).reduce(
schema: { (acc, c) => ({ ...acc, [c]: { visible: true } }),
name: { visible: true }, {}
age: { visible: false, readonly: true }, ),
},
relWithHalfSchema: {
name: "relWithHalfSchema",
relationshipType: RelationshipType.ONE_TO_MANY,
type: FieldType.LINK,
tableId: auxTableId,
fieldName: "fk_relWithHalfSchema",
constraints: { presence: true },
schema: {
name: { visible: true },
age: { visible: false, readonly: true },
},
},
relWithIllegalSchema: {
name: "relWithIllegalSchema",
relationshipType: RelationshipType.ONE_TO_MANY,
type: FieldType.LINK,
tableId: auxTableId,
fieldName: "fk_relWithIllegalSchema",
constraints: { presence: true },
schema: {
name: { visible: true },
address: { visible: true },
unexisting: { visible: true },
},
}, },
}, },
relWithIllegalSchema: { })
name: "relWithIllegalSchema", )
relationshipType: RelationshipType.ONE_TO_MANY, tableId = table._id!
type: FieldType.LINK, })
tableId: auxTableId,
fieldName: "fk_relWithIllegalSchema",
constraints: { presence: true },
schema: {
name: { visible: true },
address: { visible: true },
unexisting: { visible: true },
},
},
},
})
)
tableId = table._id!
})
// Upserting isn't yet supported in MSSQL or Oracle, see:
// https://github.com/knex/knex/pull/6050
!isMSSQL &&
!isOracle &&
it.each([ it.each([
["get row", (row: Row) => config.api.row.get(tableId, row._id!)], ["get row", (row: Row) => config.api.row.get(tableId, row._id!)],
[ [
@ -2648,7 +2648,7 @@ describe.each([
) )
} }
) )
}) })
describe("Formula fields", () => { describe("Formula fields", () => {
let table: Table let table: Table