This commit is contained in:
@ -1,26 +1,26 @@
|
||||
defmodule MemexWeb.ContextLiveTest do
|
||||
use MemexWeb.ConnCase
|
||||
import Phoenix.LiveViewTest
|
||||
import Memex.{ContextsFixtures, NotesFixtures}
|
||||
import Memex.Fixtures
|
||||
alias MemexWeb.Endpoint
|
||||
|
||||
@create_attrs %{
|
||||
"content" => "some content",
|
||||
"tags_string" => "tag1",
|
||||
"slug" => "some-slug",
|
||||
"visibility" => :public
|
||||
content: "some content",
|
||||
tags_string: "tag1",
|
||||
slug: "some-slug",
|
||||
visibility: :public
|
||||
}
|
||||
@update_attrs %{
|
||||
"content" => "some updated content",
|
||||
"tags_string" => "tag1,tag2",
|
||||
"slug" => "some-updated-slug",
|
||||
"visibility" => :private
|
||||
content: "some updated content",
|
||||
tags_string: "tag1,tag2",
|
||||
slug: "some-updated-slug",
|
||||
visibility: :private
|
||||
}
|
||||
@invalid_attrs %{
|
||||
"content" => nil,
|
||||
"tags_string" => " ",
|
||||
"slug" => nil,
|
||||
"visibility" => nil
|
||||
content: nil,
|
||||
tags_string: " ",
|
||||
slug: nil,
|
||||
visibility: nil
|
||||
}
|
||||
|
||||
defp create_context(%{current_user: current_user}) do
|
||||
@ -37,34 +37,31 @@ defmodule MemexWeb.ContextLiveTest do
|
||||
assert html =~ context.slug
|
||||
end
|
||||
|
||||
test "searches by tag", %{conn: conn} do
|
||||
test "searches by tag", %{conn: conn, context: %{tags: [tag]}} do
|
||||
{:ok, index_live, html} = live(conn, Routes.context_index_path(conn, :index))
|
||||
|
||||
assert html =~ "example-tag"
|
||||
assert index_live |> element("a", "example-tag") |> render_click()
|
||||
assert_patch(index_live, Routes.context_index_path(conn, :search, "example-tag"))
|
||||
assert html =~ tag
|
||||
assert index_live |> element("a", tag) |> render_click()
|
||||
assert_patch(index_live, Routes.context_index_path(conn, :search, tag))
|
||||
end
|
||||
|
||||
test "saves new context", %{conn: conn} do
|
||||
{:ok, index_live, _html} = live(conn, Routes.context_index_path(conn, :index))
|
||||
|
||||
assert index_live |> element("a", "new context") |> render_click() =~
|
||||
"new context"
|
||||
|
||||
assert index_live |> element("a", "new context") |> render_click() =~ "new context"
|
||||
assert_patch(index_live, Routes.context_index_path(conn, :new))
|
||||
|
||||
assert index_live
|
||||
|> form("#context-form", context: @invalid_attrs)
|
||||
|> render_change() =~ "can't be blank"
|
||||
|> form("#context-form")
|
||||
|> render_change(context: @invalid_attrs) =~ "can't be blank"
|
||||
|
||||
{:ok, _live, html} =
|
||||
index_live
|
||||
|> form("#context-form", context: @create_attrs)
|
||||
|> render_submit()
|
||||
|> form("#context-form")
|
||||
|> render_submit(context: @create_attrs)
|
||||
|> follow_redirect(conn, Routes.context_index_path(conn, :index))
|
||||
|
||||
assert html =~ "#{@create_attrs |> Map.get("slug")} created"
|
||||
assert html =~ "some-slug"
|
||||
assert html =~ "#{@create_attrs.slug} created"
|
||||
assert html =~ @create_attrs.slug
|
||||
end
|
||||
|
||||
test "updates context in listing", %{conn: conn, context: context} do
|
||||
@ -76,16 +73,16 @@ defmodule MemexWeb.ContextLiveTest do
|
||||
assert_patch(index_live, Routes.context_index_path(conn, :edit, context.slug))
|
||||
|
||||
assert index_live
|
||||
|> form("#context-form", context: @invalid_attrs)
|
||||
|> render_change() =~ "can't be blank"
|
||||
|> form("#context-form")
|
||||
|> render_change(context: @invalid_attrs) =~ "can't be blank"
|
||||
|
||||
{:ok, _live, html} =
|
||||
index_live
|
||||
|> form("#context-form", context: @update_attrs)
|
||||
|> render_submit()
|
||||
|> form("#context-form")
|
||||
|> render_submit(context: @update_attrs)
|
||||
|> follow_redirect(conn, Routes.context_index_path(conn, :index))
|
||||
|
||||
assert html =~ "#{@update_attrs |> Map.get("slug")} saved"
|
||||
assert html =~ "#{@update_attrs.slug} saved"
|
||||
assert html =~ "some-updated-slug"
|
||||
end
|
||||
|
||||
@ -109,23 +106,21 @@ defmodule MemexWeb.ContextLiveTest do
|
||||
|
||||
test "updates context within modal", %{conn: conn, context: context} do
|
||||
{:ok, show_live, _html} = live(conn, Routes.context_show_path(conn, :show, context.slug))
|
||||
|
||||
assert show_live |> element("a", "edit") |> render_click() =~ "edit"
|
||||
|
||||
assert_patch(show_live, Routes.context_show_path(conn, :edit, context.slug))
|
||||
|
||||
html =
|
||||
show_live
|
||||
|> form("#context-form", context: @invalid_attrs)
|
||||
|> render_change()
|
||||
|> form("#context-form")
|
||||
|> render_change(context: @invalid_attrs)
|
||||
|
||||
assert html =~ "can't be blank"
|
||||
assert html =~ "tags must be comma-delimited"
|
||||
|
||||
{:ok, _live, html} =
|
||||
show_live
|
||||
|> form("#context-form", context: Map.put(@update_attrs, "slug", context.slug))
|
||||
|> render_submit()
|
||||
|> form("#context-form")
|
||||
|> render_submit(context: Map.put(@update_attrs, "slug", context.slug))
|
||||
|> follow_redirect(conn, Routes.context_show_path(conn, :show, context.slug))
|
||||
|
||||
assert html =~ "#{context.slug} saved"
|
||||
@ -161,12 +156,12 @@ defmodule MemexWeb.ContextLiveTest do
|
||||
]
|
||||
end
|
||||
|
||||
test "searches by tag", %{conn: conn, context: context} do
|
||||
test "searches by tag", %{conn: conn, context: %{tags: [tag]} = context} do
|
||||
{:ok, show_live, html} = live(conn, Routes.context_show_path(conn, :show, context.slug))
|
||||
|
||||
assert html =~ "example-tag"
|
||||
assert show_live |> element("a", "example-tag") |> render_click()
|
||||
assert_redirect(show_live, Routes.context_index_path(conn, :search, "example-tag"))
|
||||
assert html =~ tag
|
||||
assert show_live |> element("a", tag) |> render_click()
|
||||
assert_redirect(show_live, Routes.context_index_path(conn, :search, tag))
|
||||
end
|
||||
|
||||
test "displays context", %{conn: conn, context: context, note: %{slug: note_slug}} do
|
||||
|
@ -5,12 +5,11 @@ defmodule MemexWeb.InviteLiveTest do
|
||||
|
||||
use MemexWeb.ConnCase
|
||||
import Phoenix.LiveViewTest
|
||||
import MemexWeb.Gettext
|
||||
alias Memex.Accounts.Invites
|
||||
|
||||
@moduletag :invite_live_test
|
||||
@create_attrs %{"name" => "some name"}
|
||||
@update_attrs %{"name" => "some updated name"}
|
||||
@create_attrs %{name: "some name"}
|
||||
@update_attrs %{name: "some updated name"}
|
||||
# @invalid_attrs %{"name" => nil}
|
||||
|
||||
describe "Index" do
|
||||
@ -24,32 +23,26 @@ defmodule MemexWeb.InviteLiveTest do
|
||||
test "lists all invites", %{conn: conn, invite: invite} do
|
||||
{:ok, _index_live, html} = live(conn, Routes.invite_index_path(conn, :index))
|
||||
|
||||
assert html =~ gettext("invites")
|
||||
assert html =~ "invites"
|
||||
assert html =~ invite.name
|
||||
end
|
||||
|
||||
test "saves new invite", %{conn: conn} do
|
||||
{:ok, index_live, _html} = live(conn, Routes.invite_index_path(conn, :index))
|
||||
|
||||
assert index_live |> element("a", dgettext("actions", "create invite")) |> render_click() =~
|
||||
gettext("new invite")
|
||||
|
||||
assert index_live |> element("a", "create invite") |> render_click() =~ "new invite"
|
||||
assert_patch(index_live, Routes.invite_index_path(conn, :new))
|
||||
|
||||
# assert index_live
|
||||
# |> form("#invite-form", invite: @invalid_attrs)
|
||||
# |> render_change() =~ dgettext("errors", "can't be blank")
|
||||
# |> form("#invite-form")
|
||||
# |> render_change(invite: @invalid_attrs) =~ "can't be blank"
|
||||
|
||||
{:ok, _live, html} =
|
||||
index_live
|
||||
|> form("#invite-form", invite: @create_attrs)
|
||||
|> render_submit()
|
||||
|> form("#invite-form")
|
||||
|> render_submit(invite: @create_attrs)
|
||||
|> follow_redirect(conn, Routes.invite_index_path(conn, :index))
|
||||
|
||||
assert html =~
|
||||
dgettext("prompts", "%{invite_name} created successfully", invite_name: "some name")
|
||||
|
||||
assert html =~ "some name"
|
||||
assert html =~ "some name created successfully"
|
||||
end
|
||||
|
||||
test "updates invite in listing", %{conn: conn, invite: invite} do
|
||||
@ -57,27 +50,21 @@ defmodule MemexWeb.InviteLiveTest do
|
||||
|
||||
assert index_live
|
||||
|> element(~s/a[aria-label="edit invite for #{invite.name}"]/)
|
||||
|> render_click() =~
|
||||
gettext("edit invite")
|
||||
|> render_click() =~ "edit invite"
|
||||
|
||||
assert_patch(index_live, Routes.invite_index_path(conn, :edit, invite))
|
||||
|
||||
# assert index_live
|
||||
# |> form("#invite-form", invite: @invalid_attrs)
|
||||
# |> render_change() =~ dgettext("errors", "can't be blank")
|
||||
# |> form("#invite-form")
|
||||
# |> render_change(invite: @invalid_attrs) =~ "can't be blank"
|
||||
|
||||
{:ok, _live, html} =
|
||||
index_live
|
||||
|> form("#invite-form", invite: @update_attrs)
|
||||
|> render_submit()
|
||||
|> form("#invite-form")
|
||||
|> render_submit(invite: @update_attrs)
|
||||
|> follow_redirect(conn, Routes.invite_index_path(conn, :index))
|
||||
|
||||
assert html =~
|
||||
dgettext("prompts", "%{invite_name} updated successfully",
|
||||
invite_name: "some updated name"
|
||||
)
|
||||
|
||||
assert html =~ "some updated name"
|
||||
assert html =~ "some updated name updated successfully"
|
||||
end
|
||||
|
||||
test "deletes invite in listing", %{conn: conn, invite: invite} do
|
||||
|
@ -2,26 +2,26 @@ defmodule MemexWeb.NoteLiveTest do
|
||||
use MemexWeb.ConnCase
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import Memex.NotesFixtures
|
||||
import Memex.Fixtures
|
||||
alias MemexWeb.Endpoint
|
||||
|
||||
@create_attrs %{
|
||||
"content" => "some content",
|
||||
"tags_string" => "tag1",
|
||||
"slug" => "some-slug",
|
||||
"visibility" => :public
|
||||
content: "some content",
|
||||
tags_string: "tag1",
|
||||
slug: "some-slug",
|
||||
visibility: :public
|
||||
}
|
||||
@update_attrs %{
|
||||
"content" => "some updated content",
|
||||
"tags_string" => "tag1,tag2",
|
||||
"slug" => "some-updated-slug",
|
||||
"visibility" => :private
|
||||
content: "some updated content",
|
||||
tags_string: "tag1,tag2",
|
||||
slug: "some-updated-slug",
|
||||
visibility: :private
|
||||
}
|
||||
@invalid_attrs %{
|
||||
"content" => nil,
|
||||
"tags_string" => " ",
|
||||
"slug" => nil,
|
||||
"visibility" => nil
|
||||
content: nil,
|
||||
tags_string: " ",
|
||||
slug: nil,
|
||||
visibility: nil
|
||||
}
|
||||
|
||||
defp create_note(%{current_user: current_user}) do
|
||||
@ -38,38 +38,35 @@ defmodule MemexWeb.NoteLiveTest do
|
||||
assert html =~ note.slug
|
||||
end
|
||||
|
||||
test "searches by tag", %{conn: conn} do
|
||||
test "searches by tag", %{conn: conn, note: %{tags: [tag]}} do
|
||||
{:ok, index_live, html} = live(conn, Routes.note_index_path(conn, :index))
|
||||
|
||||
assert html =~ "example-tag"
|
||||
assert index_live |> element("a", "example-tag") |> render_click()
|
||||
assert_patch(index_live, Routes.note_index_path(conn, :search, "example-tag"))
|
||||
assert html =~ tag
|
||||
assert index_live |> element("a", tag) |> render_click()
|
||||
assert_patch(index_live, Routes.note_index_path(conn, :search, tag))
|
||||
end
|
||||
|
||||
test "saves new note", %{conn: conn} do
|
||||
{:ok, index_live, _html} = live(conn, Routes.note_index_path(conn, :index))
|
||||
|
||||
assert index_live |> element("a", "new note") |> render_click() =~
|
||||
"new note"
|
||||
|
||||
assert index_live |> element("a", "new note") |> render_click() =~ "new note"
|
||||
assert_patch(index_live, Routes.note_index_path(conn, :new))
|
||||
|
||||
html =
|
||||
index_live
|
||||
|> form("#note-form", note: @invalid_attrs)
|
||||
|> render_change()
|
||||
|> form("#note-form")
|
||||
|> render_change(note: @invalid_attrs)
|
||||
|
||||
assert html =~ "can't be blank"
|
||||
assert html =~ "tags must be comma-delimited"
|
||||
|
||||
{:ok, _live, html} =
|
||||
index_live
|
||||
|> form("#note-form", note: @create_attrs)
|
||||
|> render_submit()
|
||||
|> form("#note-form")
|
||||
|> render_submit(note: @create_attrs)
|
||||
|> follow_redirect(conn, Routes.note_index_path(conn, :index))
|
||||
|
||||
assert html =~ "#{@create_attrs |> Map.get("slug")} created"
|
||||
assert html =~ "some-slug"
|
||||
assert html =~ "#{@create_attrs.slug} created"
|
||||
assert html =~ @create_attrs.slug
|
||||
end
|
||||
|
||||
test "updates note in listing", %{conn: conn, note: note} do
|
||||
@ -81,17 +78,17 @@ defmodule MemexWeb.NoteLiveTest do
|
||||
assert_patch(index_live, Routes.note_index_path(conn, :edit, note.slug))
|
||||
|
||||
assert index_live
|
||||
|> form("#note-form", note: @invalid_attrs)
|
||||
|> render_change() =~ "can't be blank"
|
||||
|> form("#note-form")
|
||||
|> render_change(note: @invalid_attrs) =~ "can't be blank"
|
||||
|
||||
{:ok, _live, html} =
|
||||
index_live
|
||||
|> form("#note-form", note: @update_attrs)
|
||||
|> render_submit()
|
||||
|> form("#note-form")
|
||||
|> render_submit(note: @update_attrs)
|
||||
|> follow_redirect(conn, Routes.note_index_path(conn, :index))
|
||||
|
||||
assert html =~ "#{@update_attrs |> Map.get("slug")} saved"
|
||||
assert html =~ "some-updated-slug"
|
||||
assert html =~ "#{@update_attrs.slug} saved"
|
||||
assert html =~ @update_attrs.slug
|
||||
end
|
||||
|
||||
test "deletes note in listing", %{conn: conn, note: note} do
|
||||
@ -114,23 +111,21 @@ defmodule MemexWeb.NoteLiveTest do
|
||||
|
||||
test "updates note within modal", %{conn: conn, note: note} do
|
||||
{:ok, show_live, _html} = live(conn, Routes.note_show_path(conn, :show, note.slug))
|
||||
|
||||
assert show_live |> element("a", "edit") |> render_click() =~ "edit"
|
||||
|
||||
assert_patch(show_live, Routes.note_show_path(conn, :edit, note.slug))
|
||||
|
||||
assert show_live
|
||||
|> form("#note-form", note: @invalid_attrs)
|
||||
|> render_change() =~ "can't be blank"
|
||||
|> form("#note-form")
|
||||
|> render_change(note: @invalid_attrs) =~ "can't be blank"
|
||||
|
||||
{:ok, _live, html} =
|
||||
show_live
|
||||
|> form("#note-form", note: Map.put(@update_attrs, "slug", note.slug))
|
||||
|> render_submit()
|
||||
|> form("#note-form")
|
||||
|> render_submit(note: @update_attrs |> Map.put(:slug, note.slug))
|
||||
|> follow_redirect(conn, Routes.note_show_path(conn, :show, note.slug))
|
||||
|
||||
assert html =~ "#{note.slug} saved"
|
||||
assert html =~ "tag2"
|
||||
assert html =~ note.slug
|
||||
end
|
||||
|
||||
test "deletes note", %{conn: conn, note: note} do
|
||||
@ -159,12 +154,12 @@ defmodule MemexWeb.NoteLiveTest do
|
||||
]
|
||||
end
|
||||
|
||||
test "searches by tag", %{conn: conn, note: note} do
|
||||
test "searches by tag", %{conn: conn, note: %{tags: [tag]} = note} do
|
||||
{:ok, show_live, html} = live(conn, Routes.note_show_path(conn, :show, note.slug))
|
||||
|
||||
assert html =~ "example-tag"
|
||||
assert show_live |> element("a", "example-tag") |> render_click()
|
||||
assert_redirect(show_live, Routes.note_index_path(conn, :search, "example-tag"))
|
||||
assert html =~ tag
|
||||
assert show_live |> element("a", tag) |> render_click()
|
||||
assert_redirect(show_live, Routes.note_index_path(conn, :search, tag))
|
||||
end
|
||||
|
||||
test "displays context", %{
|
||||
|
@ -1,37 +1,37 @@
|
||||
defmodule MemexWeb.PipelineLiveTest do
|
||||
use MemexWeb.ConnCase
|
||||
import Phoenix.LiveViewTest
|
||||
import Memex.{PipelinesFixtures, StepsFixtures}
|
||||
import Memex.Fixtures
|
||||
|
||||
@create_attrs %{
|
||||
"description" => "some description",
|
||||
"tags_string" => "tag1",
|
||||
"slug" => "some-slug",
|
||||
"visibility" => :public
|
||||
description: "some description",
|
||||
tags_string: "tag1",
|
||||
slug: "some-slug",
|
||||
visibility: :public
|
||||
}
|
||||
@update_attrs %{
|
||||
"description" => "some updated description",
|
||||
"tags_string" => "tag1,tag2",
|
||||
"slug" => "some-updated-slug",
|
||||
"visibility" => :private
|
||||
description: "some updated description",
|
||||
tags_string: "tag1,tag2",
|
||||
slug: "some-updated-slug",
|
||||
visibility: :private
|
||||
}
|
||||
@invalid_attrs %{
|
||||
"description" => nil,
|
||||
"tags_string" => " ",
|
||||
"slug" => nil,
|
||||
"visibility" => nil
|
||||
description: nil,
|
||||
tags_string: " ",
|
||||
slug: nil,
|
||||
visibility: nil
|
||||
}
|
||||
@step_create_attrs %{
|
||||
"content" => "some content",
|
||||
"title" => "some title"
|
||||
content: "some content",
|
||||
title: "some title"
|
||||
}
|
||||
@step_update_attrs %{
|
||||
"content" => "some updated content",
|
||||
"title" => "some updated title"
|
||||
content: "some updated content",
|
||||
title: "some updated title"
|
||||
}
|
||||
@step_invalid_attrs %{
|
||||
"content" => nil,
|
||||
"title" => nil
|
||||
content: nil,
|
||||
title: nil
|
||||
}
|
||||
|
||||
defp create_pipeline(%{current_user: current_user}) do
|
||||
@ -48,34 +48,32 @@ defmodule MemexWeb.PipelineLiveTest do
|
||||
assert html =~ pipeline.description
|
||||
end
|
||||
|
||||
test "searches by tag", %{conn: conn} do
|
||||
test "searches by tag", %{conn: conn, pipeline: %{tags: [tag]}} do
|
||||
{:ok, index_live, html} = live(conn, Routes.pipeline_index_path(conn, :index))
|
||||
|
||||
assert html =~ "example-tag"
|
||||
assert index_live |> element("a", "example-tag") |> render_click()
|
||||
assert_patch(index_live, Routes.pipeline_index_path(conn, :search, "example-tag"))
|
||||
assert html =~ tag
|
||||
assert index_live |> element("a", tag) |> render_click()
|
||||
assert_patch(index_live, Routes.pipeline_index_path(conn, :search, tag))
|
||||
end
|
||||
|
||||
test "saves new pipeline", %{conn: conn} do
|
||||
{:ok, index_live, _html} = live(conn, Routes.pipeline_index_path(conn, :index))
|
||||
|
||||
assert index_live |> element("a", "new pipeline") |> render_click() =~
|
||||
"new pipeline"
|
||||
|
||||
assert index_live |> element("a", "new pipeline") |> render_click() =~ "new pipeline"
|
||||
assert_patch(index_live, Routes.pipeline_index_path(conn, :new))
|
||||
|
||||
assert index_live
|
||||
|> form("#pipeline-form", pipeline: @invalid_attrs)
|
||||
|> render_change() =~ "can't be blank"
|
||||
|> form("#pipeline-form")
|
||||
|> render_change(pipeline: @invalid_attrs) =~ "can't be blank"
|
||||
|
||||
{:ok, _live, html} =
|
||||
index_live
|
||||
|> form("#pipeline-form", pipeline: @create_attrs)
|
||||
|> render_submit()
|
||||
|> form("#pipeline-form")
|
||||
|> render_submit(pipeline: @create_attrs)
|
||||
|> follow_redirect(conn, Routes.pipeline_index_path(conn, :index))
|
||||
|
||||
assert html =~ "#{@create_attrs |> Map.get("slug")} created"
|
||||
assert html =~ "some description"
|
||||
assert html =~ "#{@create_attrs.slug} created"
|
||||
assert html =~ @create_attrs.description
|
||||
end
|
||||
|
||||
test "updates pipeline in listing", %{conn: conn, pipeline: pipeline} do
|
||||
@ -87,17 +85,17 @@ defmodule MemexWeb.PipelineLiveTest do
|
||||
assert_patch(index_live, Routes.pipeline_index_path(conn, :edit, pipeline.slug))
|
||||
|
||||
assert index_live
|
||||
|> form("#pipeline-form", pipeline: @invalid_attrs)
|
||||
|> render_change() =~ "can't be blank"
|
||||
|> form("#pipeline-form")
|
||||
|> render_change(pipeline: @invalid_attrs) =~ "can't be blank"
|
||||
|
||||
{:ok, _live, html} =
|
||||
index_live
|
||||
|> form("#pipeline-form", pipeline: @update_attrs)
|
||||
|> render_submit()
|
||||
|> form("#pipeline-form")
|
||||
|> render_submit(pipeline: @update_attrs)
|
||||
|> follow_redirect(conn, Routes.pipeline_index_path(conn, :index))
|
||||
|
||||
assert html =~ "#{@update_attrs |> Map.get("slug")} saved"
|
||||
assert html =~ "some updated description"
|
||||
assert html =~ "#{@update_attrs.slug} saved"
|
||||
assert html =~ @update_attrs.description
|
||||
end
|
||||
|
||||
test "deletes pipeline in listing", %{conn: conn, pipeline: pipeline} do
|
||||
@ -123,27 +121,25 @@ 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.slug))
|
||||
|
||||
assert show_live |> element("a", "edit") |> render_click() =~ "edit"
|
||||
|
||||
assert_patch(show_live, Routes.pipeline_show_path(conn, :edit, pipeline.slug))
|
||||
|
||||
html =
|
||||
show_live
|
||||
|> form("#pipeline-form", pipeline: @invalid_attrs)
|
||||
|> render_change()
|
||||
|> form("#pipeline-form")
|
||||
|> render_change(pipeline: @invalid_attrs)
|
||||
|
||||
assert html =~ "can't be blank"
|
||||
assert html =~ "tags must be comma-delimited"
|
||||
|
||||
{:ok, _live, html} =
|
||||
show_live
|
||||
|> form("#pipeline-form", pipeline: Map.put(@update_attrs, "slug", pipeline.slug))
|
||||
|> render_submit()
|
||||
|> form("#pipeline-form")
|
||||
|> render_submit(pipeline: @update_attrs |> Map.put(:slug, pipeline.slug))
|
||||
|> follow_redirect(conn, Routes.pipeline_show_path(conn, :show, pipeline.slug))
|
||||
|
||||
assert html =~ "#{pipeline.slug} saved"
|
||||
assert html =~ "some updated description"
|
||||
assert html =~ @update_attrs.description
|
||||
end
|
||||
|
||||
test "deletes pipeline", %{conn: conn, pipeline: pipeline} do
|
||||
@ -160,19 +156,17 @@ defmodule MemexWeb.PipelineLiveTest do
|
||||
|
||||
test "creates a step", %{conn: conn, pipeline: pipeline} do
|
||||
{:ok, show_live, _html} = live(conn, Routes.pipeline_show_path(conn, :show, pipeline.slug))
|
||||
|
||||
show_live |> element("a", "add step") |> render_click()
|
||||
|
||||
assert_patch(show_live, Routes.pipeline_show_path(conn, :add_step, pipeline.slug))
|
||||
|
||||
{:ok, _show_live, html} =
|
||||
show_live
|
||||
|> form("#step-form", step: @step_create_attrs)
|
||||
|> render_submit()
|
||||
|> form("#step-form")
|
||||
|> render_submit(step: @step_create_attrs)
|
||||
|> follow_redirect(conn, Routes.pipeline_show_path(conn, :show, pipeline.slug))
|
||||
|
||||
assert html =~ "some title created"
|
||||
assert html =~ "some description"
|
||||
assert html =~ @step_create_attrs.title
|
||||
assert html =~ @step_create_attrs.content
|
||||
end
|
||||
end
|
||||
|
||||
@ -185,12 +179,12 @@ defmodule MemexWeb.PipelineLiveTest do
|
||||
]
|
||||
end
|
||||
|
||||
test "searches by tag", %{conn: conn, pipeline: pipeline} do
|
||||
test "searches by tag", %{conn: conn, pipeline: %{tags: [tag]} = pipeline} do
|
||||
{:ok, show_live, html} = live(conn, Routes.pipeline_show_path(conn, :show, pipeline.slug))
|
||||
|
||||
assert html =~ "example-tag"
|
||||
assert show_live |> element("a", "example-tag") |> render_click()
|
||||
assert_redirect(show_live, Routes.pipeline_index_path(conn, :search, "example-tag"))
|
||||
assert html =~ tag
|
||||
assert show_live |> element("a", tag) |> render_click()
|
||||
assert_redirect(show_live, Routes.pipeline_index_path(conn, :search, tag))
|
||||
end
|
||||
|
||||
test "updates a step", %{conn: conn, pipeline: pipeline, step: step} do
|
||||
@ -203,17 +197,17 @@ defmodule MemexWeb.PipelineLiveTest do
|
||||
assert_patch(show_live, Routes.pipeline_show_path(conn, :edit_step, pipeline.slug, step.id))
|
||||
|
||||
assert show_live
|
||||
|> form("#step-form", step: @step_invalid_attrs)
|
||||
|> render_change() =~ "can't be blank"
|
||||
|> form("#step-form")
|
||||
|> render_change(step: @step_invalid_attrs) =~ "can't be blank"
|
||||
|
||||
{:ok, _show_live, html} =
|
||||
show_live
|
||||
|> form("#step-form", step: @step_update_attrs)
|
||||
|> render_submit()
|
||||
|> form("#step-form")
|
||||
|> render_submit(step: @step_update_attrs)
|
||||
|> follow_redirect(conn, Routes.pipeline_show_path(conn, :show, pipeline.slug))
|
||||
|
||||
assert html =~ "some updated title saved"
|
||||
assert html =~ "some updated content"
|
||||
assert html =~ @step_update_attrs.title
|
||||
assert html =~ @step_update_attrs.content
|
||||
end
|
||||
|
||||
test "deletes a step", %{conn: conn, pipeline: pipeline, step: step} do
|
||||
@ -226,8 +220,8 @@ defmodule MemexWeb.PipelineLiveTest do
|
||||
|
||||
assert_patch(show_live, Routes.pipeline_show_path(conn, :show, pipeline.slug))
|
||||
|
||||
assert html =~ "some title deleted"
|
||||
refute html =~ "some updated content"
|
||||
assert html =~ "#{step.title} deleted"
|
||||
refute html =~ step.content
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user