chore: rename ImportExport module to Import
This commit is contained in:
parent
ce542eae3e
commit
b18f895939
10 changed files with 161 additions and 197 deletions
|
|
@ -42,7 +42,7 @@ defmodule MvWeb.GlobalSettingsLiveConfigTest do
|
|||
# Arrange: Set custom row limit to 500
|
||||
Application.put_env(:mv, :csv_import, max_rows: 500)
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import-export")
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import")
|
||||
|
||||
# Generate CSV with 501 rows (exceeding custom limit of 500)
|
||||
header = "first_name;last_name;email;street;postal_code;city\n"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
defmodule MvWeb.ImportExportLiveTest do
|
||||
defmodule MvWeb.ImportLiveTest do
|
||||
@moduledoc """
|
||||
Tests for Import/Export LiveView: authorization (business rule), CSV import integration,
|
||||
Tests for Import LiveView: authorization (business rule), CSV import integration,
|
||||
and minimal UI smoke tests. CSV parsing/validation logic is covered by
|
||||
Mv.Membership.Import.MemberCSVTest; here we verify access control and end-to-end outcomes.
|
||||
"""
|
||||
|
|
@ -31,7 +31,7 @@ defmodule MvWeb.ImportExportLiveTest do
|
|||
|
||||
# ---------- Business logic: Authorization ----------
|
||||
describe "Authorization" do
|
||||
test "non-admin user cannot access import/export page and sees permission error", %{
|
||||
test "non-admin user cannot access import page and sees permission error", %{
|
||||
conn: conn
|
||||
} do
|
||||
member_user = Mv.Fixtures.user_with_role_fixture("own_data")
|
||||
|
|
@ -42,7 +42,7 @@ defmodule MvWeb.ImportExportLiveTest do
|
|||
|> put_locale_en()
|
||||
|
||||
assert {:error, {:redirect, %{to: redirect_path, flash: %{"error" => msg}}}} =
|
||||
live(conn, ~p"/admin/import-export")
|
||||
live(conn, ~p"/admin/import")
|
||||
|
||||
assert redirect_path =~ "/users/"
|
||||
assert msg =~ "don't have permission"
|
||||
|
|
@ -55,7 +55,7 @@ defmodule MvWeb.ImportExportLiveTest do
|
|||
Path.join([__DIR__, "..", "..", "fixtures", "valid_member_import.csv"])
|
||||
|> File.read!()
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import-export")
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import")
|
||||
upload_csv_file(view, csv_content)
|
||||
submit_import(view)
|
||||
wait_for_import_completion()
|
||||
|
|
@ -109,7 +109,7 @@ defmodule MvWeb.ImportExportLiveTest do
|
|||
end
|
||||
|
||||
test "invalid CSV shows user-friendly prepare error", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import-export")
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import")
|
||||
upload_csv_file(view, "invalid_header\nincomplete_row", "invalid.csv")
|
||||
submit_import(view)
|
||||
html = render(view)
|
||||
|
|
@ -120,7 +120,7 @@ defmodule MvWeb.ImportExportLiveTest do
|
|||
conn: conn,
|
||||
invalid_csv: csv_content
|
||||
} do
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import-export")
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import")
|
||||
upload_csv_file(view, csv_content, "invalid_import.csv")
|
||||
submit_import(view)
|
||||
wait_for_import_completion()
|
||||
|
|
@ -135,7 +135,7 @@ defmodule MvWeb.ImportExportLiveTest do
|
|||
end
|
||||
|
||||
test "error list is capped and truncation message is shown", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import-export")
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import")
|
||||
header = "first_name;last_name;email;street;postal_code;city\n"
|
||||
|
||||
invalid_rows =
|
||||
|
|
@ -153,7 +153,7 @@ defmodule MvWeb.ImportExportLiveTest do
|
|||
end
|
||||
|
||||
test "row limit is enforced (1001 rows rejected)", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import-export")
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import")
|
||||
header = "first_name;last_name;email;street;postal_code;city\n"
|
||||
|
||||
rows =
|
||||
|
|
@ -168,7 +168,7 @@ defmodule MvWeb.ImportExportLiveTest do
|
|||
end
|
||||
|
||||
test "BOM and semicolon delimiter are accepted", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import-export")
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import")
|
||||
|
||||
csv_content =
|
||||
Path.join([__DIR__, "..", "..", "fixtures", "csv_with_bom_semicolon.csv"])
|
||||
|
|
@ -187,7 +187,7 @@ defmodule MvWeb.ImportExportLiveTest do
|
|||
test "physical line numbers in errors (empty line does not shift numbering)", %{
|
||||
conn: conn
|
||||
} do
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import-export")
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import")
|
||||
|
||||
csv_content =
|
||||
Path.join([__DIR__, "..", "..", "fixtures", "csv_with_empty_lines.csv"])
|
||||
|
|
@ -207,7 +207,7 @@ defmodule MvWeb.ImportExportLiveTest do
|
|||
conn: conn,
|
||||
unknown_custom_field_csv: csv_content
|
||||
} do
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import-export")
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import")
|
||||
upload_csv_file(view, csv_content, "unknown_custom.csv")
|
||||
submit_import(view)
|
||||
wait_for_import_completion()
|
||||
|
|
@ -220,7 +220,7 @@ defmodule MvWeb.ImportExportLiveTest do
|
|||
end
|
||||
|
||||
# ---------- UI (smoke / framework): tagged for exclusion from fast CI ----------
|
||||
describe "Import/Export page UI" do
|
||||
describe "Import page UI" do
|
||||
@describetag :ui
|
||||
setup %{conn: conn} do
|
||||
admin_user = Mv.Fixtures.user_with_role_fixture("admin")
|
||||
|
|
@ -233,19 +233,17 @@ defmodule MvWeb.ImportExportLiveTest do
|
|||
{:ok, conn: conn}
|
||||
end
|
||||
|
||||
test "page loads and shows import form and export placeholder", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import-export")
|
||||
test "page loads and shows import form", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import")
|
||||
assert has_element?(view, "[data-testid='csv-upload-form']")
|
||||
assert has_element?(view, "[data-testid='start-import-button']")
|
||||
assert has_element?(view, "[data-testid='custom-fields-link']")
|
||||
html = render(view)
|
||||
assert html =~ "Import Members (CSV)"
|
||||
assert html =~ "Export Members (CSV)"
|
||||
assert html =~ "Export functionality will be available"
|
||||
end
|
||||
|
||||
test "template links and file input are present", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import-export")
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import")
|
||||
assert has_element?(view, "a[href*='/templates/member_import_en.csv']")
|
||||
assert has_element?(view, "a[href*='/templates/member_import_de.csv']")
|
||||
assert has_element?(view, "label[for='csv_file']")
|
||||
|
|
@ -258,7 +256,7 @@ defmodule MvWeb.ImportExportLiveTest do
|
|||
Path.join([__DIR__, "..", "..", "fixtures", "valid_member_import.csv"])
|
||||
|> File.read!()
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import-export")
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import")
|
||||
upload_csv_file(view, csv_content)
|
||||
submit_import(view)
|
||||
wait_for_import_completion()
|
||||
|
|
@ -273,7 +271,7 @@ defmodule MvWeb.ImportExportLiveTest do
|
|||
@tag :skip
|
||||
test "empty CSV shows error", %{conn: conn} do
|
||||
conn = put_locale_en(conn)
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import-export")
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/import")
|
||||
upload_csv_file(view, " ", "empty.csv")
|
||||
submit_import(view)
|
||||
html = render(view)
|
||||
Loading…
Add table
Add a link
Reference in a new issue