[Enhancement] Adds ability to enable/disable sources (#481)
* [Unrelated] updated module name for existing liveview module * Updated toggle component and moved MP index table to a liveview * [WIP] reverted MP index table; added source count to MP index * Moved new live table to sources index * Added 'enabled' boolean to sources * Got 'enabled' logic working re: downloading pending media * Updated sources context to do the right thing when a source is updated * Docs and tests * Updated slow indexing to maintain its old schedule if re-enabled * Hooked up the enabled toggle to the sources page * [Unrelated] added direct links to various tabs on the sources table * More tests * Removed unneeded guard in * Removed outdated comment
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
defmodule PinchflatWeb.Sources.IndexTableLiveTest do
|
||||
use PinchflatWeb.ConnCase
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import Pinchflat.SourcesFixtures
|
||||
import Pinchflat.ProfilesFixtures
|
||||
|
||||
alias Pinchflat.Sources.Source
|
||||
alias PinchflatWeb.Sources.IndexTableLive
|
||||
|
||||
describe "initial rendering" do
|
||||
test "lists all sources", %{conn: conn} do
|
||||
source = source_fixture()
|
||||
|
||||
{:ok, _view, html} = live_isolated(conn, IndexTableLive)
|
||||
|
||||
assert html =~ source.custom_name
|
||||
end
|
||||
|
||||
test "omits sources that have marked_for_deletion_at set", %{conn: conn} do
|
||||
source = source_fixture(marked_for_deletion_at: DateTime.utc_now())
|
||||
|
||||
{:ok, _view, html} = live_isolated(conn, IndexTableLive)
|
||||
|
||||
refute html =~ source.custom_name
|
||||
end
|
||||
|
||||
test "omits sources who's media profile has marked_for_deletion_at set", %{conn: conn} do
|
||||
media_profile = media_profile_fixture(marked_for_deletion_at: DateTime.utc_now())
|
||||
source = source_fixture(media_profile_id: media_profile.id)
|
||||
|
||||
{:ok, _view, html} = live_isolated(conn, IndexTableLive)
|
||||
|
||||
refute html =~ source.custom_name
|
||||
end
|
||||
end
|
||||
|
||||
describe "when a source is enabled or disabled" do
|
||||
test "updates the source's enabled status", %{conn: conn} do
|
||||
source = source_fixture(enabled: true)
|
||||
{:ok, view, _html} = live_isolated(conn, IndexTableLive)
|
||||
|
||||
params = %{
|
||||
"event" => "toggle_enabled",
|
||||
"id" => source.id,
|
||||
"value" => "false"
|
||||
}
|
||||
|
||||
# Send an event to the server directly
|
||||
render_change(view, "formless-input", params)
|
||||
|
||||
assert %{enabled: false} = Repo.get!(Source, source.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user