continuing improvements
This commit is contained in:
parent
89d9bc0cce
commit
e00ecbf4c1
8 changed files with 121 additions and 166 deletions
test/shift73k_web/live
|
@ -5,9 +5,33 @@ defmodule Shift73kWeb.ShiftTemplateLiveTest do
|
|||
|
||||
alias Shift73k.ShiftTemplates
|
||||
|
||||
@create_attrs %{description: "some description", length_hours: 12, length_minutes: 42, location: "some location", start_time: ~T[14:00:00], subject: "some subject", timezone: "some timezone"}
|
||||
@update_attrs %{description: "some updated description", length_hours: 12, length_minutes: 43, location: "some updated location", start_time: ~T[15:01:01], subject: "some updated subject", timezone: "some updated timezone"}
|
||||
@invalid_attrs %{description: nil, length_hours: nil, length_minutes: nil, location: nil, start_time: nil, subject: nil, timezone: nil}
|
||||
@create_attrs %{
|
||||
description: "some description",
|
||||
length_hours: 12,
|
||||
length_minutes: 42,
|
||||
location: "some location",
|
||||
start_time: ~T[14:00:00],
|
||||
subject: "some subject",
|
||||
timezone: "some timezone"
|
||||
}
|
||||
@update_attrs %{
|
||||
description: "some updated description",
|
||||
length_hours: 12,
|
||||
length_minutes: 43,
|
||||
location: "some updated location",
|
||||
start_time: ~T[15:01:01],
|
||||
subject: "some updated subject",
|
||||
timezone: "some updated timezone"
|
||||
}
|
||||
@invalid_attrs %{
|
||||
description: nil,
|
||||
length_hours: nil,
|
||||
length_minutes: nil,
|
||||
location: nil,
|
||||
start_time: nil,
|
||||
subject: nil,
|
||||
timezone: nil
|
||||
}
|
||||
|
||||
defp fixture(:shift_template) do
|
||||
{:ok, shift_template} = ShiftTemplates.create_shift_template(@create_attrs)
|
||||
|
@ -54,7 +78,9 @@ defmodule Shift73kWeb.ShiftTemplateLiveTest do
|
|||
test "updates shift_template in listing", %{conn: conn, shift_template: shift_template} do
|
||||
{:ok, index_live, _html} = live(conn, Routes.shift_template_index_path(conn, :index))
|
||||
|
||||
assert index_live |> element("#shift_template-#{shift_template.id} a", "Edit") |> render_click() =~
|
||||
assert index_live
|
||||
|> element("#shift_template-#{shift_template.id} a", "Edit")
|
||||
|> render_click() =~
|
||||
"Edit Shift template"
|
||||
|
||||
assert_patch(index_live, Routes.shift_template_index_path(conn, :edit, shift_template))
|
||||
|
@ -76,41 +102,11 @@ defmodule Shift73kWeb.ShiftTemplateLiveTest do
|
|||
test "deletes shift_template in listing", %{conn: conn, shift_template: shift_template} do
|
||||
{:ok, index_live, _html} = live(conn, Routes.shift_template_index_path(conn, :index))
|
||||
|
||||
assert index_live |> element("#shift_template-#{shift_template.id} a", "Delete") |> render_click()
|
||||
assert index_live
|
||||
|> element("#shift_template-#{shift_template.id} a", "Delete")
|
||||
|> render_click()
|
||||
|
||||
refute has_element?(index_live, "#shift_template-#{shift_template.id}")
|
||||
end
|
||||
end
|
||||
|
||||
describe "Show" do
|
||||
setup [:create_shift_template]
|
||||
|
||||
test "displays shift_template", %{conn: conn, shift_template: shift_template} do
|
||||
{:ok, _show_live, html} = live(conn, Routes.shift_template_show_path(conn, :show, shift_template))
|
||||
|
||||
assert html =~ "Show Shift template"
|
||||
assert html =~ shift_template.description
|
||||
end
|
||||
|
||||
test "updates shift_template within modal", %{conn: conn, shift_template: shift_template} do
|
||||
{:ok, show_live, _html} = live(conn, Routes.shift_template_show_path(conn, :show, shift_template))
|
||||
|
||||
assert show_live |> element("a", "Edit") |> render_click() =~
|
||||
"Edit Shift template"
|
||||
|
||||
assert_patch(show_live, Routes.shift_template_show_path(conn, :edit, shift_template))
|
||||
|
||||
assert show_live
|
||||
|> form("#shift_template-form", shift_template: @invalid_attrs)
|
||||
|> render_change() =~ "can't be blank"
|
||||
|
||||
{:ok, _, html} =
|
||||
show_live
|
||||
|> form("#shift_template-form", shift_template: @update_attrs)
|
||||
|> render_submit()
|
||||
|> follow_redirect(conn, Routes.shift_template_show_path(conn, :show, shift_template))
|
||||
|
||||
assert html =~ "Shift template updated successfully"
|
||||
assert html =~ "some updated description"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue