Extra tests

This commit is contained in:
Adria Navarro 2024-08-29 12:30:16 +02:00
parent 275d358df9
commit 351ed643ce
1 changed files with 77 additions and 21 deletions

View File

@ -2434,6 +2434,7 @@ describe.each([
!isMSSQL && !isMSSQL &&
!isOracle && !isOracle &&
describe("relationships", () => { describe("relationships", () => {
let tableId: string
let viewId: string let viewId: string
let auxData: Row[] = [] let auxData: Row[] = []
@ -2549,7 +2550,7 @@ describe.each([
}, },
}) })
) )
const tableId = table._id! tableId = table._id!
const view = await config.api.viewV2.create({ const view = await config.api.viewV2.create({
name: generator.guid(), name: generator.guid(),
tableId, tableId,
@ -2597,20 +2598,6 @@ describe.each([
const testScenarios: [string, (row: Row) => Promise<Row> | Row][] = [ const testScenarios: [string, (row: Row) => Promise<Row> | Row][] = [
["get row", (row: Row) => config.api.row.get(viewId, row._id!)], ["get row", (row: Row) => config.api.row.get(viewId, row._id!)],
// [
// "fetch",
// async (row: Row) => {
// const rows = await config.api.row.fetch(tableId)
// return rows.find(r => r._id === row._id)
// },
// ],
// [
// "search",
// async (row: Row) => {
// const { rows } = await config.api.row.search(tableId)
// return rows.find(r => r._id === row._id)
// },
// ],
[ [
"from view search", "from view search",
async (row: Row) => { async (row: Row) => {
@ -2741,6 +2728,75 @@ describe.each([
) )
} }
) )
it.each([
[
"from table fetch",
async (row: Row) => {
const rows = await config.api.row.fetch(tableId)
return rows.find(r => r._id === row._id!)
},
],
[
"from table search",
async (row: Row) => {
const { rows } = await config.api.row.search(tableId)
return rows.find(r => r._id === row._id!)
},
],
])(
"does not enrich when fetching from the table (via %s)",
async (__, retrieveDelegate) => {
const otherRows = _.sampleSize(auxData, 5)
const row = await config.api.row.save(viewId, {
title: generator.word(),
relWithNoSchema: [otherRows[0]],
relWithEmptySchema: [otherRows[1]],
relWithFullSchema: [otherRows[2]],
relWithHalfSchema: [otherRows[3]],
relWithIllegalSchema: [otherRows[4]],
})
const retrieved = await retrieveDelegate(row)
expect(retrieved).toEqual(
expect.objectContaining({
title: row.title,
relWithNoSchema: [
{
_id: otherRows[0]._id,
primaryDisplay: otherRows[0].name,
},
],
relWithEmptySchema: [
{
_id: otherRows[1]._id,
primaryDisplay: otherRows[1].name,
},
],
relWithFullSchema: [
{
_id: otherRows[2]._id,
primaryDisplay: otherRows[2].name,
},
],
relWithHalfSchema: [
{
_id: otherRows[3]._id,
primaryDisplay: otherRows[3].name,
},
],
relWithIllegalSchema: [
{
_id: otherRows[4]._id,
primaryDisplay: otherRows[4].name,
},
],
})
)
}
)
}) })
describe("Formula fields", () => { describe("Formula fields", () => {