Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions apps/web/lib/pages/auth/verify-email.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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");
});
})
});
2 changes: 1 addition & 1 deletion packages/app-store/signal/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
Loading