Skip to content

Commit

Permalink
test: fix coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
zvonimirr committed Apr 22, 2024
1 parent 41846a7 commit 094f961
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/tenantee_web/live/property_live/agreement_form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ defmodule TenanteeWeb.PropertyLive.Agreement do

~H"""
<.link class="text-gray-500" navigate={~p"/properties"}>
<.icon name="hero-arrow-left" /> Back to property card
<.icon name="hero-arrow-left" /> Back to properties
</.link>
<h1 class="text-3xl font-bold my-4">Create new agreement</h1>
Expand Down
2 changes: 1 addition & 1 deletion lib/tenantee_web/live/property_live/edit_agreement.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ defmodule TenanteeWeb.PropertyLive.EditAgreement do

~H"""
<.link class="text-gray-500" navigate={~p"/properties"}>
<.icon name="hero-arrow-left" /> Back to property card
<.icon name="hero-arrow-left" /> Back to properties
</.link>
<h1 class="text-3xl font-bold my-4">Edit agreement</h1>
<form
Expand Down
2 changes: 1 addition & 1 deletion lib/tenantee_web/live/property_live/view_agreement.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule TenanteeWeb.PropertyLive.ViewAgreement do
~H"""
<div>
<.link class="text-gray-500" navigate={~p"/properties"}>
<.icon name="hero-arrow-left" /> Back to property card
<.icon name="hero-arrow-left" /> Back to properties
</.link>
<div id="pdf-content">
Expand Down
33 changes: 33 additions & 0 deletions test/live/property/agreement_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,37 @@ defmodule TenanteeWeb.PropertyAgreementTest do

assert html =~ "agreement was updated successfully"
end

test "goes back to properties", %{conn: conn} do
{:ok, tenant} = generate_tenant()
{:ok, property} = generate_property()
Tenant.add_to_property(tenant.id, property.id)
{:ok, view, _html} = live(conn, "/properties")

{:ok, view, _html} =
view
|> element("abbr[title='Generate Agreement'] a")
|> render_click()
|> follow_redirect(conn)

{:ok, view, _html} =
view
|> form("#agreement-form", %{
tenant_name: "None",
rent_amount: 1000,
lease_term: 12,
start_date: "2022-01-01",
end_date: "2022-12-31",
security_deposit: 1000,
additional_terms: "No pets allowed"
})
|> render_submit()
|> follow_redirect(conn)

{:ok, _view, _html} =
view
|> element("a", "Back to properties")
|> render_click()
|> follow_redirect(conn)
end
end

0 comments on commit 094f961

Please sign in to comment.