work on pipelines

This commit is contained in:
2022-11-24 14:31:16 -05:00
parent ad457b428a
commit 7195c7fba6
17 changed files with 787 additions and 242 deletions

View File

@ -4,26 +4,36 @@ defmodule MemexWeb.PipelineLiveTest do
import Phoenix.LiveViewTest
import Memex.PipelinesFixtures
@create_attrs %{description: "some description", title: "some title", visibility: :public}
@update_attrs %{
description: "some updated description",
title: "some updated title",
visibility: :private
@create_attrs %{
"description" => "some description",
"tags_string" => "tag1",
"title" => "some title",
"visibility" => :public
}
@update_attrs %{
"description" => "some updated description",
"tags_string" => "tag1,tag2",
"title" => "some updated title",
"visibility" => :private
}
@invalid_attrs %{
"description" => nil,
"tags_string" => "",
"title" => nil,
"visibility" => nil
}
@invalid_attrs %{description: nil, title: nil, visibility: nil}
defp create_pipeline(_) do
pipeline = pipeline_fixture()
%{pipeline: pipeline}
defp create_pipeline(%{user: user}) do
[pipeline: pipeline_fixture(user)]
end
describe "Index" do
setup [:create_pipeline]
setup [:register_and_log_in_user, :create_pipeline]
test "lists all pipelines", %{conn: conn, pipeline: pipeline} do
{:ok, _index_live, html} = live(conn, Routes.pipeline_index_path(conn, :index))
assert html =~ "listing pipelines"
assert html =~ "pipelines"
assert html =~ pipeline.description
end
@ -45,15 +55,15 @@ defmodule MemexWeb.PipelineLiveTest do
|> render_submit()
|> follow_redirect(conn, Routes.pipeline_index_path(conn, :index))
assert html =~ "pipeline created successfully"
assert html =~ "#{@create_attrs |> Map.get("title")} created"
assert html =~ "some description"
end
test "updates pipeline in listing", %{conn: conn, pipeline: pipeline} do
{:ok, index_live, _html} = live(conn, Routes.pipeline_index_path(conn, :index))
assert index_live |> element("#pipeline-#{pipeline.id} a", "edit") |> render_click() =~
"edit pipeline"
assert index_live |> element("[data-qa=\"pipeline-edit-#{pipeline.id}\"]") |> render_click() =~
"edit"
assert_patch(index_live, Routes.pipeline_index_path(conn, :edit, pipeline))
@ -67,20 +77,23 @@ defmodule MemexWeb.PipelineLiveTest do
|> render_submit()
|> follow_redirect(conn, Routes.pipeline_index_path(conn, :index))
assert html =~ "pipeline updated successfully"
assert html =~ "#{@update_attrs |> Map.get("title")} saved"
assert html =~ "some updated description"
end
test "deletes pipeline in listing", %{conn: conn, pipeline: pipeline} do
{:ok, index_live, _html} = live(conn, Routes.pipeline_index_path(conn, :index))
assert index_live |> element("#pipeline-#{pipeline.id} a", "delete") |> render_click()
assert index_live
|> element("[data-qa=\"delete-pipeline-#{pipeline.id}\"]")
|> render_click()
refute has_element?(index_live, "#pipeline-#{pipeline.id}")
end
end
describe "show" do
setup [:create_pipeline]
setup [:register_and_log_in_user, :create_pipeline]
test "displays pipeline", %{conn: conn, pipeline: pipeline} do
{:ok, _show_live, html} = live(conn, Routes.pipeline_show_path(conn, :show, pipeline))
@ -92,8 +105,7 @@ defmodule MemexWeb.PipelineLiveTest do
test "updates pipeline within modal", %{conn: conn, pipeline: pipeline} do
{:ok, show_live, _html} = live(conn, Routes.pipeline_show_path(conn, :show, pipeline))
assert show_live |> element("a", "edit") |> render_click() =~
"edit pipeline"
assert show_live |> element("a", "edit") |> render_click() =~ "edit"
assert_patch(show_live, Routes.pipeline_show_path(conn, :edit, pipeline))
@ -107,8 +119,20 @@ defmodule MemexWeb.PipelineLiveTest do
|> render_submit()
|> follow_redirect(conn, Routes.pipeline_show_path(conn, :show, pipeline))
assert html =~ "pipeline updated successfully"
assert html =~ "#{@update_attrs |> Map.get("title")} saved"
assert html =~ "some updated description"
end
test "deletes pipeline", %{conn: conn, pipeline: pipeline} do
{:ok, show_live, _html} = live(conn, Routes.pipeline_show_path(conn, :show, pipeline))
{:ok, index_live, _html} =
show_live
|> element("[data-qa=\"delete-pipeline-#{pipeline.id}\"]")
|> render_click()
|> follow_redirect(conn, Routes.pipeline_index_path(conn, :index))
refute has_element?(index_live, "#pipeline-#{pipeline.id}")
end
end
end