Merge commit

This commit is contained in:
Dean 2024-05-02 09:24:05 +01:00
parent ac3b8478ec
commit f2cb90735b
1 changed files with 36 additions and 8 deletions

View File

@ -7,7 +7,7 @@ import {
AutoFieldSubType, AutoFieldSubType,
Datasource, Datasource,
EmptyFilterOption, EmptyFilterOption,
FieldTypeSubtypes, BBReferenceFieldSubType,
FieldType, FieldType,
RowSearchParams, RowSearchParams,
SearchFilters, SearchFilters,
@ -176,12 +176,13 @@ describe.each([
// Ensure all bindings resolve and perform as expected // Ensure all bindings resolve and perform as expected
describe("bindings", () => { describe("bindings", () => {
let globalUsers: any = [] let globalUsers: any = []
const future = new Date(serverTime.getTime()) let globalUserIds: any = []
const future = new Date(serverTime.getTime())
future.setDate(future.getDate() + 30) future.setDate(future.getDate() + 30)
const rows = (currentUser: User) => { const rows = (currentUser: User) => {
const globalUserIds = globalUsers.map((user: any) => { globalUserIds = globalUsers.map((user: any) => {
return user._id return user._id
}) })
return [ return [
@ -225,19 +226,19 @@ describe.each([
single_user: { single_user: {
name: "single_user", name: "single_user",
type: FieldType.BB_REFERENCE, type: FieldType.BB_REFERENCE,
subtype: FieldTypeSubtypes.BB_REFERENCE.USER, subtype: BBReferenceFieldSubType.USER,
}, },
multi_user: { multi_user: {
name: "multi_user", name: "multi_user",
type: FieldType.BB_REFERENCE, type: FieldType.BB_REFERENCE,
subtype: FieldTypeSubtypes.BB_REFERENCE.USERS, subtype: BBReferenceFieldSubType.USERS,
}, },
}) })
await createRows([...rows(config.getUser())]) await createRows([...rows(config.getUser())])
}) })
// !! Current User is auto generated per run // !! Current User is auto generated per run
it("should return all rows matching the session firstname", async () => { it("should return all rows matching the session user firstname", async () => {
await expectQuery({ await expectQuery({
equal: { name: "{{ [user].firstName }}" }, equal: { name: "{{ [user].firstName }}" },
}).toContainExactly([ }).toContainExactly([
@ -245,7 +246,7 @@ describe.each([
]) ])
}) })
it("should return all rows after search request datetime", async () => { it("should parse the date binding and return all rows after the resolved value", async () => {
await expectQuery({ await expectQuery({
range: { range: {
appointment: { appointment: {
@ -262,7 +263,7 @@ describe.each([
]) ])
}) })
it("should return all rows before search request datetime", async () => { it("should parse the date binding and return all rows before the resolved value", async () => {
await expectQuery({ await expectQuery({
range: { range: {
appointment: { appointment: {
@ -322,6 +323,33 @@ describe.each([
}, },
]) ])
}) })
it("should match the session user id in a multi user field", async () => {
await expectQuery({
contains: { multi_user: ["{{ [user]._id }}"] },
}).toContainExactly([
{
name: "multi user with session user",
multi_user: [{ _id: config.getUser()._id }],
},
])
})
it("should match the session user id in a multi user field", async () => {
await expectQuery({
notContains: { multi_user: ["{{ [user]._id }}"] },
notEmpty: { multi_user: true },
}).toContainExactly([
{
name: "multi user",
multi_user: globalUsers.map((user: any) => {
return {
_id: user._id,
}
}),
},
])
})
}) })
describe("strings", () => { describe("strings", () => {