fix: A1-17 route bds2://new-post deep links into transform pipeline and draft creation

This commit is contained in:
2026-05-30 08:58:22 +02:00
parent ebf6136d2f
commit 7045b10738
20 changed files with 1128 additions and 607 deletions

View File

@@ -0,0 +1,34 @@
defmodule BDS.Desktop.DeepLinkTest do
use ExUnit.Case, async: false
alias BDS.Desktop.DeepLink
setup do
topic = "deep-link-test:#{System.unique_integer([:positive])}"
Phoenix.PubSub.subscribe(BDS.PubSub, topic)
{:ok, pid} = DeepLink.start_link(name: nil, pubsub: BDS.PubSub, topic: topic)
on_exit(fn -> if Process.alive?(pid), do: GenServer.stop(pid) end)
%{pid: pid, topic: topic}
end
test "broadcasts a bds2:// open_url event to the shell topic", %{pid: pid} do
url = "bds2://new-post?title=Hello&url=https://example.com"
send(pid, {:open_url, [url]})
assert_receive {:blogmark_deep_link, ^url}, 500
end
test "ignores non-bds2 open_url events", %{pid: pid} do
send(pid, {:open_url, ["https://example.com"]})
refute_receive {:blogmark_deep_link, _url}, 200
end
test "ignores unrelated messages", %{pid: pid} do
send(pid, {:open_file, ["/tmp/x"]})
refute_receive {:blogmark_deep_link, _url}, 200
end
end

View File

@@ -846,6 +846,27 @@ defmodule BDS.Desktop.ShellLiveTest do
assert html =~ ~s(data-tab-id="#{created_definition.id}")
end
test "blogmark deep link creates a draft post and opens it in the editor", %{project: project} do
{:ok, view, _html} = live_isolated(build_conn(), BDS.Desktop.ShellLive)
post_count_before = Repo.aggregate(Post, :count, :id)
url =
"bds2://new-post?title=" <>
URI.encode_www_form("Saved From Browser") <>
"&url=" <> URI.encode_www_form("https://example.com/article")
send(view.pid, {:blogmark_deep_link, url})
html = render(view)
assert Repo.aggregate(Post, :count, :id) == post_count_before + 1
created_post = Repo.get_by!(Post, title: "Saved From Browser")
assert created_post.project_id == project.id
assert created_post.status == :draft
assert html =~ ~s(data-tab-type="post")
assert html =~ ~s(data-tab-id="#{created_post.id}")
end
test "settings sidebar selections expose a scroll target for the preferences editor" do
{:ok, view, _html} = live_isolated(build_conn(), BDS.Desktop.ShellLive)