Rendering champions with win rates
ci / docker (push) Waiting to run

This commit is contained in:
2024-05-31 00:45:22 +02:00
parent 520c234a94
commit 22b79f5376
19 changed files with 853 additions and 9 deletions
@@ -0,0 +1,108 @@
defmodule LoLAnalyticsWeb.ChampionLiveTest do
use LoLAnalyticsWeb.ConnCase
import Phoenix.LiveViewTest
import LoLAnalytics.AccountsFixtures
@create_attrs %{}
@update_attrs %{}
@invalid_attrs %{}
defp create_champion(_) do
champion = champion_fixture()
%{champion: champion}
end
describe "Index" do
setup [:create_champion]
test "lists all champions", %{conn: conn} do
{:ok, _index_live, html} = live(conn, ~p"/champions")
assert html =~ "Listing Champions"
end
test "saves new champion", %{conn: conn} do
{:ok, index_live, _html} = live(conn, ~p"/champions")
assert index_live |> element("a", "New Champion") |> render_click() =~
"New Champion"
assert_patch(index_live, ~p"/champions/new")
assert index_live
|> form("#champion-form", champion: @invalid_attrs)
|> render_change() =~ "can't be blank"
assert index_live
|> form("#champion-form", champion: @create_attrs)
|> render_submit()
assert_patch(index_live, ~p"/champions")
html = render(index_live)
assert html =~ "Champion created successfully"
end
test "updates champion in listing", %{conn: conn, champion: champion} do
{:ok, index_live, _html} = live(conn, ~p"/champions")
assert index_live |> element("#champions-#{champion.id} a", "Edit") |> render_click() =~
"Edit Champion"
assert_patch(index_live, ~p"/champions/#{champion}/edit")
assert index_live
|> form("#champion-form", champion: @invalid_attrs)
|> render_change() =~ "can't be blank"
assert index_live
|> form("#champion-form", champion: @update_attrs)
|> render_submit()
assert_patch(index_live, ~p"/champions")
html = render(index_live)
assert html =~ "Champion updated successfully"
end
test "deletes champion in listing", %{conn: conn, champion: champion} do
{:ok, index_live, _html} = live(conn, ~p"/champions")
assert index_live |> element("#champions-#{champion.id} a", "Delete") |> render_click()
refute has_element?(index_live, "#champions-#{champion.id}")
end
end
describe "Show" do
setup [:create_champion]
test "displays champion", %{conn: conn, champion: champion} do
{:ok, _show_live, html} = live(conn, ~p"/champions/#{champion}")
assert html =~ "Show Champion"
end
test "updates champion within modal", %{conn: conn, champion: champion} do
{:ok, show_live, _html} = live(conn, ~p"/champions/#{champion}")
assert show_live |> element("a", "Edit") |> render_click() =~
"Edit Champion"
assert_patch(show_live, ~p"/champions/#{champion}/show/edit")
assert show_live
|> form("#champion-form", champion: @invalid_attrs)
|> render_change() =~ "can't be blank"
assert show_live
|> form("#champion-form", champion: @update_attrs)
|> render_submit()
assert_patch(show_live, ~p"/champions/#{champion}")
html = render(show_live)
assert html =~ "Champion updated successfully"
end
end
end
@@ -0,0 +1,108 @@
defmodule LoLAnalyticsWeb.RoleLiveTest do
use LoLAnalyticsWeb.ConnCase
import Phoenix.LiveViewTest
import LoLAnalytics.AccountsFixtures
@create_attrs %{}
@update_attrs %{}
@invalid_attrs %{}
defp create_role(_) do
role = role_fixture()
%{role: role}
end
describe "Index" do
setup [:create_role]
test "lists all roles", %{conn: conn} do
{:ok, _index_live, html} = live(conn, ~p"/roles")
assert html =~ "Listing Roles"
end
test "saves new role", %{conn: conn} do
{:ok, index_live, _html} = live(conn, ~p"/roles")
assert index_live |> element("a", "New Role") |> render_click() =~
"New Role"
assert_patch(index_live, ~p"/roles/new")
assert index_live
|> form("#role-form", role: @invalid_attrs)
|> render_change() =~ "can't be blank"
assert index_live
|> form("#role-form", role: @create_attrs)
|> render_submit()
assert_patch(index_live, ~p"/roles")
html = render(index_live)
assert html =~ "Role created successfully"
end
test "updates role in listing", %{conn: conn, role: role} do
{:ok, index_live, _html} = live(conn, ~p"/roles")
assert index_live |> element("#roles-#{role.id} a", "Edit") |> render_click() =~
"Edit Role"
assert_patch(index_live, ~p"/roles/#{role}/edit")
assert index_live
|> form("#role-form", role: @invalid_attrs)
|> render_change() =~ "can't be blank"
assert index_live
|> form("#role-form", role: @update_attrs)
|> render_submit()
assert_patch(index_live, ~p"/roles")
html = render(index_live)
assert html =~ "Role updated successfully"
end
test "deletes role in listing", %{conn: conn, role: role} do
{:ok, index_live, _html} = live(conn, ~p"/roles")
assert index_live |> element("#roles-#{role.id} a", "Delete") |> render_click()
refute has_element?(index_live, "#roles-#{role.id}")
end
end
describe "Show" do
setup [:create_role]
test "displays role", %{conn: conn, role: role} do
{:ok, _show_live, html} = live(conn, ~p"/roles/#{role}")
assert html =~ "Show Role"
end
test "updates role within modal", %{conn: conn, role: role} do
{:ok, show_live, _html} = live(conn, ~p"/roles/#{role}")
assert show_live |> element("a", "Edit") |> render_click() =~
"Edit Role"
assert_patch(show_live, ~p"/roles/#{role}/show/edit")
assert show_live
|> form("#role-form", role: @invalid_attrs)
|> render_change() =~ "can't be blank"
assert show_live
|> form("#role-form", role: @update_attrs)
|> render_submit()
assert_patch(show_live, ~p"/roles/#{role}")
html = render(show_live)
assert html =~ "Role updated successfully"
end
end
end