ImplementsCSV Import UI closes #335 #359
1 changed files with 72 additions and 0 deletions
|
|
@ -81,4 +81,76 @@ defmodule MvWeb.GlobalSettingsLiveTest do
|
|||
assert render(view) =~ "updated" or render(view) =~ "success"
|
||||
end
|
||||
end
|
||||
|
||||
describe "CSV Import Section" do
|
||||
test "admin user sees import section", %{conn: conn} do
|
||||
{:ok, _view, html} = live(conn, ~p"/settings")
|
||||
|
||||
# Check for import section heading or identifier
|
||||
assert html =~ "Import" or html =~ "CSV" or html =~ "member_import"
|
||||
end
|
||||
|
||||
test "admin user sees custom fields notice", %{conn: conn} do
|
||||
{:ok, _view, html} = live(conn, ~p"/settings")
|
||||
|
||||
# Check for custom fields notice text
|
||||
assert html =~ "Custom fields" or html =~ "custom field"
|
||||
end
|
||||
|
||||
test "admin user sees template download links", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, ~p"/settings")
|
||||
|
||||
html = render(view)
|
||||
|
||||
# Check for English template link
|
||||
assert html =~ "member_import_en.csv" or html =~ "/templates/member_import_en.csv"
|
||||
|
||||
# Check for German template link
|
||||
assert html =~ "member_import_de.csv" or html =~ "/templates/member_import_de.csv"
|
||||
end
|
||||
|
||||
test "template links use static path helper", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, ~p"/settings")
|
||||
|
||||
html = render(view)
|
||||
|
||||
# Check that links contain the static path pattern
|
||||
# Static paths typically start with /templates/ or contain the full path
|
||||
assert html =~ "/templates/member_import_en.csv" or
|
||||
html =~ ~r/href=["'][^"']*member_import_en\.csv["']/
|
||||
|
||||
assert html =~ "/templates/member_import_de.csv" or
|
||||
html =~ ~r/href=["'][^"']*member_import_de\.csv["']/
|
||||
end
|
||||
|
||||
test "admin user sees file upload input", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, ~p"/settings")
|
||||
|
||||
html = render(view)
|
||||
|
||||
# Check for file input element
|
||||
assert html =~ ~r/type=["']file["']/i or html =~ "phx-hook" or html =~ "upload"
|
||||
end
|
||||
|
||||
test "file upload has CSV-only restriction", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, ~p"/settings")
|
||||
|
||||
html = render(view)
|
||||
|
||||
# Check for CSV file type restriction in help text or accept attribute
|
||||
assert html =~ ~r/\.csv/i or html =~ "CSV" or html =~ ~r/accept=["'][^"']*csv["']/i
|
||||
end
|
||||
|
||||
test "non-admin user does not see import section", %{conn: conn} do
|
||||
# Create non-admin user (member role)
|
||||
member_user = Mv.Fixtures.user_with_role_fixture("own_data")
|
||||
conn = MvWeb.ConnCase.conn_with_password_user(conn, member_user)
|
||||
|
||||
{:ok, _view, html} = live(conn, ~p"/settings")
|
||||
|
||||
# Import section should not be visible
|
||||
refute html =~ "Import Members" or html =~ "CSV Import" or
|
||||
(html =~ "Import" and html =~ "CSV")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue