fix: issue #35 validation expected unrendered .lang translation variant routes; main-language lists now render main-language translations
This commit is contained in:
@@ -1473,6 +1473,123 @@ defmodule BDS.GenerationTest do
|
||||
)
|
||||
end
|
||||
|
||||
test "validate_site reports no missing pages for main-language translations of foreign-language posts",
|
||||
%{project: project, temp_dir: temp_dir} do
|
||||
assert {:ok, _metadata} =
|
||||
Metadata.update_project_metadata(project.id, %{
|
||||
public_url: "https://example.com/blog",
|
||||
main_language: "de",
|
||||
blog_languages: ["de", "en"]
|
||||
})
|
||||
|
||||
assert {:ok, post} =
|
||||
Posts.create_post(%{
|
||||
project_id: project.id,
|
||||
title: "English Original",
|
||||
content: "English body",
|
||||
language: "en"
|
||||
})
|
||||
|
||||
created_at = DateTime.to_unix(~U[2026-04-15 12:00:00Z])
|
||||
|
||||
Repo.update_all(from(p in BDS.Posts.Post, where: p.id == ^post.id),
|
||||
set: [created_at: created_at, updated_at: created_at]
|
||||
)
|
||||
|
||||
assert {:ok, _translation} =
|
||||
Posts.upsert_post_translation(post.id, "de", %{
|
||||
title: "Deutsches Original",
|
||||
content: "Deutscher Inhalt"
|
||||
})
|
||||
|
||||
assert {:ok, published_post} = Posts.publish_post(post.id)
|
||||
assert {:ok, _result} = BDS.Generation.generate_site(project.id, [:core, :single])
|
||||
assert {:ok, report} = BDS.Generation.validate_site(project.id, [:core, :single])
|
||||
|
||||
assert report.missing_url_paths == []
|
||||
assert report.extra_url_paths == []
|
||||
assert report.updated_post_url_paths == []
|
||||
|
||||
canonical_html =
|
||||
File.read!(
|
||||
Path.join([temp_dir, "html", BDS.Generation.post_output_path(published_post)])
|
||||
)
|
||||
|
||||
english_html =
|
||||
File.read!(
|
||||
Path.join([temp_dir, "html", BDS.Generation.post_output_path(published_post, "en")])
|
||||
)
|
||||
|
||||
assert canonical_html =~ "Deutscher Inhalt"
|
||||
assert english_html =~ "English body"
|
||||
|
||||
sitemap_xml = File.read!(Path.join([temp_dir, "html", "sitemap.xml"]))
|
||||
|
||||
refute sitemap_xml =~ "english-original.de"
|
||||
end
|
||||
|
||||
test "main-language list pages and feeds use main-language translations of foreign-language posts",
|
||||
%{project: project, temp_dir: temp_dir} do
|
||||
assert {:ok, _metadata} =
|
||||
Metadata.update_project_metadata(project.id, %{
|
||||
public_url: "https://example.com/blog",
|
||||
main_language: "de",
|
||||
blog_languages: ["de", "en"]
|
||||
})
|
||||
|
||||
assert {:ok, post} =
|
||||
Posts.create_post(%{
|
||||
project_id: project.id,
|
||||
title: "English List Original",
|
||||
content: "English list body",
|
||||
language: "en",
|
||||
categories: ["notes"],
|
||||
tags: ["Elixir"]
|
||||
})
|
||||
|
||||
created_at = DateTime.to_unix(~U[2026-04-15 12:00:00Z])
|
||||
|
||||
Repo.update_all(from(p in BDS.Posts.Post, where: p.id == ^post.id),
|
||||
set: [created_at: created_at, updated_at: created_at]
|
||||
)
|
||||
|
||||
assert {:ok, _translation} =
|
||||
Posts.upsert_post_translation(post.id, "de", %{
|
||||
title: "Deutsche Listenfassung",
|
||||
content: "Deutscher Listeninhalt"
|
||||
})
|
||||
|
||||
assert {:ok, _published_post} = Posts.publish_post(post.id)
|
||||
|
||||
assert {:ok, _result} =
|
||||
BDS.Generation.generate_site(project.id, [:core, :single, :category, :tag, :date])
|
||||
|
||||
read_output = fn segments -> File.read!(Path.join([temp_dir, "html" | segments])) end
|
||||
|
||||
for segments <- [
|
||||
["index.html"],
|
||||
["rss.xml"],
|
||||
["atom.xml"],
|
||||
["category", "notes", "index.html"],
|
||||
["tag", "Elixir", "index.html"],
|
||||
["2026", "index.html"]
|
||||
] do
|
||||
html = read_output.(segments)
|
||||
assert html =~ "Deutsche Listenfassung", "expected translated title in #{Path.join(segments)}"
|
||||
refute html =~ "English List Original", "unexpected original title in #{Path.join(segments)}"
|
||||
end
|
||||
|
||||
for segments <- [
|
||||
["en", "index.html"],
|
||||
["en", "rss.xml"],
|
||||
["en", "category", "notes", "index.html"]
|
||||
] do
|
||||
html = read_output.(segments)
|
||||
assert html =~ "English List Original", "expected original title in #{Path.join(segments)}"
|
||||
refute html =~ "Deutsche Listenfassung", "unexpected translated title in #{Path.join(segments)}"
|
||||
end
|
||||
end
|
||||
|
||||
test "validate_site follows old language subtree expectations and combined sitemap output", %{
|
||||
project: project,
|
||||
temp_dir: temp_dir
|
||||
|
||||
Reference in New Issue
Block a user