Improve tests
This commit is contained in:
parent
2833e0558e
commit
fa2843b296
|
@ -26,11 +26,11 @@ tk.freeze(serverTime)
|
||||||
|
|
||||||
describe.each([
|
describe.each([
|
||||||
["lucene", undefined],
|
["lucene", undefined],
|
||||||
["sqs", undefined],
|
// ["sqs", undefined],
|
||||||
[DatabaseName.POSTGRES, getDatasource(DatabaseName.POSTGRES)],
|
// [DatabaseName.POSTGRES, getDatasource(DatabaseName.POSTGRES)],
|
||||||
[DatabaseName.MYSQL, getDatasource(DatabaseName.MYSQL)],
|
// [DatabaseName.MYSQL, getDatasource(DatabaseName.MYSQL)],
|
||||||
[DatabaseName.SQL_SERVER, getDatasource(DatabaseName.SQL_SERVER)],
|
// [DatabaseName.SQL_SERVER, getDatasource(DatabaseName.SQL_SERVER)],
|
||||||
[DatabaseName.MARIADB, getDatasource(DatabaseName.MARIADB)],
|
// [DatabaseName.MARIADB, getDatasource(DatabaseName.MARIADB)],
|
||||||
])("/api/:sourceId/search (%s)", (name, dsProvider) => {
|
])("/api/:sourceId/search (%s)", (name, dsProvider) => {
|
||||||
const isSqs = name === "sqs"
|
const isSqs = name === "sqs"
|
||||||
const isLucene = name === "lucene"
|
const isLucene = name === "lucene"
|
||||||
|
@ -268,6 +268,14 @@ describe.each([
|
||||||
name: "single user",
|
name: "single user",
|
||||||
single_user: JSON.stringify(globalUsers[0]),
|
single_user: JSON.stringify(globalUsers[0]),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "deprecated single user, session user",
|
||||||
|
deprecated_single_user: JSON.stringify([currentUser]),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "deprecated single user",
|
||||||
|
deprecated_single_user: JSON.stringify([globalUsers[0]]),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "multi user",
|
name: "multi user",
|
||||||
multi_user: JSON.stringify(globalUsers),
|
multi_user: JSON.stringify(globalUsers),
|
||||||
|
@ -314,7 +322,7 @@ describe.each([
|
||||||
},
|
},
|
||||||
deprecated_single_user: {
|
deprecated_single_user: {
|
||||||
name: "deprecated_single_user",
|
name: "deprecated_single_user",
|
||||||
type: FieldType.BB_REFERENCE_SINGLE,
|
type: FieldType.BB_REFERENCE,
|
||||||
subtype: BBReferenceFieldSubType.USER,
|
subtype: BBReferenceFieldSubType.USER,
|
||||||
constraints: {
|
constraints: {
|
||||||
type: "array",
|
type: "array",
|
||||||
|
@ -424,6 +432,17 @@ describe.each([
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should match a deprecated single user row by the session user id", async () => {
|
||||||
|
await expectQuery({
|
||||||
|
equal: { deprecated_single_user: "{{ [user]._id }}" },
|
||||||
|
}).toContainExactly([
|
||||||
|
{
|
||||||
|
name: "deprecated single user, session user",
|
||||||
|
deprecated_single_user: [{ _id: config.getUser()._id }],
|
||||||
|
},
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
// TODO(samwho): fix for SQS
|
// TODO(samwho): fix for SQS
|
||||||
!isSqs &&
|
!isSqs &&
|
||||||
it("should match the session user id in a multi user field", async () => {
|
it("should match the session user id in a multi user field", async () => {
|
||||||
|
@ -510,6 +529,26 @@ describe.each([
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should match the session user id and a user table row id using helpers, user binding and a static user id. (deprecated single user)", async () => {
|
||||||
|
await expectQuery({
|
||||||
|
oneOf: {
|
||||||
|
deprecated_single_user: [
|
||||||
|
"{{ default [user]._id '_empty_' }}",
|
||||||
|
globalUsers[0]._id,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}).toContainExactly([
|
||||||
|
{
|
||||||
|
name: "deprecated single user, session user",
|
||||||
|
deprecated_single_user: [{ _id: config.getUser()._id }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "deprecated single user",
|
||||||
|
deprecated_single_user: [{ _id: globalUsers[0]._id }],
|
||||||
|
},
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
it("should resolve 'default' helper to '_empty_' when binding resolves to nothing", async () => {
|
it("should resolve 'default' helper to '_empty_' when binding resolves to nothing", async () => {
|
||||||
await expectQuery({
|
await expectQuery({
|
||||||
oneOf: {
|
oneOf: {
|
||||||
|
@ -525,6 +564,22 @@ describe.each([
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should resolve 'default' helper to '_empty_' when binding resolves to nothing (deprecated single user)", async () => {
|
||||||
|
await expectQuery({
|
||||||
|
oneOf: {
|
||||||
|
deprecated_single_user: [
|
||||||
|
"{{ default [user]._idx '_empty_' }}",
|
||||||
|
globalUsers[0]._id,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}).toContainExactly([
|
||||||
|
{
|
||||||
|
name: "deprecated single user",
|
||||||
|
deprecated_single_user: [{ _id: globalUsers[0]._id }],
|
||||||
|
},
|
||||||
|
])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe.each([FieldType.STRING, FieldType.LONGFORM])("%s", () => {
|
describe.each([FieldType.STRING, FieldType.LONGFORM])("%s", () => {
|
||||||
|
|
|
@ -139,8 +139,10 @@ export function parse(rows: Rows, schema: TableSchema): Rows {
|
||||||
? new Date(columnData).toISOString()
|
? new Date(columnData).toISOString()
|
||||||
: columnData
|
: columnData
|
||||||
} else if (columnType === FieldType.BB_REFERENCE) {
|
} else if (columnType === FieldType.BB_REFERENCE) {
|
||||||
const parsedValues =
|
let parsedValues: { _id: string }[] = columnData || []
|
||||||
(!!columnData && parseCsvExport<{ _id: string }[]>(columnData)) || []
|
if (columnData) {
|
||||||
|
parsedValues = parseCsvExport<{ _id: string }[]>(columnData)
|
||||||
|
}
|
||||||
|
|
||||||
parsedRow[columnName] = parsedValues?.map(u => u._id)
|
parsedRow[columnName] = parsedValues?.map(u => u._id)
|
||||||
} else if (columnType === FieldType.BB_REFERENCE_SINGLE) {
|
} else if (columnType === FieldType.BB_REFERENCE_SINGLE) {
|
||||||
|
|
Loading…
Reference in New Issue