feat: claims for having the js parts in (not working, though)
This commit is contained in:
@@ -6,6 +6,7 @@ defmodule BDS.GenerationTest do
|
||||
alias BDS.Media
|
||||
alias BDS.Metadata
|
||||
alias BDS.Posts
|
||||
alias BDS.PreviewAssets
|
||||
alias BDS.Repo
|
||||
|
||||
setup do
|
||||
@@ -113,7 +114,7 @@ defmodule BDS.GenerationTest do
|
||||
"de/pagefind/index.json",
|
||||
"de/pagefind/pagefind-ui.css",
|
||||
"de/pagefind/pagefind-ui.js"
|
||||
]
|
||||
] ++ Enum.map(PreviewAssets.generated_outputs(), &elem(&1, 0))
|
||||
|
||||
assert Enum.sort(Enum.map(result.generated_files, & &1.relative_path)) ==
|
||||
Enum.sort(expected_paths)
|
||||
@@ -125,6 +126,60 @@ defmodule BDS.GenerationTest do
|
||||
assert File.read!(Path.join([temp_dir, "html", "sitemap.xml"])) =~ "https://example.com/blog/"
|
||||
end
|
||||
|
||||
test "core generation writes local macro and preview assets for static html", %{
|
||||
project: project,
|
||||
temp_dir: temp_dir
|
||||
} do
|
||||
assert {:ok, _metadata} =
|
||||
Metadata.update_project_metadata(project.id, %{
|
||||
public_url: "https://example.com/blog",
|
||||
main_language: "en",
|
||||
blog_languages: ["en"],
|
||||
pico_theme: "green"
|
||||
})
|
||||
|
||||
assert {:ok, result} = BDS.Generation.generate_site(project.id, [:core])
|
||||
|
||||
expected_assets = [
|
||||
"assets/pico.min.css",
|
||||
"assets/pico.green.min.css",
|
||||
"assets/lightbox.min.css",
|
||||
"assets/lightbox.min.js",
|
||||
"assets/highlight.min.css",
|
||||
"assets/highlight.min.js",
|
||||
"assets/code-enhancements.js",
|
||||
"assets/d3.layout.cloud.js",
|
||||
"assets/tag-cloud.js",
|
||||
"assets/vanilla-calendar.min.css",
|
||||
"assets/vanilla-calendar.min.js",
|
||||
"assets/calendar-runtime.js",
|
||||
"assets/search-runtime.js",
|
||||
"assets/bds.css",
|
||||
"images/prev.png",
|
||||
"images/next.png",
|
||||
"images/close.png",
|
||||
"images/loading.gif"
|
||||
]
|
||||
|
||||
generated_paths = Enum.map(result.generated_files, & &1.relative_path)
|
||||
|
||||
for relative_path <- expected_assets do
|
||||
assert relative_path in generated_paths
|
||||
assert File.exists?(Path.join([temp_dir, "html", relative_path]))
|
||||
end
|
||||
|
||||
assert File.read!(Path.join([temp_dir, "html", "assets", "calendar-runtime.js"])) =~
|
||||
"loadCalendarData"
|
||||
|
||||
assert File.read!(Path.join([temp_dir, "html", "assets", "tag-cloud.js"])) =~
|
||||
"data-tag-cloud-words"
|
||||
|
||||
assert File.read!(Path.join([temp_dir, "html", "assets", "bds.css"])) =~ ".blog-menu"
|
||||
|
||||
assert File.read!(Path.join([temp_dir, "html", "assets", "pico.green.min.css"])) =~
|
||||
"color-scheme"
|
||||
end
|
||||
|
||||
test "generation writes feed and atom entries with canonical URLs for published posts", %{
|
||||
project: project,
|
||||
temp_dir: temp_dir
|
||||
|
||||
@@ -88,6 +88,23 @@ defmodule BDS.PreviewTest do
|
||||
|
||||
assert bds_css =~ ".blog-menu"
|
||||
|
||||
assert {:ok, %{body: calendar_runtime, content_type: "application/javascript"}} =
|
||||
BDS.Preview.request(project.id, "/assets/calendar-runtime.js")
|
||||
|
||||
assert calendar_runtime =~ "loadCalendarData"
|
||||
assert calendar_runtime =~ "window.location.assign"
|
||||
|
||||
assert {:ok, %{body: tag_cloud_runtime, content_type: "application/javascript"}} =
|
||||
BDS.Preview.request(project.id, "/assets/tag-cloud.js")
|
||||
|
||||
assert tag_cloud_runtime =~ "data-tag-cloud-words"
|
||||
|
||||
assert {:ok, %{body: _prev_png, content_type: "image/png"}} =
|
||||
BDS.Preview.request(project.id, "/images/prev.png")
|
||||
|
||||
assert {:ok, %{body: _loading_gif, content_type: "image/gif"}} =
|
||||
BDS.Preview.request(project.id, "/images/loading.gif")
|
||||
|
||||
assert {:ok, %{body: "media body", content_type: "text/plain"}} =
|
||||
BDS.Preview.request(project.id, "/media/2026/04/image.txt")
|
||||
|
||||
@@ -405,14 +422,14 @@ defmodule BDS.PreviewTest do
|
||||
assert {:ok, %{body: generated_html, content_type: "text/html"}} =
|
||||
BDS.Preview.request(project.id, "/?theme=amber&mode=dark")
|
||||
|
||||
assert generated_html =~ ~s(data-theme="amber")
|
||||
assert generated_html =~ ~s(data-theme="dark")
|
||||
assert generated_html =~ ~s(data-mode="dark")
|
||||
assert generated_html =~ ~s(/assets/pico.amber.min.css)
|
||||
|
||||
assert {:ok, %{body: draft_html, content_type: "text/html"}} =
|
||||
BDS.Preview.preview_draft(project.id, "/draft/theme-draft?theme=amber&mode=dark", post.id)
|
||||
|
||||
assert draft_html =~ ~s(data-theme="amber")
|
||||
assert draft_html =~ ~s(data-theme="dark")
|
||||
assert draft_html =~ ~s(data-mode="dark")
|
||||
assert draft_html =~ ~s(/assets/pico.amber.min.css)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user