This commit is contained in:
parent
9b9e7ec995
commit
8e387d8e17
5 changed files with 429 additions and 79 deletions
|
|
@ -48,34 +48,28 @@ defmodule MvWeb.MemberLive.IndexTest do
|
|||
|
||||
describe "translations" do
|
||||
@describetag :ui
|
||||
test "shows translated title in German", %{conn: conn} do
|
||||
conn = conn_with_oidc_user(conn)
|
||||
conn = Plug.Test.init_test_session(conn, locale: "de")
|
||||
{:ok, _view, html} = live(conn, "/members")
|
||||
# Expected German title
|
||||
assert html =~ "Mitglieder"
|
||||
end
|
||||
|
||||
test "shows translated title in English", %{conn: conn} do
|
||||
conn = conn_with_oidc_user(conn)
|
||||
Gettext.put_locale(MvWeb.Gettext, "en")
|
||||
{:ok, _view, html} = live(conn, "/members")
|
||||
# Expected English title
|
||||
assert html =~ "Members"
|
||||
end
|
||||
test "shows translated title and button text by locale", %{conn: conn} do
|
||||
locales = [
|
||||
{"de", "Mitglieder", "Speichern",
|
||||
fn c -> Plug.Test.init_test_session(c, locale: "de") end},
|
||||
{"en", "Members", "Save",
|
||||
fn c ->
|
||||
Gettext.put_locale(MvWeb.Gettext, "en")
|
||||
c
|
||||
end}
|
||||
]
|
||||
|
||||
test "shows translated button text in German", %{conn: conn} do
|
||||
conn = conn_with_oidc_user(conn)
|
||||
conn = Plug.Test.init_test_session(conn, locale: "de")
|
||||
{:ok, _view, html} = live(conn, "/members/new")
|
||||
assert html =~ "Speichern"
|
||||
end
|
||||
for {_locale, expected_title, expected_button, set_locale} <- locales do
|
||||
base = conn_with_oidc_user(conn) |> set_locale.()
|
||||
|
||||
test "shows translated button text in English", %{conn: conn} do
|
||||
conn = conn_with_oidc_user(conn)
|
||||
Gettext.put_locale(MvWeb.Gettext, "en")
|
||||
{:ok, _view, html} = live(conn, "/members/new")
|
||||
assert html =~ "Save"
|
||||
{:ok, _view, index_html} = live(base, "/members")
|
||||
assert index_html =~ expected_title
|
||||
|
||||
base_form = conn_with_oidc_user(conn) |> set_locale.()
|
||||
{:ok, _view, form_html} = live(base_form, "/members/new")
|
||||
assert form_html =~ expected_button
|
||||
end
|
||||
end
|
||||
|
||||
test "shows translated flash message after creating a member in German", %{conn: conn} do
|
||||
|
|
@ -543,7 +537,7 @@ defmodule MvWeb.MemberLive.IndexTest do
|
|||
|
||||
test "export button is rendered when no selection and shows (all)", %{conn: conn} do
|
||||
conn = conn_with_oidc_user(conn)
|
||||
{:ok, view, html} = live(conn, "/members")
|
||||
{:ok, _view, html} = live(conn, "/members")
|
||||
|
||||
# Button text shows "all" when 0 selected (locale-dependent)
|
||||
assert html =~ "Export to CSV"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue