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:
Adria Navarro 2023-02-21 15:13:05 +00:00 committed by GitHub
commit b65e39bb22
1 changed files with 11 additions and 1 deletions

View File

@ -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
)
}) })
}) })
}) })