Clean tests
This commit is contained in:
parent
9b783e0804
commit
a5142088d9
|
@ -772,22 +772,36 @@ describe.each([
|
||||||
|
|
||||||
describe("fetchEnrichedRows", () => {
|
describe("fetchEnrichedRows", () => {
|
||||||
it("should allow enriching some linked rows", async () => {
|
it("should allow enriching some linked rows", async () => {
|
||||||
const { table, firstRow, secondRow } = await tenancy.doInTenant(
|
const { linkedTable, firstRow, secondRow } = await tenancy.doInTenant(
|
||||||
config.getTenantId(),
|
config.getTenantId(),
|
||||||
async () => {
|
async () => {
|
||||||
const table = await config.createLinkedTable()
|
const linkedTable = await config.createLinkedTable({
|
||||||
const firstRow = await config.createRow({
|
name: generator.guid(),
|
||||||
|
type: "table",
|
||||||
|
primary: ["id"],
|
||||||
|
schema: {
|
||||||
|
id: {
|
||||||
|
type: FieldType.AUTO,
|
||||||
|
name: "id",
|
||||||
|
autocolumn: true,
|
||||||
|
constraints: {
|
||||||
|
presence: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const firstRow = await createRow(table._id, {
|
||||||
name: "Test Contact",
|
name: "Test Contact",
|
||||||
description: "original description",
|
description: "original description",
|
||||||
tableId: table._id,
|
tableId: table._id,
|
||||||
})
|
})
|
||||||
const secondRow = await config.createRow({
|
const secondRow = await createRow(linkedTable._id, {
|
||||||
name: "Test 2",
|
name: "Test 2",
|
||||||
description: "og desc",
|
description: "og desc",
|
||||||
link: [{ _id: firstRow._id }],
|
link: [{ _id: firstRow._id }],
|
||||||
tableId: table._id,
|
tableId: linkedTable._id,
|
||||||
})
|
})
|
||||||
return { table, firstRow, secondRow }
|
return { linkedTable, firstRow, secondRow }
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
const rowUsage = await getRowUsage()
|
const rowUsage = await getRowUsage()
|
||||||
|
@ -795,16 +809,16 @@ describe.each([
|
||||||
|
|
||||||
// test basic enrichment
|
// test basic enrichment
|
||||||
const resBasic = await request
|
const resBasic = await request
|
||||||
.get(`/api/${table._id}/rows/${secondRow._id}`)
|
.get(`/api/${linkedTable._id}/rows/${secondRow._id}`)
|
||||||
.set(config.defaultHeaders())
|
.set(config.defaultHeaders())
|
||||||
.expect("Content-Type", /json/)
|
.expect("Content-Type", /json/)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
expect(resBasic.body.link[0]._id).toBe(firstRow._id)
|
expect(resBasic.body.link.length).toBe(1)
|
||||||
expect(resBasic.body.link[0].primaryDisplay).toBe("Test Contact")
|
expect(resBasic.body.link[0]).toEqual({ _id: firstRow._id })
|
||||||
|
|
||||||
// test full enrichment
|
// test full enrichment
|
||||||
const resEnriched = await request
|
const resEnriched = await request
|
||||||
.get(`/api/${table._id}/${secondRow._id}/enrich`)
|
.get(`/api/${linkedTable._id}/${secondRow._id}/enrich`)
|
||||||
.set(config.defaultHeaders())
|
.set(config.defaultHeaders())
|
||||||
.expect("Content-Type", /json/)
|
.expect("Content-Type", /json/)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
|
|
Loading…
Reference in New Issue