From 2833e0558e38e3cb958e84edcf85d92e2a76138a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 10 May 2024 11:26:43 +0200 Subject: [PATCH] Test deprecated_multi_user bindings --- .../src/api/routes/tests/search.spec.ts | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index 455bd36a27..a1bf27df43 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -276,6 +276,14 @@ describe.each([ name: "multi user with session user", multi_user: JSON.stringify([...globalUsers, currentUser]), }, + { + name: "deprecated multi user", + deprecated_multi_user: JSON.stringify(globalUsers), + }, + { + name: "deprecated multi user with session user", + deprecated_multi_user: JSON.stringify([...globalUsers, currentUser]), + }, ] } @@ -304,11 +312,24 @@ describe.each([ type: FieldType.BB_REFERENCE_SINGLE, subtype: BBReferenceFieldSubType.USER, }, + deprecated_single_user: { + name: "deprecated_single_user", + type: FieldType.BB_REFERENCE_SINGLE, + subtype: BBReferenceFieldSubType.USER, + constraints: { + type: "array", + }, + }, multi_user: { name: "multi_user", type: FieldType.BB_REFERENCE, subtype: BBReferenceFieldSubType.USER, }, + deprecated_multi_user: { + name: "deprecated_multi_user", + type: FieldType.BB_REFERENCE, + subtype: BBReferenceFieldSubType.USERS, + }, }) await createRows(rows(config.getUser())) }) @@ -420,6 +441,23 @@ describe.each([ ]) }) + // TODO(samwho): fix for SQS + !isSqs && + it("should match the session user id in a deprecated multi user field", async () => { + const allUsers = [...globalUsers, config.getUser()].map((user: any) => { + return { _id: user._id } + }) + + await expectQuery({ + contains: { deprecated_multi_user: ["{{ [user]._id }}"] }, + }).toContainExactly([ + { + name: "deprecated multi user with session user", + deprecated_multi_user: allUsers, + }, + ]) + }) + // TODO(samwho): fix for SQS !isSqs && it("should not match the session user id in a multi user field", async () => { @@ -436,6 +474,22 @@ describe.each([ ]) }) + // TODO(samwho): fix for SQS + !isSqs && + it("should not match the session user id in a deprecated multi user field", async () => { + await expectQuery({ + notContains: { deprecated_multi_user: ["{{ [user]._id }}"] }, + notEmpty: { deprecated_multi_user: true }, + }).toContainExactly([ + { + name: "deprecated multi user", + deprecated_multi_user: globalUsers.map((user: any) => { + return { _id: user._id } + }), + }, + ]) + }) + it("should match the session user id and a user table row id using helpers, user binding and a static user id.", async () => { await expectQuery({ oneOf: {