Skip to content

Commit

Permalink
[WIP] Test accepting team invites
Browse files Browse the repository at this point in the history
  • Loading branch information
zoldar committed Jan 8, 2025
1 parent 7e37aa7 commit 8071c48
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
24 changes: 23 additions & 1 deletion test/plausible/site/memberships/accept_invitation_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,29 @@ defmodule Plausible.Site.Memberships.AcceptInvitationTest do
end
end

describe "accept_invitation/3 - invitations" do
describe "accept_invitation/3 - team invitations" do
test "converts an invitation into a membership" do
inviter = new_user()
invitee = new_user()
_site = new_site(owner: inviter)
team = team_of(inviter)

invitation = invite_member(team, invitee, inviter: inviter, role: :editor)

assert {:ok, _} =
AcceptInvitation.accept_invitation(invitation.invitation_id, invitee)

assert_team_membership(invitee, team, :editor)

assert_email_delivered_with(
to: [nil: inviter.email],
subject:
@subject_prefix <> "#{invitee.email} accepted your invitation to \"#{team.name}\" team"
)
end
end

describe "accept_invitation/3 - guest invitations" do
test "converts an invitation into a membership" do

Check failure on line 129 in test/plausible/site/memberships/accept_invitation_test.exs

View workflow job for this annotation

GitHub Actions / Build and test (test, postgres:15)

test accept_invitation/3 - guest invitations converts an invitation into a membership (Plausible.Site.Memberships.AcceptInvitationTest)

Check failure on line 129 in test/plausible/site/memberships/accept_invitation_test.exs

View workflow job for this annotation

GitHub Actions / Build and test (ce_test, postgres:16)

test accept_invitation/3 - guest invitations converts an invitation into a membership (Plausible.Site.Memberships.AcceptInvitationTest)
inviter = new_user()
invitee = new_user()
Expand Down
2 changes: 1 addition & 1 deletion test/support/teams/test.ex
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ defmodule Plausible.Teams.Test do
end

def assert_team_membership(user, team, role \\ :owner) do
if role == :owner do
if role != :guest do
assert membership =
Repo.get_by(Teams.Membership,
team_id: team.id,
Expand Down

0 comments on commit 8071c48

Please sign in to comment.