test: adapt tests to reflect implementation details
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
5e0b6580ae
commit
9991291b2f
7 changed files with 98 additions and 71 deletions
|
|
@ -19,7 +19,7 @@ defmodule MvWeb.GroupLive.FormTest do
|
|||
test "form renders with empty fields", %{conn: conn} do
|
||||
{:ok, view, html} = live(conn, "/groups/new")
|
||||
|
||||
assert html =~ gettext("Create Group") || html =~ "create"
|
||||
assert html =~ gettext("Create Group") or html =~ "create" or html =~ "Gruppe erstellen"
|
||||
assert has_element?(view, "form")
|
||||
end
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ defmodule MvWeb.GroupLive.FormTest do
|
|||
}
|
||||
|
||||
view
|
||||
|> form("form", group: form_data)
|
||||
|> form("#group-form", group: form_data)
|
||||
|> render_submit()
|
||||
|
||||
# Should redirect to groups list or show page
|
||||
|
|
@ -47,7 +47,7 @@ defmodule MvWeb.GroupLive.FormTest do
|
|||
}
|
||||
|
||||
view
|
||||
|> form("form", group: form_data)
|
||||
|> form("#group-form", group: form_data)
|
||||
|> render_submit()
|
||||
|
||||
assert_redirect(view, "/groups")
|
||||
|
|
@ -62,10 +62,11 @@ defmodule MvWeb.GroupLive.FormTest do
|
|||
|
||||
html =
|
||||
view
|
||||
|> form("form", group: form_data)
|
||||
|> form("#group-form", group: form_data)
|
||||
|> render_submit()
|
||||
|
||||
assert html =~ gettext("required") || html =~ "name" || html =~ "error"
|
||||
assert html =~ gettext("required") or html =~ "name" or html =~ "error" or
|
||||
html =~ "erforderlich"
|
||||
end
|
||||
|
||||
test "shows error when name exceeds 100 characters", %{conn: conn} do
|
||||
|
|
@ -76,10 +77,10 @@ defmodule MvWeb.GroupLive.FormTest do
|
|||
|
||||
html =
|
||||
view
|
||||
|> form("form", group: form_data)
|
||||
|> form("#group-form", group: form_data)
|
||||
|> render_submit()
|
||||
|
||||
assert html =~ "100" || html =~ "length" || html =~ "error"
|
||||
assert html =~ "100" or html =~ "length" or html =~ "error" or html =~ "Länge"
|
||||
end
|
||||
|
||||
test "shows error when description exceeds 500 characters", %{conn: conn} do
|
||||
|
|
@ -94,10 +95,10 @@ defmodule MvWeb.GroupLive.FormTest do
|
|||
|
||||
html =
|
||||
view
|
||||
|> form("form", group: form_data)
|
||||
|> form("#group-form", group: form_data)
|
||||
|> render_submit()
|
||||
|
||||
assert html =~ "500" || html =~ "length" || html =~ "error"
|
||||
assert html =~ "500" or html =~ "length" or html =~ "error" or html =~ "Länge"
|
||||
end
|
||||
|
||||
test "shows error when name already exists (case-insensitive)", %{conn: conn} do
|
||||
|
|
@ -111,7 +112,7 @@ defmodule MvWeb.GroupLive.FormTest do
|
|||
|
||||
html =
|
||||
view
|
||||
|> form("form", group: form_data)
|
||||
|> form("#group-form", group: form_data)
|
||||
|> render_submit()
|
||||
|
||||
assert html =~ "already" || html =~ "taken" || html =~ "exists" || html =~ "error"
|
||||
|
|
@ -126,10 +127,10 @@ defmodule MvWeb.GroupLive.FormTest do
|
|||
|
||||
html =
|
||||
view
|
||||
|> form("form", group: form_data)
|
||||
|> form("#group-form", group: form_data)
|
||||
|> render_submit()
|
||||
|
||||
assert html =~ "error" || html =~ "invalid"
|
||||
assert html =~ "error" or html =~ "invalid" or html =~ "Fehler" or html =~ "ungültig"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -156,7 +157,7 @@ defmodule MvWeb.GroupLive.FormTest do
|
|||
}
|
||||
|
||||
view
|
||||
|> form("form", group: form_data)
|
||||
|> form("#group-form", group: form_data)
|
||||
|> render_submit()
|
||||
|
||||
# Verify slug didn't change by checking redirect URL or reloading
|
||||
|
|
@ -173,7 +174,7 @@ defmodule MvWeb.GroupLive.FormTest do
|
|||
}
|
||||
|
||||
view
|
||||
|> form("form", group: form_data)
|
||||
|> form("#group-form", group: form_data)
|
||||
|> render_submit()
|
||||
|
||||
assert_redirect(view, "/groups/#{group.slug}")
|
||||
|
|
@ -191,10 +192,11 @@ defmodule MvWeb.GroupLive.FormTest do
|
|||
|
||||
html =
|
||||
view
|
||||
|> form("form", group: form_data)
|
||||
|> form("#group-form", group: form_data)
|
||||
|> render_submit()
|
||||
|
||||
assert html =~ "already" || html =~ "taken" || html =~ "exists" || html =~ "error"
|
||||
assert html =~ "already" or html =~ "taken" or html =~ "exists" or html =~ "error" or
|
||||
html =~ "bereits" or html =~ "vergeben"
|
||||
end
|
||||
|
||||
test "slug is not displayed in form (immutable)", %{conn: conn} do
|
||||
|
|
@ -203,7 +205,7 @@ defmodule MvWeb.GroupLive.FormTest do
|
|||
{:ok, _view, html} = live(conn, "/groups/#{group.slug}/edit")
|
||||
|
||||
# Slug should not be in form (it's immutable)
|
||||
refute html =~ ~r/slug.*input/i || html =~ ~r/input.*slug/i
|
||||
refute html =~ ~r/slug.*input/i or html =~ ~r/input.*slug/i
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -216,7 +218,7 @@ defmodule MvWeb.GroupLive.FormTest do
|
|||
}
|
||||
|
||||
view
|
||||
|> form("form", group: form_data)
|
||||
|> form("#group-form", group: form_data)
|
||||
|> render_submit()
|
||||
|
||||
# Name should be trimmed
|
||||
|
|
@ -231,7 +233,7 @@ defmodule MvWeb.GroupLive.FormTest do
|
|||
}
|
||||
|
||||
view
|
||||
|> form("form", group: form_data)
|
||||
|> form("#group-form", group: form_data)
|
||||
|> render_submit()
|
||||
|
||||
assert_redirect(view, "/groups")
|
||||
|
|
@ -261,8 +263,8 @@ defmodule MvWeb.GroupLive.FormTest do
|
|||
test "unauthenticated users are redirected to login", %{conn: conn} do
|
||||
result = live(conn, "/groups/new")
|
||||
|
||||
assert match?({:error, {:redirect, %{to: "/auth/sign_in"}}}, result) ||
|
||||
match?({:error, {:live_redirect, %{to: "/auth/sign_in"}}}, result)
|
||||
assert match?({:error, {:redirect, %{to: "/sign-in"}}}, result) ||
|
||||
match?({:error, {:live_redirect, %{to: "/sign-in"}}}, result)
|
||||
end
|
||||
|
||||
test "user cannot edit group with non-existent slug", %{conn: conn} do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue