test: D1-3 cover BundledDefaultTemplatesExistOutsideProjectData with no Template rows

This commit is contained in:
2026-05-29 22:02:19 +02:00
parent cf8b0af15f
commit 8cb6d238b9
2 changed files with 41 additions and 1 deletions

View File

@@ -1,6 +1,8 @@
defmodule BDS.TemplateLookupPriorityTest do
use ExUnit.Case, async: false
import Ecto.Query
alias BDS.Rendering.TemplateSelection
setup do
@@ -138,6 +140,44 @@ defmodule BDS.TemplateLookupPriorityTest do
end
end
describe "BundledDefaultTemplatesExistOutsideProjectData" do
test "single-post bundled template resolves with no Template rows", %{project: project} do
assert [] = BDS.Repo.all(from t in BDS.Templates.Template, where: t.project_id == ^project.id)
{:ok, source} = TemplateSelection.load_template_source(project.id, :post, nil)
assert source =~ ~s(data-template="single-post")
end
test "post-list bundled template resolves with no Template rows", %{project: project} do
assert [] = BDS.Repo.all(from t in BDS.Templates.Template, where: t.project_id == ^project.id)
{:ok, source} = TemplateSelection.load_template_source(project.id, :list, nil)
assert source =~ ~s({% if archive_context %})
end
test "not-found bundled template resolves with no Template rows", %{project: project} do
assert [] = BDS.Repo.all(from t in BDS.Templates.Template, where: t.project_id == ^project.id)
{:ok, source} = TemplateSelection.load_template_source(project.id, :not_found, nil)
assert source =~ ~s(data-template="not-found")
assert source =~ "404"
end
test "bundled defaults resolve even when project has no templates directory", %{
project: project
} do
template_dir = Path.join(BDS.Projects.project_data_dir(project), "templates")
refute File.exists?(template_dir)
{:ok, source} = TemplateSelection.load_template_source(project.id, :post, nil)
assert source =~ ~s(data-template="single-post")
end
end
describe "end-to-end template lookup with rendering" do
test "post renders with tag-specific template when no post template set", %{
project: project