From 258fa175a09725af18b2bf41e53229670aab03bb Mon Sep 17 00:00:00 2001 From: Ry Racherbaumer Date: Fri, 13 Dec 2024 17:33:07 -0600 Subject: [PATCH] Add test --- bindings_node/test/Conversations.test.ts | 57 ++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/bindings_node/test/Conversations.test.ts b/bindings_node/test/Conversations.test.ts index 96114bd5d..ee40b431d 100644 --- a/bindings_node/test/Conversations.test.ts +++ b/bindings_node/test/Conversations.test.ts @@ -9,6 +9,9 @@ import { Conversation, GroupPermissionsOptions, Message, + MetadataField, + PermissionPolicy, + PermissionUpdateType, } from '../dist' const SLEEP_MS = 100 @@ -116,6 +119,60 @@ describe('Conversations', () => { }) }) + it('should update group permission policy', async () => { + const user1 = createUser() + const user2 = createUser() + const client1 = await createRegisteredClient(user1) + const client2 = await createRegisteredClient(user2) + const group = await client1 + .conversations() + .createGroup([user2.account.address]) + + expect(group.groupPermissions().policySet()).toEqual({ + addMemberPolicy: 0, + removeMemberPolicy: 2, + addAdminPolicy: 3, + removeAdminPolicy: 3, + updateGroupNamePolicy: 0, + updateGroupDescriptionPolicy: 0, + updateGroupImageUrlSquarePolicy: 0, + updateGroupPinnedFrameUrlPolicy: 0, + }) + + await group.updatePermissionPolicy( + PermissionUpdateType.AddAdmin, + PermissionPolicy.Deny + ) + + expect(group.groupPermissions().policySet()).toEqual({ + addMemberPolicy: 0, + removeMemberPolicy: 2, + addAdminPolicy: 1, + removeAdminPolicy: 3, + updateGroupNamePolicy: 0, + updateGroupDescriptionPolicy: 0, + updateGroupImageUrlSquarePolicy: 0, + updateGroupPinnedFrameUrlPolicy: 0, + }) + + await group.updatePermissionPolicy( + PermissionUpdateType.UpdateMetadata, + PermissionPolicy.Deny, + MetadataField.GroupName + ) + + expect(group.groupPermissions().policySet()).toEqual({ + addMemberPolicy: 0, + removeMemberPolicy: 2, + addAdminPolicy: 1, + removeAdminPolicy: 3, + updateGroupNamePolicy: 1, + updateGroupDescriptionPolicy: 0, + updateGroupImageUrlSquarePolicy: 0, + updateGroupPinnedFrameUrlPolicy: 0, + }) + }) + it('should create a dm group', async () => { const user1 = createUser() const user2 = createUser()