Fix tests

This commit is contained in:
Adria Navarro 2024-10-02 17:39:35 +02:00
parent 576ebc997e
commit 39511a4e83
1 changed files with 48 additions and 63 deletions

View File

@ -70,14 +70,10 @@ describe.each([
let rows: Row[]
async function basicRelationshipTables(type: RelationshipType) {
const relatedTable = await createTable(
{
const relatedTable = await createTable({
name: { name: "name", type: FieldType.STRING },
},
generator.guid().substring(0, 10)
)
const tableId = await createTable(
{
})
const tableId = await createTable({
name: { name: "name", type: FieldType.STRING },
//@ts-ignore - API accepts this structure, will build out rest of definition
productCat: {
@ -90,9 +86,7 @@ describe.each([
type: "array",
},
},
},
generator.guid().substring(0, 10)
)
})
return {
relatedTable: await config.api.table.get(relatedTable),
tableId,
@ -138,9 +132,9 @@ describe.each([
}
})
async function createTable(schema: TableSchema, name?: string) {
async function createTable(schema: TableSchema) {
const table = await config.api.table.save(
tableForDatasource(datasource, { schema, name })
tableForDatasource(datasource, { schema })
)
return table._id!
}
@ -157,8 +151,8 @@ describe.each([
["table", createTable],
[
"view",
async (schema: TableSchema, name?: string) => {
const tableId = await createTable(schema, name)
async (schema: TableSchema) => {
const tableId = await createTable(schema)
const view = await config.api.viewV2.create({
tableId: tableId,
name: generator.guid(),
@ -2042,8 +2036,7 @@ describe.each([
isSql &&
describe("related formulas", () => {
beforeAll(async () => {
const arrayTable = await createTable(
{
const arrayTable = await createTable({
name: { name: "name", type: FieldType.STRING },
array: {
name: "array",
@ -2053,11 +2046,8 @@ describe.each([
inclusion: ["option 1", "option 2"],
},
},
},
"array"
)
tableOrViewId = await createTableOrView(
{
})
tableOrViewId = await createTableOrView({
relationship: {
type: FieldType.LINK,
relationshipType: RelationshipType.MANY_TO_ONE,
@ -2075,9 +2065,7 @@ describe.each([
`let array = [];$("relationship").forEach(rel => array = array.concat(rel.array));return array.sort().join(",")`
),
},
},
"main"
)
})
const arrayRows = await Promise.all([
config.api.row.save(arrayTable, {
name: "foo",
@ -2378,12 +2366,9 @@ describe.each([
let relatedTable: string, relatedRows: Row[]
beforeAll(async () => {
relatedTable = await createTable(
{
relatedTable = await createTable({
name: { name: "name", type: FieldType.STRING },
},
"productCategory"
)
})
tableOrViewId = await createTableOrView({
name: { name: "name", type: FieldType.STRING },
related1: {