fix: work on step 12
This commit is contained in:
@@ -97,16 +97,29 @@ defmodule BDS.Desktop.ImportShellLiveTest do
|
||||
%{
|
||||
item_type: "post",
|
||||
item_name: "hello-world",
|
||||
resolution: "skip",
|
||||
resolution: "ignore",
|
||||
source_title: "Hello World",
|
||||
existing_title: "Existing Hello"
|
||||
}
|
||||
],
|
||||
macros: [%{name: "gallery", usage_count: 1, parameters: ["ids"], validation_status: "unknown"}],
|
||||
macros: %{
|
||||
total: 1,
|
||||
mapped_count: 0,
|
||||
unmapped_count: 1,
|
||||
discovered: [
|
||||
%{
|
||||
name: "gallery",
|
||||
mapped: false,
|
||||
total_count: 1,
|
||||
usages: [%{params: %{"ids" => "1,2"}, count: 1, validation_status: "unknown"}],
|
||||
post_slugs: ["hello-world"]
|
||||
}
|
||||
]
|
||||
},
|
||||
items: %{
|
||||
posts: [
|
||||
%{item_type: "post", title: "Hello World", slug: "hello-world", status: "new"},
|
||||
%{item_type: "post", title: "Conflict Me", slug: "conflict-me", status: "conflict", resolution: "skip"}
|
||||
%{item_type: "post", title: "Conflict Me", slug: "conflict-me", status: "conflict", resolution: "ignore"}
|
||||
],
|
||||
pages: [
|
||||
%{item_type: "page", title: "About", slug: "about", status: "new"}
|
||||
@@ -145,7 +158,7 @@ defmodule BDS.Desktop.ImportShellLiveTest do
|
||||
title: "Conflict Me",
|
||||
slug: "conflict-me",
|
||||
status: "conflict",
|
||||
resolution: "skip",
|
||||
resolution: "ignore",
|
||||
wp_status: "publish",
|
||||
author: "Importer",
|
||||
categories: ["General"],
|
||||
|
||||
@@ -50,36 +50,30 @@ defmodule BDS.ImportAnalysisTest do
|
||||
row.year == 2024 and row.post_count == 2 and row.media_count == 1
|
||||
end)
|
||||
|
||||
assert [%{name: "gallery", usage_count: 1, parameters: ["ids"], validation_status: "unknown"}] = report.macros
|
||||
assert %{
|
||||
total: 1,
|
||||
mapped_count: 0,
|
||||
unmapped_count: 1,
|
||||
discovered: [
|
||||
%{
|
||||
name: "gallery",
|
||||
mapped: false,
|
||||
total_count: 1,
|
||||
usages: [%{params: %{"ids" => "1,2"}, count: 1, validation_status: "unknown"}],
|
||||
post_slugs: ["hello-world"]
|
||||
}
|
||||
]
|
||||
} = report.macros
|
||||
assert report.conflicts == []
|
||||
|
||||
assert report.items.posts == [
|
||||
%{
|
||||
title: "Hello World",
|
||||
slug: "hello-world",
|
||||
status: "new",
|
||||
item_type: "post"
|
||||
}
|
||||
]
|
||||
assert [%{title: "Hello World", slug: "hello-world", status: "new", item_type: "post", post_type: "post"}] =
|
||||
report.items.posts
|
||||
|
||||
assert report.items.pages == [
|
||||
%{
|
||||
title: "About",
|
||||
slug: "about",
|
||||
status: "new",
|
||||
item_type: "page"
|
||||
}
|
||||
]
|
||||
assert [%{title: "About", slug: "about", status: "new", item_type: "page"} = page_item] = report.items.pages
|
||||
assert Map.get(page_item, :post_type) == "page"
|
||||
|
||||
assert report.items.media == [
|
||||
%{
|
||||
title: "Import Asset",
|
||||
filename: "import-asset.txt",
|
||||
relative_path: "2024/05/import-asset.txt",
|
||||
status: "new",
|
||||
item_type: "media"
|
||||
}
|
||||
]
|
||||
assert [%{title: "Import Asset", filename: "import-asset.txt", relative_path: "2024/05/import-asset.txt", status: "new", item_type: "media"}] =
|
||||
report.items.media
|
||||
end
|
||||
|
||||
test "analyze_wxr detects update, conflict, duplicate, existing taxonomy, and missing uploads", %{project: project, temp_dir: temp_dir} do
|
||||
@@ -140,12 +134,12 @@ defmodule BDS.ImportAnalysisTest do
|
||||
assert report.tag_stats == %{existing_count: 1, mapped_count: 0, new_count: 0}
|
||||
|
||||
assert Enum.any?(report.conflicts, fn conflict ->
|
||||
conflict.item_type == "post" and conflict.item_name == "conflict-me" and conflict.resolution == "skip"
|
||||
conflict.item_type == "post" and conflict.item_name == "conflict-me" and conflict.resolution == "ignore"
|
||||
end)
|
||||
|
||||
assert Enum.any?(report.items.posts, &(&1.slug == "update-me" and &1.status == "update"))
|
||||
assert Enum.any?(report.items.posts, &(&1.slug == "conflict-me" and &1.status == "conflict"))
|
||||
assert Enum.any?(report.items.posts, &(&1.slug == "duplicate-me" and &1.status == "duplicate"))
|
||||
assert Enum.any?(report.items.posts, &(&1.slug == "duplicate-me" and &1.status == "content-duplicate"))
|
||||
assert Enum.any?(report.items.media, &(&1.filename == "missing-asset.txt" and &1.status == "missing"))
|
||||
end
|
||||
|
||||
|
||||
@@ -90,7 +90,6 @@ defmodule BDS.ImportExecutionTest do
|
||||
|
||||
assert {:ok, imported_result} = ImportExecution.execute_import(project.id, import_report, default_author: "Imported Author")
|
||||
assert imported_result.posts == %{imported: 1, skipped: 0, errors: 0}
|
||||
|
||||
slugs = Repo.all(from post in Posts.Post, where: post.project_id == ^project.id, select: post.slug, order_by: [asc: post.slug])
|
||||
assert length(slugs) == 2
|
||||
assert "conflict-me" in slugs
|
||||
@@ -116,11 +115,11 @@ defmodule BDS.ImportExecutionTest do
|
||||
end
|
||||
)
|
||||
|
||||
assert_received {:execution_progress, "tags", 0, 2, "Creating tags..."}
|
||||
assert_received {:execution_progress, "posts", 0, 1, "Importing posts..."}
|
||||
assert_received {:execution_progress, "media", 0, 1, "Importing media..."}
|
||||
assert_received {:execution_progress, "pages", 0, 1, "Importing pages..."}
|
||||
assert_received {:execution_progress, "complete", 1, 1, "Import complete"}
|
||||
assert_received {:execution_progress, "tags", 0, 2, %{detail: "creating_tags"}}
|
||||
assert_received {:execution_progress, "posts", 0, 1, %{detail: "importing_posts"}}
|
||||
assert_received {:execution_progress, "media", 0, 1, %{detail: "importing_media"}}
|
||||
assert_received {:execution_progress, "pages", 0, 1, %{detail: "importing_pages"}}
|
||||
assert_received {:execution_progress, "complete", 1, 1, %{detail: "import_complete"}}
|
||||
end
|
||||
|
||||
defp sha256(value) do
|
||||
|
||||
Reference in New Issue
Block a user