diff --git a/apps/web/lib/pages/auth/verify-email.test.ts b/apps/web/lib/pages/auth/verify-email.test.ts index ad568abde0765c..113102ff8ad5d5 100644 --- a/apps/web/lib/pages/auth/verify-email.test.ts +++ b/apps/web/lib/pages/auth/verify-email.test.ts @@ -56,6 +56,75 @@ describe("moveUserToMatchingOrg", () => { ], }; + it("should always invite as MEMBER role, not an elevated role", async() => { + const org = { + id: "org123", + slug: "test-org", + requestedSlug: null + } + + organizationScenarios.organizationRepository.findUniqueNonPlatformOrgsByMatchingAutoAcceptEmail.fakeReturnOrganization( + org, + { email } + ) + + await moveUserToMatchingOrg({ email }) + + const call = vi.mocked(inviteMembersWithNoInviterPermissionCheck).mock.calls[0][0] + expect(call.invitations[0].role).toBe(MembershipRole.MEMBER) + }) + + it("should pass inviterName as null", async () => { + const org = { + id: "org123", + slug: "test-org", + requestedSlug: null, + }; + organizationScenarios.organizationRepository.findUniqueNonPlatformOrgsByMatchingAutoAcceptEmail.fakeReturnOrganization( + org, + { email } + ); + + await moveUserToMatchingOrg({ email }); + + const call = vi.mocked(inviteMembersWithNoInviterPermissionCheck).mock.calls[0][0]; + expect(call.inviterName).toBeNull(); + }); + + it("should pass creationSource as WEBAPP", async () => { + const org = { + id: "org123", + slug: "test-org", + requestedSlug: null, + }; + organizationScenarios.organizationRepository.findUniqueNonPlatformOrgsByMatchingAutoAcceptEmail.fakeReturnOrganization( + org, + { email } + ); + + await moveUserToMatchingOrg({ email }); + + const call = vi.mocked(inviteMembersWithNoInviterPermissionCheck).mock.calls[0][0]; + expect(call.creationSource).toBe(CreationSource.WEBAPP); + }); + + it("should pass exactly one invitation", async () => { + const org = { + id: "org123", + slug: "test-org", + requestedSlug: null, + }; + organizationScenarios.organizationRepository.findUniqueNonPlatformOrgsByMatchingAutoAcceptEmail.fakeReturnOrganization( + org, + { email } + ); + + await moveUserToMatchingOrg({ email }); + + const call = vi.mocked(inviteMembersWithNoInviterPermissionCheck).mock.calls[0][0]; + expect(call.invitations).toHaveLength(1); + }); + it("when organization has a slug and requestedSlug(slug is used)", async () => { const org = { id: "org123", @@ -98,4 +167,23 @@ describe("moveUserToMatchingOrg", () => { }); }); }); + + describe("error handling", () => { + it("should propagate errors thrown by inviteMembersWithNoInviterPermissionCheck", async () => { + const org = { + id: "org123", + slug: "test-org", + requestedSlug: null, + }; + organizationScenarios.organizationRepository.findUniqueNonPlatformOrgsByMatchingAutoAcceptEmail.fakeReturnOrganization( + org, + { email } + ); + + const error = new Error("Invite failed"); + vi.mocked(inviteMembersWithNoInviterPermissionCheck).mockRejectedValue(error); + + await expect(moveUserToMatchingOrg({ email })).rejects.toThrow("Invite failed"); + }); + }) }); diff --git a/packages/app-store/signal/config.json b/packages/app-store/signal/config.json index fe3bf5bd2f1295..6d0a44758dfe1a 100644 --- a/packages/app-store/signal/config.json +++ b/packages/app-store/signal/config.json @@ -6,7 +6,7 @@ "logo": "icon.svg", "url": "https://cal.com/", "variant": "messaging", - "categories": ["messaging"], + "categories": ["messaging","conferencing"], "publisher": "Cal.com, Inc.", "email": "support@cal.com", "description": "Schedule a chat with your guests or have a Signal Video call.",