defmodule BDS.Desktop.ImportShellLiveTest do use ExUnit.Case, async: false import Phoenix.ConnTest import Phoenix.LiveViewTest alias BDS.ImportDefinitions alias BDS.Projects @endpoint BDS.Desktop.Endpoint setup do :ok = Ecto.Adapters.SQL.Sandbox.checkout(BDS.Repo) Ecto.Adapters.SQL.Sandbox.mode(BDS.Repo, {:shared, self()}) temp_dir = Path.join(System.tmp_dir!(), "bds-import-shell-live-#{System.unique_integer([:positive])}") File.mkdir_p!(temp_dir) on_exit(fn -> File.rm_rf(temp_dir) end) {:ok, project} = Projects.create_project(%{name: "Import Shell", data_path: temp_dir}) {:ok, _project} = Projects.set_active_project(project.id) %{project: project, temp_dir: temp_dir} end test "opening an import definition renders the dedicated import analysis editor instead of the fallback shell frame", %{project: project, temp_dir: temp_dir} do uploads_dir = Path.join(temp_dir, "uploads") wxr_path = Path.join(temp_dir, "legacy.xml") assert {:ok, definition} = ImportDefinitions.create_definition(%{ project_id: project.id, name: "Legacy Import", wxr_file_path: wxr_path, uploads_folder_path: uploads_dir, last_analysis_result: Jason.encode!(cached_report(wxr_path, uploads_dir)) }) {:ok, view, _html} = live_isolated(build_conn(), BDS.Desktop.ShellLive) _html = render_click(view, "select_view", %{"view" => "import"}) html = view |> element("[data-testid='sidebar-open-item'][data-item-id='#{definition.id}']") |> render_click() assert html =~ ~s(data-testid="import-editor") assert html =~ ~s(data-testid="import-editor-form") assert html =~ "Legacy Import" assert html =~ "Uploads Folder" assert html =~ "WXR File" assert html =~ "Ready to import:" assert html =~ "Import 5 Items" assert html =~ "Post Slug Conflicts" assert html =~ ~s(