mirror of
https://github.com/fly-apps/live_beats.git
synced 2024-11-25 01:10:59 +00:00
Test song deletion
This commit is contained in:
parent
dda0cdaa3f
commit
570e86d02c
2 changed files with 14 additions and 3 deletions
|
@ -133,7 +133,7 @@ defmodule LiveBeatsWeb.ProfileLive do
|
||||||
song = MediaLibrary.get_song!(id)
|
song = MediaLibrary.get_song!(id)
|
||||||
|
|
||||||
if song.user_id == socket.assigns.current_user.id do
|
if song.user_id == socket.assigns.current_user.id do
|
||||||
{:ok, _} = MediaLibrary.delete_song(song)
|
:ok = MediaLibrary.delete_song(song)
|
||||||
end
|
end
|
||||||
|
|
||||||
{:noreply, socket}
|
{:noreply, socket}
|
||||||
|
|
|
@ -4,6 +4,7 @@ defmodule LiveBeatsWeb.ProfileLiveTest do
|
||||||
import Phoenix.LiveViewTest
|
import Phoenix.LiveViewTest
|
||||||
import LiveBeats.AccountsFixtures
|
import LiveBeats.AccountsFixtures
|
||||||
|
|
||||||
|
alias LiveBeats.MediaLibrary
|
||||||
alias LiveBeatsWeb.LiveHelpers
|
alias LiveBeatsWeb.LiveHelpers
|
||||||
|
|
||||||
setup %{conn: conn} do
|
setup %{conn: conn} do
|
||||||
|
@ -13,11 +14,13 @@ defmodule LiveBeatsWeb.ProfileLiveTest do
|
||||||
{:ok, conn: conn, current_user: current_user, user2: user2}
|
{:ok, conn: conn, current_user: current_user, user2: user2}
|
||||||
end
|
end
|
||||||
|
|
||||||
test "profile page", %{conn: conn, current_user: current_user} do
|
test "profile page uploads", %{conn: conn, current_user: current_user} do
|
||||||
|
profile = MediaLibrary.get_profile!(current_user)
|
||||||
{:ok, lv, dead_html} = live(conn, LiveHelpers.profile_path(current_user))
|
{:ok, lv, dead_html} = live(conn, LiveHelpers.profile_path(current_user))
|
||||||
|
|
||||||
assert dead_html =~ "chrismccord's beats"
|
assert dead_html =~ "chrismccord's beats"
|
||||||
|
|
||||||
|
# uploads
|
||||||
assert lv
|
assert lv
|
||||||
|> element("#upload-btn")
|
|> element("#upload-btn")
|
||||||
|> render_click()
|
|> render_click()
|
||||||
|
@ -47,12 +50,20 @@ defmodule LiveBeatsWeb.ProfileLiveTest do
|
||||||
}
|
}
|
||||||
}) =~ "can't be blank"
|
}) =~ "can't be blank"
|
||||||
|
|
||||||
assert {:ok, _new_lv, html} =
|
assert {:ok, new_lv, html} =
|
||||||
lv |> form("#song-form") |> render_submit() |> follow_redirect(conn)
|
lv |> form("#song-form") |> render_submit() |> follow_redirect(conn)
|
||||||
|
|
||||||
assert_redirected(lv, "/#{current_user.username}")
|
assert_redirected(lv, "/#{current_user.username}")
|
||||||
assert html =~ "1 song(s) uploaded"
|
assert html =~ "1 song(s) uploaded"
|
||||||
|
|
||||||
assert html =~ "silence1s"
|
assert html =~ "silence1s"
|
||||||
|
|
||||||
|
# deleting songs
|
||||||
|
|
||||||
|
song = MediaLibrary.get_first_song(profile)
|
||||||
|
assert new_lv |> element("#delete-modal-#{song.id}-confirm") |> render_click()
|
||||||
|
|
||||||
|
{:ok, refreshed_lv, _} = live(conn, LiveHelpers.profile_path(current_user))
|
||||||
|
refute render(refreshed_lv) =~ "silence1s"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue