From 1f92c452d15d42f7cc9288f602cb52eacada9dec Mon Sep 17 00:00:00 2001 From: shibao Date: Fri, 25 Feb 2022 22:17:30 -0500 Subject: [PATCH] fix tests --- .../live/invite_live/form_component.ex | 2 +- mix.exs | 1 + priv/gettext/actions.pot | 20 +++++++ priv/gettext/default.pot | 52 +++++++++++++++++ priv/gettext/errors.pot | 5 ++ priv/gettext/prompts.pot | 57 +++++++++++++++++++ test/lokal/accounts_test.exs | 2 +- test/lokal/invites_text.exs | 2 +- .../user_registration_controller_test.exs | 6 -- test/support/conn_case.ex | 2 +- test/support/fixtures.ex | 8 +-- 11 files changed, 143 insertions(+), 14 deletions(-) diff --git a/lib/lokal_web/live/invite_live/form_component.ex b/lib/lokal_web/live/invite_live/form_component.ex index 36b670c..f694d0d 100644 --- a/lib/lokal_web/live/invite_live/form_component.ex +++ b/lib/lokal_web/live/invite_live/form_component.ex @@ -4,8 +4,8 @@ defmodule LokalWeb.InviteLive.FormComponent do """ use LokalWeb, :live_component - alias Lokal.{Accounts.User, Invites, Invites.Invite} alias Ecto.Changeset + alias Lokal.{Accounts.User, Invites, Invites.Invite} alias Phoenix.LiveView.Socket @impl true diff --git a/mix.exs b/mix.exs index ef193ed..07ec05c 100644 --- a/mix.exs +++ b/mix.exs @@ -12,6 +12,7 @@ defmodule Lokal.MixProject do aliases: aliases(), deps: deps(), dialyzer: [plt_add_apps: [:ex_unit]], + consolidate_protocols: Mix.env() not in [:dev, :test], # ExDoc name: "Lokal", source_url: "https://gitea.bubbletea.dev/shibao/lokal", diff --git a/priv/gettext/actions.pot b/priv/gettext/actions.pot index ea067a2..6522d3a 100644 --- a/priv/gettext/actions.pot +++ b/priv/gettext/actions.pot @@ -72,3 +72,23 @@ msgstr "" #: lib/lokal_web/templates/user_reset_password/new.html.heex:16 msgid "Send instructions to reset password" msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/index.html.heex:32 +msgid "Copy to clipboard" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/index.html.heex:16 +msgid "Create Invite" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/index.html.heex:11 +msgid "Invite someone new!" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/form_component.html.heex:28 +msgid "Save" +msgstr "" diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index bc0761e..ec559f0 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -38,6 +38,8 @@ msgstr "" #, elixir-autogen, elixir-format #: lib/lokal_web/components/topbar.ex:58 +#: lib/lokal_web/live/invite_live/index.ex:43 +#: lib/lokal_web/live/invite_live/index.html.heex:3 msgid "Invites" msgstr "" @@ -101,3 +103,53 @@ msgstr "" #: lib/lokal_web/live/page_live.ex:13 msgid "Home" msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/index.html.heex:89 +msgid "Admins" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/index.html.heex:58 +msgid "Disable" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/index.ex:35 +msgid "Edit Invite" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/index.html.heex:62 +msgid "Enable" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/form_component.html.heex:20 +msgid "Name" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/index.ex:39 +msgid "New Invite" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/index.html.heex:8 +msgid "No invites 😔" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/index.html.heex:78 +msgid "Set Unlimited" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/index.html.heex:118 +msgid "Users" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/form_component.html.heex:24 +msgid "Uses left" +msgstr "" diff --git a/priv/gettext/errors.pot b/priv/gettext/errors.pot index 42e47e3..31e03e7 100644 --- a/priv/gettext/errors.pot +++ b/priv/gettext/errors.pot @@ -193,3 +193,8 @@ msgstr "" #: lib/lokal/accounts/user.ex:82 msgid "must have the @ sign and no spaces" msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/index.ex:20 +msgid "You are not authorized to view this page" +msgstr "" diff --git a/priv/gettext/prompts.pot b/priv/gettext/prompts.pot index f9310b8..3ab08a5 100644 --- a/priv/gettext/prompts.pot +++ b/priv/gettext/prompts.pot @@ -69,3 +69,60 @@ msgstr "" #: lib/lokal_web/controllers/user_settings_controller.ex:78 msgid "Your account has been deleted" msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/form_component.ex:59 +msgid "%{name} created successfully" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/index.ex:55 +#: lib/lokal_web/live/invite_live/index.ex:135 +msgid "%{name} deleted succesfully" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/index.ex:111 +msgid "%{name} disabled succesfully" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/index.ex:89 +msgid "%{name} enabled succesfully" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/index.ex:69 +msgid "%{name} updated succesfully" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/form_component.ex:41 +msgid "%{name} updated successfully" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/index.html.heex:101 +#: lib/lokal_web/live/invite_live/index.html.heex:130 +msgid "Are you sure you want to delete %{email}? This action is permanent!" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/index.html.heex:48 +msgid "Are you sure you want to delete the invite for %{name}?" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/index.html.heex:73 +msgid "Are you sure you want to make %{name} unlimited?" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/index.ex:123 +msgid "Copied to clipboard" +msgstr "" + +#, elixir-autogen, elixir-format +#: lib/lokal_web/live/invite_live/form_component.html.heex:30 +msgid "Saving..." +msgstr "" diff --git a/test/lokal/accounts_test.exs b/test/lokal/accounts_test.exs index 4e27583..012cd97 100644 --- a/test/lokal/accounts_test.exs +++ b/test/lokal/accounts_test.exs @@ -4,9 +4,9 @@ defmodule Lokal.AccountsTest do """ use Lokal.DataCase + alias Ecto.Changeset alias Lokal.Accounts alias Lokal.Accounts.{User, UserToken} - alias Ecto.Changeset @moduletag :accounts_test diff --git a/test/lokal/invites_text.exs b/test/lokal/invites_text.exs index 7d9425d..e27fdcd 100644 --- a/test/lokal/invites_text.exs +++ b/test/lokal/invites_text.exs @@ -4,8 +4,8 @@ defmodule Lokal.InvitesTest do """ use Lokal.DataCase - alias Lokal.{Invites, Invites.Invite} alias Ecto.Changeset + alias Lokal.{Invites, Invites.Invite} @moduletag :invites_test diff --git a/test/lokal_web/controllers/user_registration_controller_test.exs b/test/lokal_web/controllers/user_registration_controller_test.exs index 43b6350..f642827 100644 --- a/test/lokal_web/controllers/user_registration_controller_test.exs +++ b/test/lokal_web/controllers/user_registration_controller_test.exs @@ -37,12 +37,6 @@ defmodule LokalWeb.UserRegistrationControllerTest do } assert redirected_to(conn) =~ "/" - - # Now do a logged in request and assert on the menu - conn = get(conn, "/") - response = html_response(conn, 200) - # user's email is recorded as admin - assert response =~ email end test "render errors for invalid data", %{conn: conn} do diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex index 8fe466a..9734d59 100644 --- a/test/support/conn_case.ex +++ b/test/support/conn_case.ex @@ -17,8 +17,8 @@ defmodule LokalWeb.ConnCase do use ExUnit.CaseTemplate import Lokal.Fixtures - alias Lokal.{Accounts, Accounts.User, Repo} alias Ecto.Adapters.SQL.Sandbox + alias Lokal.{Accounts, Accounts.User, Repo} using do quote do diff --git a/test/support/fixtures.ex b/test/support/fixtures.ex index 7f46534..23c77ca 100644 --- a/test/support/fixtures.ex +++ b/test/support/fixtures.ex @@ -8,8 +8,8 @@ defmodule Lokal.Fixtures do def unique_user_email, do: "user#{System.unique_integer()}@example.com" def valid_user_password, do: "hello world!" - @spec user_fixture() :: Accounts.User.t() - @spec user_fixture(attrs :: map()) :: Accounts.User.t() + @spec user_fixture() :: User.t() + @spec user_fixture(attrs :: map()) :: User.t() def user_fixture(attrs \\ %{}) do attrs |> Enum.into(%{ @@ -20,8 +20,8 @@ defmodule Lokal.Fixtures do |> unwrap_ok_tuple() end - @spec admin_fixture() :: Accounts.User.t() - @spec admin_fixture(attrs :: map()) :: Accounts.User.t() + @spec admin_fixture() :: User.t() + @spec admin_fixture(attrs :: map()) :: User.t() def admin_fixture(attrs \\ %{}) do attrs |> Enum.into(%{