Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mayel committed Aug 18, 2024
1 parent 1c3a229 commit 0ad7b86
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 28 deletions.
4 changes: 4 additions & 0 deletions test/controllers/confirm_email_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,17 @@ defmodule Bonfire.UI.Me.ConfirmEmailController.Test do
end

test "success" do
#  create a first user since confirmation otherwise not required
fake_user!()
conn = conn()
{:ok, account} = Bonfire.Me.Accounts.signup(signup_form())
conn = get(conn, "/signup/email/confirm/#{account.email.confirm_token}")
assert redirected_to(conn) == "/switch-user"
end

test "cannot confirm twice" do
#  create a first user since confirmation otherwise not required
fake_user!()
# needs template fix - no feedback
conn = conn()
{:ok, account} = Bonfire.Me.Accounts.signup(signup_form())
Expand Down
4 changes: 2 additions & 2 deletions test/controllers/create_user_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ defmodule Bonfire.UI.Me.CreateUserController.Test do
end

test "first user is autopromoted" do
Process.put([:bonfire, :env], "prod")
Process.put([:bonfire, :env], :prod)

on_exit(fn ->
Process.delete([:bonfire, :env])
Expand All @@ -201,7 +201,7 @@ defmodule Bonfire.UI.Me.CreateUserController.Test do
}

conn = post(conn, "/create-user", params)
# assert_raise RuntimeError, debug(floki_response(conn))
# debug(floki_response(conn))
conn = get(recycle(conn), "/dashboard")
doc = floki_response(conn)
assert [ok] = find_flash(doc)
Expand Down
20 changes: 0 additions & 20 deletions test/controllers/ghost_actor_test.exs

This file was deleted.

27 changes: 27 additions & 0 deletions test/controllers/local_user_ban_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
defmodule Bonfire.UI.Me.Boundaries.InstanceWideGhostActorTest do
use Bonfire.UI.Me.ConnCase, async: true
# import Bonfire.Boundaries.Debug
alias ActivityPub.Config

test "instance-wide ghosted local user cannot switch to that or any other identity" do
bob = fake_account!()
alice_user = fake_user!(bob)
bob_user = fake_user!(bob)
Bonfire.Boundaries.Blocks.block(bob_user, :ghost, :instance_wide)

conn = conn(account: bob)
assert catch_throw(get(conn, "/switch-user/#{bob_user.character.username}"))

assert catch_throw(get(conn, "/switch-user/#{alice_user.character.username}"))

# assert redirected_to(conn) == "/switch-user"
# assert catch_throw(get(recycle(conn), "/switch-user") |> warn("swwww"))
conn = get(recycle(conn), "/switch-user")
# doc = floki_response(conn)
assert redirected_to(conn) == "/login"
# conn = get(recycle(conn), "/error")
# doc = floki_response(conn)
# assert [err] = find_flash(doc)
# assert_flash_kind(err, :error)
end
end
6 changes: 3 additions & 3 deletions test/controllers/login_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ defmodule Bonfire.UI.Me.LoginController.Test do
}

conn = post(conn, "/login", params)
assert redirected_to(conn) == "/"
assert redirected_to(conn, 303) == "/"
end

test "with email for an account with multiple user identities" do
Expand All @@ -142,7 +142,7 @@ defmodule Bonfire.UI.Me.LoginController.Test do
}

conn = post(conn, "/login", params)
assert redirected_to(conn) == "/switch-user"
assert redirected_to(conn, 303) == "/switch-user"
end

test "with username" do
Expand All @@ -159,7 +159,7 @@ defmodule Bonfire.UI.Me.LoginController.Test do
}

conn = post(conn, "/login", params)
assert redirected_to(conn) == "/"
assert redirected_to(conn, 303) == "/"
end
end
end
6 changes: 6 additions & 0 deletions test/controllers/signup_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ defmodule Bonfire.UI.Me.SignupController.Test do
end

test "can signup" do
#  create a first user since confirmation otherwise not required
fake_user!()

conn = conn()
email = email()
password = password()
Expand All @@ -84,6 +87,8 @@ defmodule Bonfire.UI.Me.SignupController.Test do
end

test "can signup (with PhoenixTest)" do
#  create a first user since confirmation otherwise not required
fake_user!()
conn = conn()
email = email()
password = password()
Expand All @@ -92,6 +97,7 @@ defmodule Bonfire.UI.Me.SignupController.Test do
|> visit("/")
|> click_link("Create an account")
|> assert_has("#signup")
#  FIXME: button no longer exists?
|> assert_has("#signup button", text: "Accept")
|> fill_in("Email address", with: email)
|> fill_in("Choose a password (10 characters minimum)", with: password)
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/switch_user_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ defmodule Bonfire.UI.Me.SwitchUserController.Test do
conn = get(conn, "/switch-user/#{user.character.username}")
next = redirected_to(conn)
assert next == "/"
conn = get(conn, next)
conn = get(conn, "/dashboard")
assert get_session(conn, :current_user_id) == user.id
doc = floki_response(conn)
# debug(doc)
Expand Down
4 changes: 2 additions & 2 deletions test/views/settings_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ defmodule Bonfire.UI.Me.SettingsTest do
|> render_change(%{"ui" => %{"compact" => "true"}})

# force a refresh
{:ok, refreshed_view, _html} = live(conn, "/")
{:ok, refreshed_view, _html} = live(conn, "/dashboard")

# open_browser(refreshed_view)
assert refreshed_view
Expand Down Expand Up @@ -241,7 +241,7 @@ defmodule Bonfire.UI.Me.SettingsTest do
"Bonfire.UI.Common.BadgeCounterLive" => %{"highlight" => "true"}
})

{:ok, refreshed_view, _html} = live(conn, "/")
{:ok, refreshed_view, _html} = live(conn, "/dashboard")
# open_browser(refreshed_view)

auto_assert refreshed_view
Expand Down

0 comments on commit 0ad7b86

Please sign in to comment.