Test with flags
This commit is contained in:
parent
c531084921
commit
1594fcc8c4
|
@ -40,6 +40,7 @@ import {
|
||||||
TableSchema,
|
TableSchema,
|
||||||
JsonFieldSubType,
|
JsonFieldSubType,
|
||||||
RowExportFormat,
|
RowExportFormat,
|
||||||
|
FeatureFlag,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { generator, mocks } from "@budibase/backend-core/tests"
|
import { generator, mocks } from "@budibase/backend-core/tests"
|
||||||
import _, { merge } from "lodash"
|
import _, { merge } from "lodash"
|
||||||
|
@ -95,7 +96,12 @@ describe.each([
|
||||||
let envCleanup: (() => void) | undefined
|
let envCleanup: (() => void) | undefined
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await withCoreEnv({ SQS_SEARCH_ENABLE: "true" }, () => config.init())
|
await withCoreEnv(
|
||||||
|
{
|
||||||
|
SQS_SEARCH_ENABLE: "true",
|
||||||
|
},
|
||||||
|
() => config.init()
|
||||||
|
)
|
||||||
if (isSqs) {
|
if (isSqs) {
|
||||||
envCleanup = setCoreEnv({
|
envCleanup = setCoreEnv({
|
||||||
SQS_SEARCH_ENABLE: "true",
|
SQS_SEARCH_ENABLE: "true",
|
||||||
|
@ -2558,7 +2564,7 @@ describe.each([
|
||||||
tableId = table._id!
|
tableId = table._id!
|
||||||
})
|
})
|
||||||
|
|
||||||
it.each([
|
const testScenarios: [string, (row: Row) => Promise<Row> | Row][] = [
|
||||||
["get row", (row: Row) => config.api.row.get(tableId, row._id!)],
|
["get row", (row: Row) => config.api.row.get(tableId, row._id!)],
|
||||||
[
|
[
|
||||||
"fetch",
|
"fetch",
|
||||||
|
@ -2591,8 +2597,75 @@ describe.each([
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
["from original saved row", (row: Row) => row],
|
["from original saved row", (row: Row) => row],
|
||||||
])(
|
]
|
||||||
|
|
||||||
|
it.each(testScenarios)(
|
||||||
"can retrieve rows with populated relationships (via %s)",
|
"can retrieve rows with populated relationships (via %s)",
|
||||||
|
async (__, retrieveDelegate) => {
|
||||||
|
const otherRows = _.sampleSize(auxData, 5)
|
||||||
|
await withCoreEnv(
|
||||||
|
{
|
||||||
|
TENANT_FEATURE_FLAGS: `*:${FeatureFlag.ENRICHED_RELATIONSHIPS}`,
|
||||||
|
},
|
||||||
|
async () => {
|
||||||
|
const row = await config.api.row.save(tableId, {
|
||||||
|
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,
|
||||||
|
name: otherRows[2].name,
|
||||||
|
age: otherRows[2].age,
|
||||||
|
id: otherRows[2].id,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
relWithHalfSchema: [
|
||||||
|
{
|
||||||
|
_id: otherRows[3]._id,
|
||||||
|
primaryDisplay: otherRows[3].name,
|
||||||
|
name: otherRows[3].name,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
relWithIllegalSchema: [
|
||||||
|
{
|
||||||
|
_id: otherRows[4]._id,
|
||||||
|
primaryDisplay: otherRows[4].name,
|
||||||
|
name: otherRows[4].name,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
it.each(testScenarios)(
|
||||||
|
"does not enrich relationships when not enabled (via %s)",
|
||||||
async (__, retrieveDelegate) => {
|
async (__, retrieveDelegate) => {
|
||||||
const otherRows = _.sampleSize(auxData, 5)
|
const otherRows = _.sampleSize(auxData, 5)
|
||||||
|
|
||||||
|
@ -2606,6 +2679,7 @@ describe.each([
|
||||||
})
|
})
|
||||||
|
|
||||||
const retrieved = await retrieveDelegate(row)
|
const retrieved = await retrieveDelegate(row)
|
||||||
|
|
||||||
expect(retrieved).toEqual(
|
expect(retrieved).toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
title: row.title,
|
title: row.title,
|
||||||
|
@ -2625,23 +2699,18 @@ describe.each([
|
||||||
{
|
{
|
||||||
_id: otherRows[2]._id,
|
_id: otherRows[2]._id,
|
||||||
primaryDisplay: otherRows[2].name,
|
primaryDisplay: otherRows[2].name,
|
||||||
name: otherRows[2].name,
|
|
||||||
age: otherRows[2].age,
|
|
||||||
id: otherRows[2].id,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
relWithHalfSchema: [
|
relWithHalfSchema: [
|
||||||
{
|
{
|
||||||
_id: otherRows[3]._id,
|
_id: otherRows[3]._id,
|
||||||
primaryDisplay: otherRows[3].name,
|
primaryDisplay: otherRows[3].name,
|
||||||
name: otherRows[3].name,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
relWithIllegalSchema: [
|
relWithIllegalSchema: [
|
||||||
{
|
{
|
||||||
_id: otherRows[4]._id,
|
_id: otherRows[4]._id,
|
||||||
primaryDisplay: otherRows[4].name,
|
primaryDisplay: otherRows[4].name,
|
||||||
name: otherRows[4].name,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue