Merge pull request #9761 from Budibase/test/fix_foreigndata_pg_test
Test - Fix relation get test to test expected behaviour
This commit is contained in:
commit
b65e39bb22
|
@ -419,14 +419,16 @@ describe("row api - postgres", () => {
|
||||||
|
|
||||||
describe("given a row with relation data", () => {
|
describe("given a row with relation data", () => {
|
||||||
let row: Row
|
let row: Row
|
||||||
|
let foreignRow: Row
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
let [createdRow] = await populatePrimaryRows(1, {
|
let [createdRow] = await populatePrimaryRows(1, {
|
||||||
createForeignRow: true,
|
createForeignRow: true,
|
||||||
})
|
})
|
||||||
row = createdRow.row
|
row = createdRow.row
|
||||||
|
foreignRow = createdRow.foreignRow!
|
||||||
})
|
})
|
||||||
|
|
||||||
it("foreign key fields are not retrieved", async () => {
|
it("only foreign keys are retrieved", async () => {
|
||||||
const res = await getRow(primaryPostgresTable._id, row.id)
|
const res = await getRow(primaryPostgresTable._id, row.id)
|
||||||
|
|
||||||
expect(res.status).toBe(200)
|
expect(res.status).toBe(200)
|
||||||
|
@ -436,7 +438,15 @@ describe("row api - postgres", () => {
|
||||||
_id: expect.any(String),
|
_id: expect.any(String),
|
||||||
_rev: expect.any(String),
|
_rev: expect.any(String),
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(res.body.foreignField).toBeUndefined()
|
expect(res.body.foreignField).toBeUndefined()
|
||||||
|
|
||||||
|
expect(
|
||||||
|
res.body[`fk_${auxPostgresTable.name}_foreignField`]
|
||||||
|
).toBeDefined()
|
||||||
|
expect(res.body[`fk_${auxPostgresTable.name}_foreignField`]).toBe(
|
||||||
|
foreignRow.id
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue