Compare commits
12 Commits
remove_gri
...
ci
| Author | SHA1 | Date | |
|---|---|---|---|
| 90b0eb71ed | |||
| 5eff7426b7 | |||
| 124e9f3c75 | |||
| 11c09ebf49 | |||
| cca9829a24 | |||
| 3f26bb457e | |||
| 24c6700f73 | |||
| 0a308ea429 | |||
| fd655391e0 | |||
| cacab2541d | |||
| 6c3cc84f7a | |||
| 96161f979b |
38
.build.yml
38
.build.yml
@@ -1,6 +1,34 @@
|
|||||||
image: alpine/edge
|
image: debian/stable
|
||||||
|
packages:
|
||||||
|
- build-essential
|
||||||
|
- git
|
||||||
|
- elixir
|
||||||
|
- erlang
|
||||||
|
secrets:
|
||||||
|
- bc0d4073-54cf-45ae-9542-6dd201b189e4
|
||||||
|
sources:
|
||||||
|
- git@git.broccoli.town:dp/wish
|
||||||
tasks:
|
tasks:
|
||||||
- say-hello: |
|
- setup: |
|
||||||
echo hello
|
cd wish
|
||||||
- say-world: |
|
mix local.hex --force
|
||||||
echo world
|
mix local.rebar --force
|
||||||
|
mix deps.get
|
||||||
|
- test: |
|
||||||
|
cd wish
|
||||||
|
mix test
|
||||||
|
- deploy: |
|
||||||
|
if [ $GIT_REF = "refs/heads/ci" ]; then
|
||||||
|
curl -L https://fly.io/install.sh | sh
|
||||||
|
export FLYCTL_INSTALL="/home/build/.fly"
|
||||||
|
export PATH="$FLYCTL_INSTALL/bin:$PATH"
|
||||||
|
|
||||||
|
set +x
|
||||||
|
export FLY_ACCESS_TOKEN=$(cat ~/.fly_secret_key)
|
||||||
|
set -x
|
||||||
|
|
||||||
|
cd wish
|
||||||
|
flyctl status
|
||||||
|
else
|
||||||
|
echo "nothing to do"
|
||||||
|
fi
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ defmodule Wish.Wishlist.Item do
|
|||||||
field :desire, :integer
|
field :desire, :integer
|
||||||
field :image_url, :string
|
field :image_url, :string
|
||||||
field :price, :integer
|
field :price, :integer
|
||||||
field :visible, :boolean
|
field :visible, :boolean, default: true
|
||||||
|
|
||||||
timestamps(type: :utc_datetime)
|
timestamps(type: :utc_datetime)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<.link patch={~p"/"}>
|
<.link href={~p"/"}>
|
||||||
<.icon name="hero-arrow-left" /> Back to list
|
<.icon name="hero-arrow-left" /> Back to list
|
||||||
</.link>
|
</.link>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,13 @@ defmodule WishWeb.HomeLive.Index do
|
|||||||
use Phoenix.Component
|
use Phoenix.Component
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def mount(_params, _session, socket) do
|
def mount(_params, session, socket) do
|
||||||
|
grid? =
|
||||||
|
case Map.get(session, "user_display", "grid") do
|
||||||
|
"grid" -> true
|
||||||
|
_ -> false
|
||||||
|
end
|
||||||
|
|
||||||
items =
|
items =
|
||||||
if socket.assigns.current_user do
|
if socket.assigns.current_user do
|
||||||
Wishlist.list_visible_items()
|
Wishlist.list_visible_items()
|
||||||
@@ -13,7 +19,12 @@ defmodule WishWeb.HomeLive.Index do
|
|||||||
Wishlist.list_available_items()
|
Wishlist.list_available_items()
|
||||||
end
|
end
|
||||||
|
|
||||||
{:ok, assign(socket, :items, items) |> assign(:hidden, false)}
|
{:ok, assign(socket, :items, items) |> assign(:grid, grid?) |> assign(:hidden, false)}
|
||||||
|
end
|
||||||
|
|
||||||
|
@impl true
|
||||||
|
def handle_event("toggle_view_state", _, socket) do
|
||||||
|
{:noreply, assign(socket, :grid, !socket.assigns.grid)}
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
@@ -51,7 +62,7 @@ defmodule WishWeb.HomeLive.Index do
|
|||||||
~H"""
|
~H"""
|
||||||
<div
|
<div
|
||||||
id={"dropdown-#{@item.id}"}
|
id={"dropdown-#{@item.id}"}
|
||||||
class="absolute z-10 w-auto bg-purple-100 origin-top right-0 whitespace-nowrap border border-black"
|
class="absolute z-10 w-40 bg-purple-100 origin-top right-0 whitespace-nowrap border border-black"
|
||||||
phx-click-away={JS.hide()}
|
phx-click-away={JS.hide()}
|
||||||
hidden
|
hidden
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,7 +1,19 @@
|
|||||||
<.header>
|
<.header>
|
||||||
Daniel's Wishlist
|
Daniel's Wishlist
|
||||||
|
<:actions>
|
||||||
|
<.button phx-click={
|
||||||
|
JS.push("toggle_view_state")
|
||||||
|
|> JS.dispatch("toggle_view_state", detail: %{"grid" => !@grid})
|
||||||
|
}>
|
||||||
|
<%= if @grid do %>
|
||||||
|
List View
|
||||||
|
<% else %>
|
||||||
|
Grid View
|
||||||
|
<% end %>
|
||||||
|
</.button>
|
||||||
|
</:actions>
|
||||||
<:actions :if={!@current_user}>
|
<:actions :if={!@current_user}>
|
||||||
<.button phx-click={JS.push("toggle_hidden_items")} id="showhide-button" phx-throttle="300">
|
<.button phx-click={JS.push("toggle_hidden_items")}>
|
||||||
<%= if @hidden do %>
|
<%= if @hidden do %>
|
||||||
Hide
|
Hide
|
||||||
<% else %>
|
<% else %>
|
||||||
@@ -12,16 +24,81 @@
|
|||||||
</:actions>
|
</:actions>
|
||||||
</.header>
|
</.header>
|
||||||
|
|
||||||
|
<%= if @grid do %>
|
||||||
|
<div class="grid grid-cols-3 gap-4 mt-4" id="items-grid">
|
||||||
|
<div
|
||||||
|
:for={item <- @items}
|
||||||
|
phx-click={JS.navigate(~p"/details/#{item}")}
|
||||||
|
class="p-3 bg-purple-200 hover:bg-purple-300 active:bg-purple-400 border-2 border-black
|
||||||
|
hover:shadow-sharp hover:-translate-x-0.5 hover:-translate-y-0.5 transition
|
||||||
|
cursor-pointer"
|
||||||
|
>
|
||||||
|
<div class="aspect-square relative flex flex-col justify-center bg-white border border-black">
|
||||||
|
<img
|
||||||
|
:if={item.image_url}
|
||||||
|
src={item.image_url}
|
||||||
|
alt={item.title}
|
||||||
|
height="224"
|
||||||
|
width="224"
|
||||||
|
class="rounded"
|
||||||
|
/>
|
||||||
|
<%= if item.received && !@current_user do %>
|
||||||
|
<div class="bg-red-400 text-white absolute w-full h-7 bottom-0">
|
||||||
|
<.icon name="hero-check-circle" />Received
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-row justify-between mt-1 font-display">
|
||||||
|
<%= item.title %>
|
||||||
|
<div phx-click={JS.toggle(to: "#dropdown-#{item.id}")} class="relative">
|
||||||
|
<div class="w-7 h-7 rounded-full hover:bg-purple-400 active:bg-purple-500">
|
||||||
|
<.icon name="hero-ellipsis-vertical" class="w-full h-full" />
|
||||||
|
</div>
|
||||||
|
<.dropdown item={item} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<%= if item.price do %>
|
||||||
|
<div>
|
||||||
|
<div class="text-sm opacity-60">
|
||||||
|
Price:
|
||||||
|
</div>
|
||||||
|
<div class="text-sm">
|
||||||
|
~£<%= item.price %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<div>
|
||||||
|
<div class="text-sm opacity-60">
|
||||||
|
Priority:
|
||||||
|
</div>
|
||||||
|
<span>
|
||||||
|
<%= for _ <- 1..item.desire do %>
|
||||||
|
<.icon name="hero-star" class="bg-red-500 text-red-500" />
|
||||||
|
<% end %>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<%= if item.description do %>
|
||||||
|
<div>
|
||||||
|
<div class="text-sm opacity-60">
|
||||||
|
Description:
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<%= item.description %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% else %>
|
||||||
<div class="flex flex-col mt-4 space-y-4">
|
<div class="flex flex-col mt-4 space-y-4">
|
||||||
<div
|
<div
|
||||||
:for={item <- @items}
|
:for={item <- @items}
|
||||||
class="grid grid-cols-12 gap-3 p-3 bg-purple-200
|
class="grid grid-cols-6 grid-rows-4 gap-3 h-56 p-3 bg-purple-200 hover:bg-purple-300 active:bg-purple-400 border-2 border-black
|
||||||
hover:bg-purple-300 active:bg-purple-400 border-2 border-black
|
hover:shadow-sharp hover:-translate-x-0.5 hover:-translate-y-0.5 transition
|
||||||
hover:shadow-sharp hover:-translate-x-0.5 hover:-translate-y-0.5
|
cursor-pointer"
|
||||||
transition cursor-pointer"
|
|
||||||
phx-click={JS.navigate(~p"/details/#{item}")}
|
phx-click={JS.navigate(~p"/details/#{item}")}
|
||||||
>
|
>
|
||||||
<div class="relative col-span-4 flex flex-col justify-center max-h-full h-full bg-white border border-black">
|
<div class="relative col-span-2 flex flex-col justify-center max-h-full h-full row-span-4 bg-white border border-black">
|
||||||
<img :if={item.image_url} src={item.image_url} alt={item.title} class="max-h-full" />
|
<img :if={item.image_url} src={item.image_url} alt={item.title} class="max-h-full" />
|
||||||
<%= if item.received && !@current_user do %>
|
<%= if item.received && !@current_user do %>
|
||||||
<div class="absolute bg-red-400 text-xs text-white w-full h-7 bottom-0">
|
<div class="absolute bg-red-400 text-xs text-white w-full h-7 bottom-0">
|
||||||
@@ -29,10 +106,16 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-span-7 flex flex-col">
|
<div class="col-span-3 text-lg font-display">
|
||||||
<div class="text-lg font-display">
|
|
||||||
<%= item.title %>
|
<%= item.title %>
|
||||||
</div>
|
</div>
|
||||||
|
<div phx-click={JS.toggle(to: "#dropdown-#{item.id}")} class="relative">
|
||||||
|
<.icon
|
||||||
|
name="hero-ellipsis-vertical"
|
||||||
|
class="w-7 h-7 rounded-full hover:bg-purple-400 active:bg-purple-500"
|
||||||
|
/>
|
||||||
|
<.dropdown item={item} />
|
||||||
|
</div>
|
||||||
<%= if item.price do %>
|
<%= if item.price do %>
|
||||||
<div class="col-span-3">
|
<div class="col-span-3">
|
||||||
<div class="text-sm opacity-60">
|
<div class="text-sm opacity-60">
|
||||||
@@ -64,14 +147,5 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-span-1">
|
|
||||||
<div phx-click={JS.toggle(to: "#dropdown-#{item.id}")} class="relative float-right mt-1">
|
|
||||||
<.icon
|
|
||||||
name="hero-ellipsis-vertical"
|
|
||||||
class="w-7 h-7 rounded-full hover:bg-purple-400 active:bg-purple-500"
|
|
||||||
/>
|
|
||||||
<.dropdown item={item} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|||||||
@@ -10,14 +10,20 @@
|
|||||||
<.table
|
<.table
|
||||||
id="items"
|
id="items"
|
||||||
rows={@streams.items}
|
rows={@streams.items}
|
||||||
row_click={fn {_id, item} -> JS.navigate(~p"/items/#{item}/show/edit") end}
|
row_click={fn {_id, item} -> JS.patch(~p"/items/#{item}/show/edit") end}
|
||||||
>
|
>
|
||||||
<:col :let={{_id, item}} label="Title"><%= item.title %></:col>
|
<:col :let={{_id, item}} label="Title"><%= item.title %></:col>
|
||||||
<:col :let={{_id, item}} label="Description"><%= item.description %></:col>
|
<:col :let={{_id, item}} label="Description"><%= item.description %></:col>
|
||||||
<:col :let={{_id, item}} label="Price"><%= item.price %></:col>
|
<:col :let={{_id, item}} label="Price"><%= item.price %></:col>
|
||||||
<:col :let={{_id, item}} label="Desire"><%= item.desire %></:col>
|
<:col :let={{_id, item}} label="Desire"><%= item.desire %></:col>
|
||||||
|
<:action :let={{_id, item}}>
|
||||||
|
<div class="sr-only">
|
||||||
|
<.link patch={~p"/items/#{item.id}/show/edit"}>Edit</.link>
|
||||||
|
</div>
|
||||||
|
</:action>
|
||||||
<:action :let={{id, item}}>
|
<:action :let={{id, item}}>
|
||||||
<.link
|
<.link
|
||||||
|
id={"delete-#{id}"}
|
||||||
phx-click={JS.push("delete", value: %{id: item.id}) |> hide("##{id}")}
|
phx-click={JS.push("delete", value: %{id: item.id}) |> hide("##{id}")}
|
||||||
data-confirm="Are you sure?"
|
data-confirm="Are you sure?"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -40,9 +40,12 @@ defmodule WishWeb.ItemLive.Show do
|
|||||||
defp save_item(socket, :edit, item_params) do
|
defp save_item(socket, :edit, item_params) do
|
||||||
case Wishlist.update_item(socket.assigns.item, item_params) do
|
case Wishlist.update_item(socket.assigns.item, item_params) do
|
||||||
{:ok, item} ->
|
{:ok, item} ->
|
||||||
|
changeset = Wishlist.change_item(item)
|
||||||
|
|
||||||
{:noreply,
|
{:noreply,
|
||||||
socket
|
socket
|
||||||
|> assign(:item, item)
|
|> assign(:item, item)
|
||||||
|
|> assign_form(changeset)
|
||||||
|> put_flash(:info, "Item updated successfully")}
|
|> put_flash(:info, "Item updated successfully")}
|
||||||
|
|
||||||
{:error, %Ecto.Changeset{} = changeset} ->
|
{:error, %Ecto.Changeset{} = changeset} ->
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ defmodule WishWeb.Router do
|
|||||||
|
|
||||||
live_session :redirect_if_user_is_authenticated,
|
live_session :redirect_if_user_is_authenticated,
|
||||||
on_mount: [{WishWeb.UserAuth, :redirect_if_user_is_authenticated}] do
|
on_mount: [{WishWeb.UserAuth, :redirect_if_user_is_authenticated}] do
|
||||||
# live "/users/register", UserRegistrationLive, :new
|
live "/users/register", UserRegistrationLive, :new
|
||||||
live "/users/log_in", UserLoginLive, :new
|
live "/users/log_in", UserLoginLive, :new
|
||||||
live "/users/reset_password", UserForgotPasswordLive, :new
|
live "/users/reset_password", UserForgotPasswordLive, :new
|
||||||
live "/users/reset_password/:token", UserResetPasswordLive, :edit
|
live "/users/reset_password/:token", UserResetPasswordLive, :edit
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
defmodule WishWeb.PageControllerTest do
|
|
||||||
use WishWeb.ConnCase
|
|
||||||
|
|
||||||
test "GET /", %{conn: conn} do
|
|
||||||
conn = get(conn, ~p"/")
|
|
||||||
assert html_response(conn, 200) =~ "Peace of mind from prototype to production"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
26
test/wish_web/live/home_live_test.exs
Normal file
26
test/wish_web/live/home_live_test.exs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
defmodule WishWeb.HomeLiveTest do
|
||||||
|
use WishWeb.ConnCase
|
||||||
|
|
||||||
|
import Phoenix.LiveViewTest
|
||||||
|
import Wish.WishlistFixtures
|
||||||
|
import Wish.AccountsFixtures
|
||||||
|
|
||||||
|
defp create_item(_) do
|
||||||
|
item = item_fixture()
|
||||||
|
%{item: item}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "Index" do
|
||||||
|
setup [:create_item]
|
||||||
|
|
||||||
|
test "lists all items", %{conn: conn, item: item} do
|
||||||
|
{:ok, _index_live, html} =
|
||||||
|
conn
|
||||||
|
|> log_in_user(user_fixture())
|
||||||
|
|> live(~p"/")
|
||||||
|
|
||||||
|
assert html =~ "Daniel's Wishlist"
|
||||||
|
assert html =~ item.description
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -3,10 +3,21 @@ defmodule WishWeb.ItemLiveTest do
|
|||||||
|
|
||||||
import Phoenix.LiveViewTest
|
import Phoenix.LiveViewTest
|
||||||
import Wish.WishlistFixtures
|
import Wish.WishlistFixtures
|
||||||
|
import Wish.AccountsFixtures
|
||||||
|
|
||||||
@create_attrs %{description: "some description", title: "some title", url: "some url", received: true, desire: 42}
|
@create_attrs %{
|
||||||
@update_attrs %{description: "some updated description", title: "some updated title", url: "some updated url", received: false, desire: 43}
|
description: "some description",
|
||||||
@invalid_attrs %{description: nil, title: nil, url: nil, received: false, desire: nil}
|
title: "some title",
|
||||||
|
url: "some url",
|
||||||
|
desire: 2
|
||||||
|
}
|
||||||
|
@update_attrs %{
|
||||||
|
description: "some updated description",
|
||||||
|
title: "some updated title",
|
||||||
|
url: "some updated url",
|
||||||
|
desire: 3
|
||||||
|
}
|
||||||
|
@invalid_attrs %{description: nil, title: nil, url: nil, desire: nil}
|
||||||
|
|
||||||
defp create_item(_) do
|
defp create_item(_) do
|
||||||
item = item_fixture()
|
item = item_fixture()
|
||||||
@@ -17,14 +28,20 @@ defmodule WishWeb.ItemLiveTest do
|
|||||||
setup [:create_item]
|
setup [:create_item]
|
||||||
|
|
||||||
test "lists all items", %{conn: conn, item: item} do
|
test "lists all items", %{conn: conn, item: item} do
|
||||||
{:ok, _index_live, html} = live(conn, ~p"/items")
|
{:ok, _index_live, html} =
|
||||||
|
conn
|
||||||
|
|> log_in_user(user_fixture())
|
||||||
|
|> live(~p"/items")
|
||||||
|
|
||||||
assert html =~ "Listing Items"
|
assert html =~ "Listing Items"
|
||||||
assert html =~ item.description
|
assert html =~ item.description
|
||||||
end
|
end
|
||||||
|
|
||||||
test "saves new item", %{conn: conn} do
|
test "saves new item", %{conn: conn} do
|
||||||
{:ok, index_live, _html} = live(conn, ~p"/items")
|
{:ok, index_live, _html} =
|
||||||
|
conn
|
||||||
|
|> log_in_user(user_fixture())
|
||||||
|
|> live(~p"/items")
|
||||||
|
|
||||||
assert index_live |> element("a", "New Item") |> render_click() =~
|
assert index_live |> element("a", "New Item") |> render_click() =~
|
||||||
"New Item"
|
"New Item"
|
||||||
@@ -46,66 +63,75 @@ defmodule WishWeb.ItemLiveTest do
|
|||||||
assert html =~ "some description"
|
assert html =~ "some description"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "updates item in listing", %{conn: conn, item: item} do
|
# test "updates item in listing", %{conn: conn, item: item} do
|
||||||
{:ok, index_live, _html} = live(conn, ~p"/items")
|
# {:ok, index_live, _html} =
|
||||||
|
# conn
|
||||||
assert index_live |> element("#items-#{item.id} a", "Edit") |> render_click() =~
|
# |> log_in_user(user_fixture())
|
||||||
"Edit Item"
|
# |> live(~p"/items")
|
||||||
|
#
|
||||||
assert_patch(index_live, ~p"/items/#{item}/edit")
|
# index_live
|
||||||
|
# |> element("#items-#{item.id} a", "Edit")
|
||||||
assert index_live
|
# |> render_click()
|
||||||
|> form("#item-form", item: @invalid_attrs)
|
#
|
||||||
|> render_change() =~ "can't be blank"
|
# assert_patch(index_live, ~p"/items/#{item}/show/edit")
|
||||||
|
#
|
||||||
assert index_live
|
# assert index_live
|
||||||
|> form("#item-form", item: @update_attrs)
|
# |> form("#item-form", item: @invalid_attrs)
|
||||||
|> render_submit()
|
# |> render_change() =~ "can't be blank"
|
||||||
|
#
|
||||||
assert_patch(index_live, ~p"/items")
|
# assert index_live
|
||||||
|
# |> form("#item-form", item: @update_attrs)
|
||||||
html = render(index_live)
|
# |> render_submit()
|
||||||
assert html =~ "Item updated successfully"
|
#
|
||||||
assert html =~ "some updated description"
|
# assert_patch(index_live, ~p"/items")
|
||||||
end
|
#
|
||||||
|
# html = render(index_live)
|
||||||
|
# assert html =~ "Item updated successfully"
|
||||||
|
# assert html =~ "some updated description"
|
||||||
|
# end
|
||||||
|
|
||||||
test "deletes item in listing", %{conn: conn, item: item} do
|
test "deletes item in listing", %{conn: conn, item: item} do
|
||||||
{:ok, index_live, _html} = live(conn, ~p"/items")
|
{:ok, index_live, _html} =
|
||||||
|
conn
|
||||||
|
|> log_in_user(user_fixture())
|
||||||
|
|> live(~p"/items")
|
||||||
|
|
||||||
|
assert index_live
|
||||||
|
|> element("#delete-items-#{item.id}")
|
||||||
|
|> render_click()
|
||||||
|
|
||||||
assert index_live |> element("#items-#{item.id} a", "Delete") |> render_click()
|
|
||||||
refute has_element?(index_live, "#items-#{item.id}")
|
refute has_element?(index_live, "#items-#{item.id}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "Show" do
|
describe "Edit" do
|
||||||
setup [:create_item]
|
setup [:create_item]
|
||||||
|
|
||||||
test "displays item", %{conn: conn, item: item} do
|
test "displays item", %{conn: conn, item: item} do
|
||||||
{:ok, _show_live, html} = live(conn, ~p"/items/#{item}")
|
{:ok, _show_live, html} =
|
||||||
|
conn
|
||||||
|
|> log_in_user(user_fixture())
|
||||||
|
|> live(~p"/items/#{item}/show/edit")
|
||||||
|
|
||||||
assert html =~ "Show Item"
|
assert html =~ "Edit Item"
|
||||||
assert html =~ item.description
|
assert html =~ item.description
|
||||||
end
|
end
|
||||||
|
|
||||||
test "updates item within modal", %{conn: conn, item: item} do
|
test "updates item within modal", %{conn: conn, item: item} do
|
||||||
{:ok, show_live, _html} = live(conn, ~p"/items/#{item}")
|
{:ok, edit_live, _html} =
|
||||||
|
conn
|
||||||
|
|> log_in_user(user_fixture())
|
||||||
|
|> live(~p"/items/#{item}/show/edit")
|
||||||
|
|
||||||
assert show_live |> element("a", "Edit") |> render_click() =~
|
assert edit_live
|
||||||
"Edit Item"
|
|
||||||
|
|
||||||
assert_patch(show_live, ~p"/items/#{item}/show/edit")
|
|
||||||
|
|
||||||
assert show_live
|
|
||||||
|> form("#item-form", item: @invalid_attrs)
|
|> form("#item-form", item: @invalid_attrs)
|
||||||
|> render_change() =~ "can't be blank"
|
|> render_change() =~ "can't be blank"
|
||||||
|
|
||||||
assert show_live
|
assert edit_live
|
||||||
|> form("#item-form", item: @update_attrs)
|
|> form("#item-form", item: @update_attrs)
|
||||||
|> render_submit()
|
|> render_submit()
|
||||||
|
|
||||||
assert_patch(show_live, ~p"/items/#{item}")
|
html = render(edit_live)
|
||||||
|
|
||||||
html = render(show_live)
|
|
||||||
assert html =~ "Item updated successfully"
|
assert html =~ "Item updated successfully"
|
||||||
assert html =~ "some updated description"
|
assert html =~ "some updated description"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ defmodule WishWeb.UserForgotPasswordLiveTest do
|
|||||||
{:ok, lv, html} = live(conn, ~p"/users/reset_password")
|
{:ok, lv, html} = live(conn, ~p"/users/reset_password")
|
||||||
|
|
||||||
assert html =~ "Forgot your password?"
|
assert html =~ "Forgot your password?"
|
||||||
assert has_element?(lv, ~s|a[href="#{~p"/users/register"}"]|, "Register")
|
|
||||||
assert has_element?(lv, ~s|a[href="#{~p"/users/log_in"}"]|, "Log in")
|
assert has_element?(lv, ~s|a[href="#{~p"/users/log_in"}"]|, "Log in")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ defmodule WishWeb.UserLoginLiveTest do
|
|||||||
{:ok, _lv, html} = live(conn, ~p"/users/log_in")
|
{:ok, _lv, html} = live(conn, ~p"/users/log_in")
|
||||||
|
|
||||||
assert html =~ "Log in"
|
assert html =~ "Log in"
|
||||||
assert html =~ "Register"
|
|
||||||
assert html =~ "Forgot your password?"
|
assert html =~ "Forgot your password?"
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -58,18 +57,6 @@ defmodule WishWeb.UserLoginLiveTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "login navigation" do
|
describe "login navigation" do
|
||||||
test "redirects to registration page when the Register button is clicked", %{conn: conn} do
|
|
||||||
{:ok, lv, _html} = live(conn, ~p"/users/log_in")
|
|
||||||
|
|
||||||
{:ok, _login_live, login_html} =
|
|
||||||
lv
|
|
||||||
|> element(~s|main a:fl-contains("Sign up")|)
|
|
||||||
|> render_click()
|
|
||||||
|> follow_redirect(conn, ~p"/users/register")
|
|
||||||
|
|
||||||
assert login_html =~ "Register"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "redirects to forgot password page when the Forgot Password button is clicked", %{
|
test "redirects to forgot password page when the Forgot Password button is clicked", %{
|
||||||
conn: conn
|
conn: conn
|
||||||
} do
|
} do
|
||||||
|
|||||||
@@ -99,20 +99,5 @@ defmodule WishWeb.UserResetPasswordLiveTest do
|
|||||||
|
|
||||||
assert conn.resp_body =~ "Log in"
|
assert conn.resp_body =~ "Log in"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "redirects to password reset page when the Register button is clicked", %{
|
|
||||||
conn: conn,
|
|
||||||
token: token
|
|
||||||
} do
|
|
||||||
{:ok, lv, _html} = live(conn, ~p"/users/reset_password/#{token}")
|
|
||||||
|
|
||||||
{:ok, conn} =
|
|
||||||
lv
|
|
||||||
|> element(~s|main a:fl-contains("Register")|)
|
|
||||||
|> render_click()
|
|
||||||
|> follow_redirect(conn, ~p"/users/register")
|
|
||||||
|
|
||||||
assert conn.resp_body =~ "Register"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user