mirror of
https://github.com/fly-apps/live_beats.git
synced 2024-11-25 09:20:59 +00:00
TODO
This commit is contained in:
parent
570e86d02c
commit
b2950adb2a
1 changed files with 44 additions and 38 deletions
|
@ -14,56 +14,62 @@ 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 uploads", %{conn: conn, current_user: current_user} do
|
describe "own profile" do
|
||||||
profile = MediaLibrary.get_profile!(current_user)
|
test "profile page uploads", %{conn: conn, current_user: current_user} do
|
||||||
{:ok, lv, dead_html} = live(conn, LiveHelpers.profile_path(current_user))
|
profile = MediaLibrary.get_profile!(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
|
# uploads
|
||||||
assert lv
|
assert lv
|
||||||
|> element("#upload-btn")
|
|> element("#upload-btn")
|
||||||
|> render_click()
|
|> render_click()
|
||||||
|
|
||||||
assert render(lv) =~ "Add Songs"
|
assert render(lv) =~ "Add Songs"
|
||||||
|
|
||||||
mp3 =
|
mp3 =
|
||||||
file_input(lv, "#song-form", :mp3, [
|
file_input(lv, "#song-form", :mp3, [
|
||||||
%{
|
%{
|
||||||
last_modified: 1_594_171_879_000,
|
last_modified: 1_594_171_879_000,
|
||||||
name: "my.mp3",
|
name: "my.mp3",
|
||||||
content: File.read!("test/support/fixtures/silence1s.mp3"),
|
content: File.read!("test/support/fixtures/silence1s.mp3"),
|
||||||
type: "audio/mpeg"
|
type: "audio/mpeg"
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
assert render_upload(mp3, "my.mp3") =~ "can't be blank"
|
assert render_upload(mp3, "my.mp3") =~ "can't be blank"
|
||||||
|
|
||||||
[%{"ref" => ref}] = mp3.entries
|
[%{"ref" => ref}] = mp3.entries
|
||||||
|
|
||||||
refute lv
|
refute lv
|
||||||
|> form("#song-form")
|
|> form("#song-form")
|
||||||
|> render_change(%{
|
|> render_change(%{
|
||||||
"_target" => ["songs", ref, "artist"],
|
"_target" => ["songs", ref, "artist"],
|
||||||
"songs" => %{
|
"songs" => %{
|
||||||
ref => %{"artist" => "Anon", "attribution" => "", "title" => "silence1s"}
|
ref => %{"artist" => "Anon", "attribution" => "", "title" => "silence1s"}
|
||||||
}
|
}
|
||||||
}) =~ "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
|
# deleting songs
|
||||||
|
|
||||||
song = MediaLibrary.get_first_song(profile)
|
song = MediaLibrary.get_first_song(profile)
|
||||||
assert new_lv |> element("#delete-modal-#{song.id}-confirm") |> render_click()
|
assert new_lv |> element("#delete-modal-#{song.id}-confirm") |> render_click()
|
||||||
|
|
||||||
{:ok, refreshed_lv, _} = live(conn, LiveHelpers.profile_path(current_user))
|
{:ok, refreshed_lv, _} = live(conn, LiveHelpers.profile_path(current_user))
|
||||||
refute render(refreshed_lv) =~ "silence1s"
|
refute render(refreshed_lv) =~ "silence1s"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "viewing other profiles" do
|
||||||
|
# TODO
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue