style: fix pre-existing formatting drift across codebase
This commit is contained in:
@@ -51,7 +51,10 @@ defmodule BDS.CSM006NPlusOneTest do
|
||||
end
|
||||
|
||||
# Clear FTS and reindex
|
||||
Repo.query!("DELETE FROM posts_fts WHERE post_id IN (SELECT id FROM posts WHERE project_id = ?)", [project.id])
|
||||
Repo.query!(
|
||||
"DELETE FROM posts_fts WHERE post_id IN (SELECT id FROM posts WHERE project_id = ?)",
|
||||
[project.id]
|
||||
)
|
||||
|
||||
# Reindex should succeed and produce correct FTS entries
|
||||
assert :ok = BDS.Search.reindex_posts(project.id)
|
||||
@@ -82,7 +85,11 @@ defmodule BDS.CSM006NPlusOneTest do
|
||||
language: "en"
|
||||
})
|
||||
|
||||
Repo.query!("DELETE FROM posts_fts WHERE post_id IN (SELECT id FROM posts WHERE project_id = ?)", [project.id])
|
||||
Repo.query!(
|
||||
"DELETE FROM posts_fts WHERE post_id IN (SELECT id FROM posts WHERE project_id = ?)",
|
||||
[project.id]
|
||||
)
|
||||
|
||||
assert :ok = BDS.Search.reindex_posts(project.id)
|
||||
|
||||
{:ok, results} = BDS.Search.search_posts(project.id, "unique-keyword-xyz")
|
||||
|
||||
@@ -24,12 +24,13 @@ defmodule BDS.CSM007ReloadShellTest do
|
||||
test "triggers no dashboard or git queries", %{project: _project} do
|
||||
{:ok, view, _html} = live_isolated(build_conn(), BDS.Desktop.ShellLive)
|
||||
|
||||
query_count = count_queries(fn ->
|
||||
render_click(view, "toggle_sidebar", %{})
|
||||
end)
|
||||
query_count =
|
||||
count_queries(fn ->
|
||||
render_click(view, "toggle_sidebar", %{})
|
||||
end)
|
||||
|
||||
assert query_count == 0,
|
||||
"Expected 0 DB queries for sidebar toggle, got #{query_count}"
|
||||
"Expected 0 DB queries for sidebar toggle, got #{query_count}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -37,12 +38,13 @@ defmodule BDS.CSM007ReloadShellTest do
|
||||
test "triggers no DB queries" do
|
||||
{:ok, view, _html} = live_isolated(build_conn(), BDS.Desktop.ShellLive)
|
||||
|
||||
query_count = count_queries(fn ->
|
||||
render_click(view, "toggle_panel", %{})
|
||||
end)
|
||||
query_count =
|
||||
count_queries(fn ->
|
||||
render_click(view, "toggle_panel", %{})
|
||||
end)
|
||||
|
||||
assert query_count == 0,
|
||||
"Expected 0 DB queries for panel toggle, got #{query_count}"
|
||||
"Expected 0 DB queries for panel toggle, got #{query_count}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -50,16 +52,17 @@ defmodule BDS.CSM007ReloadShellTest do
|
||||
test "triggers no DB queries" do
|
||||
{:ok, view, _html} = live_isolated(build_conn(), BDS.Desktop.ShellLive)
|
||||
|
||||
query_count = count_queries(fn ->
|
||||
render_click(view, "sync_layout", %{
|
||||
"sidebar_width" => "300",
|
||||
"sidebar_visible" => "true",
|
||||
"panel_visible" => "false"
|
||||
})
|
||||
end)
|
||||
query_count =
|
||||
count_queries(fn ->
|
||||
render_click(view, "sync_layout", %{
|
||||
"sidebar_width" => "300",
|
||||
"sidebar_visible" => "true",
|
||||
"panel_visible" => "false"
|
||||
})
|
||||
end)
|
||||
|
||||
assert query_count == 0,
|
||||
"Expected 0 DB queries for sync_layout, got #{query_count}"
|
||||
"Expected 0 DB queries for sync_layout, got #{query_count}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -67,12 +70,13 @@ defmodule BDS.CSM007ReloadShellTest do
|
||||
test "triggers no DB queries" do
|
||||
{:ok, view, _html} = live_isolated(build_conn(), BDS.Desktop.ShellLive)
|
||||
|
||||
query_count = count_queries(fn ->
|
||||
render_click(view, "select_panel_tab", %{"tab" => "output"})
|
||||
end)
|
||||
query_count =
|
||||
count_queries(fn ->
|
||||
render_click(view, "select_panel_tab", %{"tab" => "output"})
|
||||
end)
|
||||
|
||||
assert query_count == 0,
|
||||
"Expected 0 DB queries for select_panel_tab, got #{query_count}"
|
||||
"Expected 0 DB queries for select_panel_tab, got #{query_count}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -80,14 +84,15 @@ defmodule BDS.CSM007ReloadShellTest do
|
||||
test "triggers sidebar query but not dashboard or git queries" do
|
||||
{:ok, view, _html} = live_isolated(build_conn(), BDS.Desktop.ShellLive)
|
||||
|
||||
{query_count, query_sources} = count_queries_with_sources(fn ->
|
||||
render_click(view, "select_view", %{"view" => "media"})
|
||||
end)
|
||||
{query_count, query_sources} =
|
||||
count_queries_with_sources(fn ->
|
||||
render_click(view, "select_view", %{"view" => "media"})
|
||||
end)
|
||||
|
||||
assert query_count > 0, "Expected at least 1 query for view change"
|
||||
|
||||
refute "dashboard" in query_sources or "projects" in query_sources,
|
||||
"View change should not query dashboard or projects, got: #{inspect(query_sources)}"
|
||||
"View change should not query dashboard or projects, got: #{inspect(query_sources)}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -95,14 +100,15 @@ defmodule BDS.CSM007ReloadShellTest do
|
||||
test "do not trigger dashboard or git queries" do
|
||||
{:ok, view, _html} = live_isolated(build_conn(), BDS.Desktop.ShellLive)
|
||||
|
||||
{_count, query_sources} = count_queries_with_sources(fn ->
|
||||
render_click(view, "update_sidebar_search", %{
|
||||
"sidebar_filters" => %{"search" => "test"}
|
||||
})
|
||||
end)
|
||||
{_count, query_sources} =
|
||||
count_queries_with_sources(fn ->
|
||||
render_click(view, "update_sidebar_search", %{
|
||||
"sidebar_filters" => %{"search" => "test"}
|
||||
})
|
||||
end)
|
||||
|
||||
refute "dashboard" in query_sources,
|
||||
"Sidebar search should not query dashboard, got: #{inspect(query_sources)}"
|
||||
"Sidebar search should not query dashboard, got: #{inspect(query_sources)}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -110,12 +116,13 @@ defmodule BDS.CSM007ReloadShellTest do
|
||||
test "triggers only the settings write, no refresh queries" do
|
||||
{:ok, view, _html} = live_isolated(build_conn(), BDS.Desktop.ShellLive)
|
||||
|
||||
query_count = count_queries(fn ->
|
||||
render_click(view, "toggle_offline_mode", %{})
|
||||
end)
|
||||
query_count =
|
||||
count_queries(fn ->
|
||||
render_click(view, "toggle_offline_mode", %{})
|
||||
end)
|
||||
|
||||
assert query_count == 1,
|
||||
"Expected exactly 1 DB query (settings write) for offline mode toggle, got #{query_count}"
|
||||
"Expected exactly 1 DB query (settings write) for offline mode toggle, got #{query_count}"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -37,12 +37,13 @@ defmodule BDS.CSM008RenderPathTest do
|
||||
render_click(view, "select_tab", %{"type" => "post", "id" => post.id})
|
||||
render_click(view, "select_panel_tab", %{"tab" => "post_links"})
|
||||
|
||||
query_count = count_queries(fn ->
|
||||
1..10 |> Enum.each(fn _ -> render(view) end)
|
||||
end)
|
||||
query_count =
|
||||
count_queries(fn ->
|
||||
1..10 |> Enum.each(fn _ -> render(view) end)
|
||||
end)
|
||||
|
||||
assert query_count == 0,
|
||||
"Expected 0 DB queries on panel re-renders, got #{query_count}"
|
||||
"Expected 0 DB queries on panel re-renders, got #{query_count}"
|
||||
end
|
||||
|
||||
test "git_log panel re-render uses cached assigns", %{post: post} do
|
||||
@@ -51,12 +52,13 @@ defmodule BDS.CSM008RenderPathTest do
|
||||
render_click(view, "select_tab", %{"type" => "post", "id" => post.id})
|
||||
render_click(view, "select_panel_tab", %{"tab" => "git_log"})
|
||||
|
||||
query_count = count_queries(fn ->
|
||||
1..10 |> Enum.each(fn _ -> render(view) end)
|
||||
end)
|
||||
query_count =
|
||||
count_queries(fn ->
|
||||
1..10 |> Enum.each(fn _ -> render(view) end)
|
||||
end)
|
||||
|
||||
assert query_count == 0,
|
||||
"Expected 0 DB queries on git_log re-renders, got #{query_count}"
|
||||
"Expected 0 DB queries on git_log re-renders, got #{query_count}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -64,26 +66,28 @@ defmodule BDS.CSM008RenderPathTest do
|
||||
test "switching to output panel triggers no post/media queries" do
|
||||
{:ok, view, _html} = live_isolated(build_conn(), BDS.Desktop.ShellLive)
|
||||
|
||||
{query_count, query_sources} = count_queries_with_sources(fn ->
|
||||
render_click(view, "select_panel_tab", %{"tab" => "output"})
|
||||
end)
|
||||
{query_count, query_sources} =
|
||||
count_queries_with_sources(fn ->
|
||||
render_click(view, "select_panel_tab", %{"tab" => "output"})
|
||||
end)
|
||||
|
||||
refute "post_links" in query_sources,
|
||||
"Switching to output should not query post_links, got: #{inspect(query_sources)}"
|
||||
"Switching to output should not query post_links, got: #{inspect(query_sources)}"
|
||||
|
||||
assert query_count == 0,
|
||||
"Expected 0 queries for output panel tab, got #{query_count}"
|
||||
"Expected 0 queries for output panel tab, got #{query_count}"
|
||||
end
|
||||
|
||||
test "switching to tasks panel triggers no post/media queries" do
|
||||
{:ok, view, _html} = live_isolated(build_conn(), BDS.Desktop.ShellLive)
|
||||
|
||||
{query_count, _query_sources} = count_queries_with_sources(fn ->
|
||||
render_click(view, "select_panel_tab", %{"tab" => "tasks"})
|
||||
end)
|
||||
{query_count, _query_sources} =
|
||||
count_queries_with_sources(fn ->
|
||||
render_click(view, "select_panel_tab", %{"tab" => "tasks"})
|
||||
end)
|
||||
|
||||
assert query_count == 0,
|
||||
"Expected 0 queries for tasks panel tab, got #{query_count}"
|
||||
"Expected 0 queries for tasks panel tab, got #{query_count}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -98,12 +102,13 @@ defmodule BDS.CSM008RenderPathTest do
|
||||
"subtitle" => "preset subtitle"
|
||||
})
|
||||
|
||||
query_count = count_queries(fn ->
|
||||
render_click(view, "select_tab", %{"type" => "post", "id" => post.id})
|
||||
end)
|
||||
query_count =
|
||||
count_queries(fn ->
|
||||
render_click(view, "select_tab", %{"type" => "post", "id" => post.id})
|
||||
end)
|
||||
|
||||
assert query_count == 0,
|
||||
"Expected 0 DB queries when tab meta is already complete, got #{query_count}"
|
||||
"Expected 0 DB queries when tab meta is already complete, got #{query_count}"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -34,7 +34,10 @@ defmodule BDS.CSM009ThumbnailErrorHandlingTest do
|
||||
assert {:error, _reason} = result
|
||||
end
|
||||
|
||||
test "ensure_thumbnails returns :ok for non-image media", %{project: project, temp_dir: temp_dir} do
|
||||
test "ensure_thumbnails returns :ok for non-image media", %{
|
||||
project: project,
|
||||
temp_dir: temp_dir
|
||||
} do
|
||||
source_path = Path.join(temp_dir, "readme.txt")
|
||||
File.write!(source_path, "just text")
|
||||
|
||||
@@ -86,11 +89,15 @@ defmodule BDS.CSM009ThumbnailErrorHandlingTest do
|
||||
} do
|
||||
source_path = Path.join(temp_dir, "good.jpg")
|
||||
File.write!(source_path, tiny_jpeg_binary())
|
||||
{:ok, good_media} = BDS.Media.import_media(%{project_id: project.id, source_path: source_path})
|
||||
|
||||
{:ok, good_media} =
|
||||
BDS.Media.import_media(%{project_id: project.id, source_path: source_path})
|
||||
|
||||
corrupt_path = Path.join(temp_dir, "bad.jpg")
|
||||
File.write!(corrupt_path, "corrupt data")
|
||||
{:ok, bad_media} = BDS.Media.import_media(%{project_id: project.id, source_path: corrupt_path})
|
||||
|
||||
{:ok, bad_media} =
|
||||
BDS.Media.import_media(%{project_id: project.id, source_path: corrupt_path})
|
||||
|
||||
Enum.each(Map.values(Thumbnails.thumbnail_paths(good_media)), fn path ->
|
||||
File.rm(Path.join(temp_dir, path))
|
||||
|
||||
@@ -79,7 +79,9 @@ defmodule BDS.CSM020NestedCaseTest do
|
||||
describe "Publishing.handle_call :update_job uses with" do
|
||||
test "source code uses with instead of case" do
|
||||
source = File.read!("lib/bds/publishing.ex")
|
||||
[func_source] = Regex.scan(~r/def handle_call\(\{:update_job.*?(?=\n def |\n @impl)/s, source)
|
||||
|
||||
[func_source] =
|
||||
Regex.scan(~r/def handle_call\(\{:update_job.*?(?=\n def |\n @impl)/s, source)
|
||||
|
||||
assert func_source |> List.first() |> String.contains?("with"),
|
||||
"update_job handler should use with"
|
||||
|
||||
@@ -4,6 +4,7 @@ defmodule BDS.CSM031TryRescueTest do
|
||||
describe "source-level: no inline try/rescue around Liquex.render!" do
|
||||
test "filters.ex has no try/rescue block in render_macro_source" do
|
||||
source = File.read!("lib/bds/rendering/filters.ex")
|
||||
|
||||
refute source =~ ~r/try do\s+.*Liquex\.render!/s,
|
||||
"render_macro_source should use safe_liquex_render helper, not inline try/rescue"
|
||||
end
|
||||
@@ -51,6 +52,7 @@ defmodule BDS.CSM031TryRescueTest do
|
||||
|
||||
test "template_selection.ex uses FileSystem.try_read instead of read_template_file" do
|
||||
source = File.read!("lib/bds/rendering/template_selection.ex")
|
||||
|
||||
refute source =~ "read_template_file",
|
||||
"should use FileSystem.try_read, not the raising read_template_file"
|
||||
|
||||
|
||||
@@ -35,12 +35,14 @@ defmodule BDS.CSM032MapGetPatternMatchTest do
|
||||
describe "source-level: overlay.ex uses pattern matching for known structures" do
|
||||
test "delete_details uses pattern matching instead of Map.get" do
|
||||
source = File.read!("lib/bds/desktop/overlay.ex")
|
||||
|
||||
refute source =~ "Map.get(delete_details,",
|
||||
"overlay.ex should pattern match delete_details instead of using Map.get"
|
||||
end
|
||||
|
||||
test "merge_details uses pattern matching instead of Map.get" do
|
||||
source = File.read!("lib/bds/desktop/overlay.ex")
|
||||
|
||||
refute source =~ "Map.get(merge,",
|
||||
"overlay.ex should pattern match merge_details instead of using Map.get"
|
||||
end
|
||||
@@ -65,32 +67,40 @@ defmodule BDS.CSM032MapGetPatternMatchTest do
|
||||
describe "source-level: generation pipeline uses dot access for Post struct fields" do
|
||||
test "outputs.ex uses post.language instead of Map.get(post, :language)" do
|
||||
source = File.read!("lib/bds/generation/outputs.ex")
|
||||
|
||||
refute source =~ "Map.get(post, :language)",
|
||||
"outputs.ex should use post.language"
|
||||
end
|
||||
|
||||
test "data.ex uses dot access for Post struct fields in build_published_translation_variant" do
|
||||
source = File.read!("lib/bds/generation/data.ex")
|
||||
|
||||
refute source =~ "Map.get(post, :author)",
|
||||
"data.ex should use post.author"
|
||||
|
||||
refute source =~ "Map.get(post, :tags",
|
||||
"data.ex should use post.tags"
|
||||
|
||||
refute source =~ "Map.get(post, :categories",
|
||||
"data.ex should use post.categories"
|
||||
|
||||
refute source =~ "Map.get(post, :template_slug)",
|
||||
"data.ex should use post.template_slug"
|
||||
|
||||
refute source =~ "Map.get(post, :do_not_translate",
|
||||
"data.ex should use post.do_not_translate"
|
||||
end
|
||||
|
||||
test "validation.ex uses post.file_path instead of Map.get(post, :file_path)" do
|
||||
source = File.read!("lib/bds/generation/validation.ex")
|
||||
|
||||
refute source =~ "Map.get(post, :file_path)",
|
||||
"validation.ex should use post.file_path"
|
||||
end
|
||||
|
||||
test "sitemap.ex uses post.do_not_translate instead of Map.get" do
|
||||
source = File.read!("lib/bds/generation/sitemap.ex")
|
||||
|
||||
refute source =~ "Map.get(post, :do_not_translate)",
|
||||
"sitemap.ex should use post.do_not_translate"
|
||||
end
|
||||
|
||||
@@ -118,9 +118,7 @@ defmodule BDS.CSM033BatchInsertsTest do
|
||||
assert Enum.all?(posts, fn post -> post.id in indexed end)
|
||||
|
||||
keys =
|
||||
BDS.Repo.all(
|
||||
from(k in BDS.Embeddings.Key, where: k.project_id == ^project.id)
|
||||
)
|
||||
BDS.Repo.all(from(k in BDS.Embeddings.Key, where: k.project_id == ^project.id))
|
||||
|
||||
assert length(keys) == 5
|
||||
labels = Enum.map(keys, & &1.label) |> Enum.sort()
|
||||
@@ -141,7 +139,8 @@ defmodule BDS.CSM033BatchInsertsTest do
|
||||
original_key =
|
||||
BDS.Repo.get_by!(BDS.Embeddings.Key, project_id: project.id, post_id: post.id)
|
||||
|
||||
{:ok, _post} = BDS.Posts.update_post(post.id, %{content: "completely different content now"})
|
||||
{:ok, _post} =
|
||||
BDS.Posts.update_post(post.id, %{content: "completely different content now"})
|
||||
|
||||
{:ok, rebuilt_ids} = BDS.Embeddings.rebuild_project(project.id)
|
||||
assert post.id in rebuilt_ids
|
||||
@@ -175,9 +174,7 @@ defmodule BDS.CSM033BatchInsertsTest do
|
||||
assert repaired == [post_a.id]
|
||||
|
||||
keys =
|
||||
BDS.Repo.all(
|
||||
from(k in BDS.Embeddings.Key, where: k.project_id == ^project.id)
|
||||
)
|
||||
BDS.Repo.all(from(k in BDS.Embeddings.Key, where: k.project_id == ^project.id))
|
||||
|
||||
assert length(keys) == 2
|
||||
end
|
||||
@@ -206,5 +203,4 @@ defmodule BDS.CSM033BatchInsertsTest do
|
||||
assert key_before.vector == key_after.vector
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -21,7 +21,9 @@ defmodule BDS.CSM034FileReadBangTest do
|
||||
test "release_packaging.ex has no File.read! or File.write!" do
|
||||
source = File.read!("lib/bds/release_packaging.ex")
|
||||
refute source =~ "File.read!", "release_packaging.ex should use File.read, not File.read!"
|
||||
refute source =~ "File.write!", "release_packaging.ex should use File.write, not File.write!"
|
||||
|
||||
refute source =~ "File.write!",
|
||||
"release_packaging.ex should use File.write, not File.write!"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -49,7 +49,9 @@ defmodule BDS.CSM035ProcessDictTest do
|
||||
match = Regex.run(~r/def sidebar_content\(assigns\).*?\n(.*?)\n/s, source)
|
||||
assert match, "could not find sidebar_content/1"
|
||||
[_, first_line | _] = match
|
||||
assert first_line =~ "UILocale.put", "sidebar_content/1 must call UILocale.put on its first line"
|
||||
|
||||
assert first_line =~ "UILocale.put",
|
||||
"sidebar_content/1 must call UILocale.put on its first line"
|
||||
end
|
||||
|
||||
test "MenuBar.mount/1 calls UILocale.put" do
|
||||
@@ -57,7 +59,9 @@ defmodule BDS.CSM035ProcessDictTest do
|
||||
match = Regex.run(~r/def mount\(menu\).*?\n(.*?)\n/s, source)
|
||||
assert match, "could not find mount/1 in menu_bar.ex"
|
||||
[_, first_line | _] = match
|
||||
assert first_line =~ "UILocale.put", "MenuBar.mount/1 must call UILocale.put on its first line"
|
||||
|
||||
assert first_line =~ "UILocale.put",
|
||||
"MenuBar.mount/1 must call UILocale.put on its first line"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -100,7 +100,9 @@ defmodule BDS.Desktop.AutomationTest do
|
||||
|
||||
assert :ok = Automation.reload(session)
|
||||
|
||||
snapshot = await(session, &(&1.sidebar_visible == true and &1.sidebar_width >= resized_width - 2))
|
||||
snapshot =
|
||||
await(session, &(&1.sidebar_visible == true and &1.sidebar_width >= resized_width - 2))
|
||||
|
||||
assert snapshot.sidebar_visible == true
|
||||
assert snapshot.sidebar_width >= resized_width - 2
|
||||
assert snapshot.sidebar_width <= resized_width + 2
|
||||
|
||||
@@ -315,9 +315,15 @@ defmodule BDS.DesktopTest do
|
||||
assert conn.resp_body =~ ~s(data-testid="toggle-sidebar")
|
||||
assert conn.resp_body =~ ~s(data-testid="toggle-panel")
|
||||
assert conn.resp_body =~ ~s(data-testid="toggle-assistant")
|
||||
assert conn.resp_body =~ ~s(class="activity-bar flex h-full shrink-0 flex-col items-center justify-between")
|
||||
|
||||
assert conn.resp_body =~
|
||||
~s(class="activity-bar flex h-full shrink-0 flex-col items-center justify-between")
|
||||
|
||||
assert conn.resp_body =~ ~s(class="sidebar flex min-w-0 flex-1 overflow-hidden")
|
||||
assert conn.resp_body =~ ~s(class="status-bar flex h-[22px] shrink-0 items-center justify-between gap-2")
|
||||
|
||||
assert conn.resp_body =~
|
||||
~s(class="status-bar flex h-[22px] shrink-0 items-center justify-between gap-2")
|
||||
|
||||
assert conn.resp_body =~ ~s(data-phx-main)
|
||||
assert conn.resp_body =~ ~s(href="/assets/app.css")
|
||||
assert conn.resp_body =~ ~s(src="/assets/app.js")
|
||||
|
||||
@@ -19,7 +19,9 @@ defmodule BDS.ImageImportPipelineTest do
|
||||
File.mkdir_p!(temp_dir)
|
||||
on_exit(fn -> File.rm_rf(temp_dir) end)
|
||||
|
||||
{:ok, project} = BDS.Projects.create_project(%{name: "Image Import Test", data_path: temp_dir})
|
||||
{:ok, project} =
|
||||
BDS.Projects.create_project(%{name: "Image Import Test", data_path: temp_dir})
|
||||
|
||||
%{project: project, temp_dir: temp_dir}
|
||||
end
|
||||
|
||||
@@ -40,7 +42,8 @@ defmodule BDS.ImageImportPipelineTest do
|
||||
)
|
||||
|
||||
assert result ==
|
||||
{:ok, ["/Users/test/photo1.jpg", "/Users/test/photo2.png", "/Users/test/photo3.heic"]}
|
||||
{:ok,
|
||||
["/Users/test/photo1.jpg", "/Users/test/photo2.png", "/Users/test/photo3.heic"]}
|
||||
end
|
||||
|
||||
test "multi selection filters out empty lines" do
|
||||
@@ -51,7 +54,8 @@ defmodule BDS.ImageImportPipelineTest do
|
||||
)
|
||||
|
||||
assert result ==
|
||||
{:ok, ["/Users/test/photo1.jpg", "/Users/test/photo2.png", "/Users/test/photo3.heic"]}
|
||||
{:ok,
|
||||
["/Users/test/photo1.jpg", "/Users/test/photo2.png", "/Users/test/photo3.heic"]}
|
||||
end
|
||||
|
||||
test "multi selection with single file returns list with one element" do
|
||||
|
||||
@@ -32,7 +32,10 @@ defmodule BDS.ImportDefinitionsTest do
|
||||
result = ImportDefinitions.decode_analysis_result(malicious_json)
|
||||
|
||||
assert is_map(result)
|
||||
assert Map.get(result, unknown_key_1) == "val" or Map.get(result, "csm001_fictive_#{unique_suffix}") == "val"
|
||||
|
||||
assert Map.get(result, unknown_key_1) == "val" or
|
||||
Map.get(result, "csm001_fictive_#{unique_suffix}") == "val"
|
||||
|
||||
assert_raise ArgumentError, fn -> String.to_existing_atom(unknown_key_1) end
|
||||
assert_raise ArgumentError, fn -> String.to_existing_atom(unknown_key_2) end
|
||||
end
|
||||
|
||||
@@ -83,9 +83,10 @@ defmodule BDS.MapUtilsTest do
|
||||
test "safe_atomize_keys does not create atoms for malicious payloads" do
|
||||
unique_suffix = :erlang.unique_integer()
|
||||
|
||||
malicious = for i <- 1..500, into: %{} do
|
||||
{"csm001_malicious_#{i}_#{unique_suffix}", "val"}
|
||||
end
|
||||
malicious =
|
||||
for i <- 1..500, into: %{} do
|
||||
{"csm001_malicious_#{i}_#{unique_suffix}", "val"}
|
||||
end
|
||||
|
||||
result = MapUtils.safe_atomize_keys(malicious)
|
||||
|
||||
|
||||
@@ -229,6 +229,7 @@ defmodule BDS.PostsTest do
|
||||
File.write!(old_full, "stale content")
|
||||
|
||||
import Ecto.Query
|
||||
|
||||
BDS.Repo.update_all(
|
||||
from(p in BDS.Posts.Post, where: p.id == ^published.id),
|
||||
set: [file_path: old_relative, content: "edited body"]
|
||||
|
||||
@@ -424,9 +424,10 @@ defmodule BDS.PreviewTest do
|
||||
assert :ok = BDS.Preview.stop_preview(project.id)
|
||||
end
|
||||
|
||||
test "on-demand rendering: published post route renders via template without generated files", %{
|
||||
project: project
|
||||
} do
|
||||
test "on-demand rendering: published post route renders via template without generated files",
|
||||
%{
|
||||
project: project
|
||||
} do
|
||||
assert {:ok, _metadata} =
|
||||
Metadata.update_project_metadata(project.id, %{
|
||||
main_language: "en",
|
||||
@@ -458,9 +459,10 @@ defmodule BDS.PreviewTest do
|
||||
assert :ok = BDS.Preview.stop_preview(project.id)
|
||||
end
|
||||
|
||||
test "on-demand rendering: home page renders published posts as list without generated files", %{
|
||||
project: project
|
||||
} do
|
||||
test "on-demand rendering: home page renders published posts as list without generated files",
|
||||
%{
|
||||
project: project
|
||||
} do
|
||||
assert {:ok, _metadata} =
|
||||
Metadata.update_project_metadata(project.id, %{
|
||||
main_language: "en",
|
||||
|
||||
@@ -96,7 +96,9 @@ defmodule BDS.Scripts.TransformsTest do
|
||||
data.content = data.content .. "D"
|
||||
return data
|
||||
end
|
||||
""", enabled: false)
|
||||
""",
|
||||
enabled: false
|
||||
)
|
||||
|
||||
transform(other.id, "Foreign", """
|
||||
function main(data, _ctx)
|
||||
|
||||
@@ -142,7 +142,8 @@ defmodule BDS.TemplateLookupPriorityTest do
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
@@ -150,7 +151,8 @@ defmodule BDS.TemplateLookupPriorityTest do
|
||||
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)
|
||||
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)
|
||||
|
||||
@@ -158,7 +160,8 @@ defmodule BDS.TemplateLookupPriorityTest do
|
||||
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)
|
||||
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)
|
||||
|
||||
|
||||
@@ -175,25 +175,39 @@ defmodule BDS.UI.ShellTest do
|
||||
|
||||
test "phase 3 templates use shared shell and form primitives for common layout" do
|
||||
post_template =
|
||||
File.read!("/Users/gb/Projects/bDS2/lib/bds/desktop/shell_live/post_editor_html/post_editor.html.heex")
|
||||
File.read!(
|
||||
"/Users/gb/Projects/bDS2/lib/bds/desktop/shell_live/post_editor_html/post_editor.html.heex"
|
||||
)
|
||||
|
||||
media_template =
|
||||
File.read!("/Users/gb/Projects/bDS2/lib/bds/desktop/shell_live/media_editor_html/media_editor.html.heex")
|
||||
File.read!(
|
||||
"/Users/gb/Projects/bDS2/lib/bds/desktop/shell_live/media_editor_html/media_editor.html.heex"
|
||||
)
|
||||
|
||||
script_template =
|
||||
File.read!("/Users/gb/Projects/bDS2/lib/bds/desktop/shell_live/script_editor_html/script_editor.html.heex")
|
||||
File.read!(
|
||||
"/Users/gb/Projects/bDS2/lib/bds/desktop/shell_live/script_editor_html/script_editor.html.heex"
|
||||
)
|
||||
|
||||
template_template =
|
||||
File.read!("/Users/gb/Projects/bDS2/lib/bds/desktop/shell_live/template_editor_html/template_editor.html.heex")
|
||||
File.read!(
|
||||
"/Users/gb/Projects/bDS2/lib/bds/desktop/shell_live/template_editor_html/template_editor.html.heex"
|
||||
)
|
||||
|
||||
chat_template =
|
||||
File.read!("/Users/gb/Projects/bDS2/lib/bds/desktop/shell_live/chat_editor_html/chat_editor.html.heex")
|
||||
File.read!(
|
||||
"/Users/gb/Projects/bDS2/lib/bds/desktop/shell_live/chat_editor_html/chat_editor.html.heex"
|
||||
)
|
||||
|
||||
menu_template =
|
||||
File.read!("/Users/gb/Projects/bDS2/lib/bds/desktop/shell_live/menu_editor_html/menu_editor.html.heex")
|
||||
File.read!(
|
||||
"/Users/gb/Projects/bDS2/lib/bds/desktop/shell_live/menu_editor_html/menu_editor.html.heex"
|
||||
)
|
||||
|
||||
settings_template =
|
||||
File.read!("/Users/gb/Projects/bDS2/lib/bds/desktop/shell_live/settings_editor_html/settings_editor.html.heex")
|
||||
File.read!(
|
||||
"/Users/gb/Projects/bDS2/lib/bds/desktop/shell_live/settings_editor_html/settings_editor.html.heex"
|
||||
)
|
||||
|
||||
assert post_template =~ "ui-editor-shell"
|
||||
assert post_template =~ "ui-editor-header"
|
||||
@@ -248,8 +262,12 @@ defmodule BDS.UI.ShellTest do
|
||||
assistant_css = File.read!("/Users/gb/Projects/bDS2/assets/css/assistant.css")
|
||||
menu_css = File.read!("/Users/gb/Projects/bDS2/assets/css/menu_editor.css")
|
||||
|
||||
refute editor_css =~ ".post-editor .editor-header,\n.scripts-view-shell.editor .editor-header,\n.templates-view-shell.editor .editor-header {\n display: flex;"
|
||||
refute editor_css =~ ".post-editor .editor-actions,\n.scripts-view-shell.editor .editor-actions,\n.templates-view-shell.editor .editor-actions {\n display: flex;"
|
||||
refute editor_css =~
|
||||
".post-editor .editor-header,\n.scripts-view-shell.editor .editor-header,\n.templates-view-shell.editor .editor-header {\n display: flex;"
|
||||
|
||||
refute editor_css =~
|
||||
".post-editor .editor-actions,\n.scripts-view-shell.editor .editor-actions,\n.templates-view-shell.editor .editor-actions {\n display: flex;"
|
||||
|
||||
refute editor_css =~ ".post-editor .quick-actions-menu {"
|
||||
refute media_css =~ "[data-testid=\"media-editor\"] .editor-header {"
|
||||
refute media_css =~ "[data-testid=\"media-editor\"] .editor-actions {"
|
||||
@@ -287,9 +305,14 @@ defmodule BDS.UI.ShellTest do
|
||||
assert css =~ ".chat-panel .chat-input-container"
|
||||
assert css =~ ".chat-model-selector-menu"
|
||||
|
||||
assert css =~ "@media (max-width: 720px) {\n .chat-panel-header {\n align-items: stretch;\n flex-direction: column;"
|
||||
assert css =~
|
||||
"@media (max-width: 720px) {\n .chat-panel-header {\n align-items: stretch;\n flex-direction: column;"
|
||||
|
||||
assert css =~ ".chat-model-selector-wrap {\n width: 100%;"
|
||||
assert css =~ ".chat-panel .chat-model-selector-button.chat-model-selector-inline {\n justify-content: space-between;\n width: 100%;"
|
||||
|
||||
assert css =~
|
||||
".chat-panel .chat-model-selector-button.chat-model-selector-inline {\n justify-content: space-between;\n width: 100%;"
|
||||
|
||||
assert css =~ ".chat-panel .chat-input-container {\n padding: 8px 12px;"
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user