Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rygine committed Jan 13, 2025
1 parent 935d8ba commit 91565a6
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions sdks/browser-sdk/test/Conversation.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
ConsentState,
GroupPermissionsOptions,
MetadataField,
PermissionPolicy,
PermissionUpdateType,
Expand Down Expand Up @@ -413,8 +414,10 @@ describe.concurrent("Conversation", () => {
it("should update group permission policy", async () => {
const user1 = createUser();
const user2 = createUser();
const user3 = createUser();
const client1 = await createRegisteredClient(user1);
await createRegisteredClient(user2);
await createRegisteredClient(user3);
const conversation = await client1.conversations.newGroup([
user2.account.address,
]);
Expand Down Expand Up @@ -488,5 +491,43 @@ describe.concurrent("Conversation", () => {
updateGroupPinnedFrameUrlPolicy: 2,
updateMessageExpirationPolicy: 2,
});

const conversation2 = await client1.conversations.newGroup([], {
permissions: GroupPermissionsOptions.AdminOnly,
});

const permissions3 = await conversation2.permissions();
expect(permissions3.policySet).toEqual({
addMemberPolicy: 2,
removeMemberPolicy: 2,
addAdminPolicy: 3,
removeAdminPolicy: 3,
updateGroupNamePolicy: 2,
updateGroupDescriptionPolicy: 2,
updateGroupImageUrlSquarePolicy: 2,
updateGroupPinnedFrameUrlPolicy: 2,
updateMessageExpirationPolicy: 2,
});

// required when group has no members
await conversation2.sync();

await conversation2.updatePermission(
PermissionUpdateType.AddMember,
PermissionPolicy.Allow,
);

const permissions4 = await conversation2.permissions();
expect(permissions4.policySet).toEqual({
addMemberPolicy: 0,
removeMemberPolicy: 2,
addAdminPolicy: 3,
removeAdminPolicy: 3,
updateGroupNamePolicy: 2,
updateGroupDescriptionPolicy: 2,
updateGroupImageUrlSquarePolicy: 2,
updateGroupPinnedFrameUrlPolicy: 2,
updateMessageExpirationPolicy: 2,
});
});
});

0 comments on commit 91565a6

Please sign in to comment.