From fcc9058654dc5890d0c709e3280a346917ac3786 Mon Sep 17 00:00:00 2001 From: Pascal Schmid Date: Sun, 3 Nov 2024 13:44:51 +0100 Subject: [PATCH] Add PhoenixTest case --- config/test.exs | 2 ++ mix.exs | 1 + mix.lock | 1 + test/mihainator_web/upload_live_test.exs | 14 ++++++++++++++ test/support/conn_case.ex | 1 + 5 files changed, 19 insertions(+) create mode 100644 test/mihainator_web/upload_live_test.exs diff --git a/config/test.exs b/config/test.exs index a6e6a73..3d97159 100644 --- a/config/test.exs +++ b/config/test.exs @@ -16,3 +16,5 @@ config :phoenix, :plug_init_mode, :runtime # Enable helpful, but potentially expensive runtime checks config :phoenix_live_view, enable_expensive_runtime_checks: true + +config :phoenix_test, :endpoint, MihainatorWeb.Endpoint diff --git a/mix.exs b/mix.exs index 5aa14e8..a980ccb 100644 --- a/mix.exs +++ b/mix.exs @@ -54,6 +54,7 @@ defmodule Mihainator.MixProject do {:dns_cluster, "~> 0.1.1"}, {:bandit, "~> 1.5"}, {:credo, "~> 1.7", only: [:dev, :test], runtime: false}, + {:phoenix_test, "~> 0.4.2", only: :test, runtime: false}, {:csv, "~> 3.2"}, {:timex, "~> 3.7"} ] diff --git a/mix.lock b/mix.lock index 566d085..5f9e964 100644 --- a/mix.lock +++ b/mix.lock @@ -28,6 +28,7 @@ "phoenix_live_view": {:hex, :phoenix_live_view, "1.0.0-rc.6", "47d2669995ea326e5c71f5c1bc9177109cebf211385c638faa7b5862a401e516", [:mix], [{:floki, "~> 0.36", [hex: :floki, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.6.15 or ~> 1.7.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.3 or ~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.15", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "e56e4f1642a0b20edc2488cab30e5439595e0d8b5b259f76ef98b1c4e2e5b527"}, "phoenix_pubsub": {:hex, :phoenix_pubsub, "2.1.3", "3168d78ba41835aecad272d5e8cd51aa87a7ac9eb836eabc42f6e57538e3731d", [:mix], [], "hexpm", "bba06bc1dcfd8cb086759f0edc94a8ba2bc8896d5331a1e2c2902bf8e36ee502"}, "phoenix_template": {:hex, :phoenix_template, "1.0.4", "e2092c132f3b5e5b2d49c96695342eb36d0ed514c5b252a77048d5969330d639", [:mix], [{:phoenix_html, "~> 2.14.2 or ~> 3.0 or ~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}], "hexpm", "2c0c81f0e5c6753faf5cca2f229c9709919aba34fab866d3bc05060c9c444206"}, + "phoenix_test": {:hex, :phoenix_test, "0.4.2", "bc00efd2bf736bc23bc40dbfd841aab88f14f767addb40b884d7910241e521b5", [:mix], [{:floki, ">= 0.30.0", [hex: :floki, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, ">= 1.0.0", [hex: :mime, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.7.10", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.20.1", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "22a1fab760aefb60f214c0796999bf167962583dd313fb595502500041668b5c"}, "plug": {:hex, :plug, "1.16.1", "40c74619c12f82736d2214557dedec2e9762029b2438d6d175c5074c933edc9d", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "a13ff6b9006b03d7e33874945b2755253841b238c34071ed85b0e86057f8cddc"}, "plug_crypto": {:hex, :plug_crypto, "2.1.0", "f44309c2b06d249c27c8d3f65cfe08158ade08418cf540fd4f72d4d6863abb7b", [:mix], [], "hexpm", "131216a4b030b8f8ce0f26038bc4421ae60e4bb95c5cf5395e1421437824c4fa"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"}, diff --git a/test/mihainator_web/upload_live_test.exs b/test/mihainator_web/upload_live_test.exs new file mode 100644 index 0000000..849a6e7 --- /dev/null +++ b/test/mihainator_web/upload_live_test.exs @@ -0,0 +1,14 @@ +defmodule MihainatorWeb.UploadLiveTest do + @moduledoc false + + use MihainatorWeb.ConnCase + + test "calender has markings for interaction days", %{conn: conn} do + conn + |> visit("/") + |> upload("CSV file", "data/test.csv") + |> click_button("Upload") + |> assert_has("button.bg-green-300") + |> assert_has("button.bg-red-300") + end +end diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex index 7eb6450..cf1f307 100644 --- a/test/support/conn_case.ex +++ b/test/support/conn_case.ex @@ -28,6 +28,7 @@ defmodule MihainatorWeb.ConnCase do import Plug.Conn import Phoenix.ConnTest import MihainatorWeb.ConnCase + import PhoenixTest end end