-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Here, we still rely on "polymorphic" invitation structures, hence the "unified by id" helper. For now, it'll remain local unless we discover it's needed in the broader `Teams.Invitations` context. cc @zoldar
- Loading branch information
Showing
3 changed files
with
112 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ defmodule PlausibleWeb.Live.RegisterFormTest do | |
import Phoenix.LiveViewTest | ||
import Plausible.Test.Support.HTML | ||
|
||
use Plausible.Teams.Test | ||
|
||
alias Plausible.Auth.User | ||
alias Plausible.Repo | ||
|
||
|
@@ -138,16 +140,11 @@ defmodule PlausibleWeb.Live.RegisterFormTest do | |
|
||
describe "/register/invitation/:invitation_id" do | ||
setup do | ||
inviter = insert(:user) | ||
site = insert(:site, members: [inviter]) | ||
inviter = new_user() | ||
site = new_site(owner: inviter) | ||
|
||
invitation = | ||
insert(:invitation, | ||
site_id: site.id, | ||
inviter: inviter, | ||
email: "[email protected]", | ||
role: :admin | ||
) | ||
invite_guest(site, "[email protected]", role: :editor, inviter: inviter) | ||
|
||
{:ok, %{site: site, invitation: invitation, inviter: inviter}} | ||
end | ||
|
@@ -183,13 +180,14 @@ defmodule PlausibleWeb.Live.RegisterFormTest do | |
assert text_of_attr(password_input, "value") == "very-long-and-very-secret-123" | ||
assert text_of_attr(password_confirmation_input, "value") == "very-long-and-very-secret-123" | ||
|
||
assert %{ | ||
name: "Mary Sue", | ||
email: "[email protected]", | ||
password_hash: password_hash, | ||
# leaves trial_expiry_date null when invitation role is not :owner | ||
trial_expiry_date: nil | ||
} = Repo.get_by(User, email: "[email protected]") | ||
assert user = | ||
%{ | ||
name: "Mary Sue", | ||
email: "[email protected]", | ||
password_hash: password_hash | ||
} = Repo.get_by(User, email: "[email protected]") | ||
|
||
assert team_of(user) == nil | ||
|
||
assert String.length(password_hash) > 0 | ||
end | ||
|
@@ -201,28 +199,19 @@ defmodule PlausibleWeb.Live.RegisterFormTest do | |
} do | ||
mock_captcha_success() | ||
|
||
invitation = | ||
insert(:invitation, | ||
site_id: site.id, | ||
inviter: inviter, | ||
email: "[email protected]", | ||
role: :owner | ||
) | ||
invitation = invite_transfer(site, "[email protected]", inviter: inviter) | ||
|
||
lv = get_liveview(conn, "/register/invitation/#{invitation.invitation_id}") | ||
lv = get_liveview(conn, "/register/invitation/#{invitation.transfer_id}") | ||
|
||
type_into_input(lv, "user[name]", "Mary Sue") | ||
type_into_input(lv, "user[password]", "very-long-and-very-secret-123") | ||
type_into_input(lv, "user[password_confirmation]", "very-long-and-very-secret-123") | ||
|
||
_html = lv |> element("form") |> render_submit() | ||
|
||
assert %{ | ||
email: "[email protected]", | ||
trial_expiry_date: trial_expiry_date | ||
} = Repo.get_by(User, email: "[email protected]") | ||
assert user = Repo.get_by(User, email: "[email protected]") | ||
|
||
assert trial_expiry_date != nil | ||
assert team_of(user).trial_expiry_date != nil | ||
end | ||
|
||
test "always uses original email from the invitation", %{conn: conn, invitation: invitation} do | ||
|