feat: persisted tabs

This commit is contained in:
2026-04-26 12:58:58 +02:00
parent b1592c49f4
commit dd9e6b73ae
6 changed files with 133 additions and 9 deletions

View File

@@ -10,6 +10,7 @@ defmodule BDS.Desktop.ShellLiveTest do
alias BDS.Projects
alias BDS.Repo
alias BDS.Tags
alias BDS.UI.{Session, Workbench}
@endpoint BDS.Desktop.Endpoint
@@ -205,6 +206,27 @@ defmodule BDS.Desktop.ShellLiveTest do
refute html =~ ~s(data-testid="window-titlebar-menu-dropdown")
end
test "workbench session restore reopens permanent and transient tabs and selected activity" do
{:ok, view, _html} = live_isolated(build_conn(), BDS.Desktop.ShellLive)
session_payload =
Workbench.new()
|> Workbench.click_activity(:media)
|> Workbench.open_tab(:post, "post-1", :pin)
|> Workbench.open_tab(:media, "media-1", :preview)
|> Session.serialize()
html = render_hook(view, "restore_workbench_session", %{"session" => session_payload})
assert html =~ ~s(data-view="media")
assert html =~ ~s(data-active="true")
assert html =~ ~s(data-tab-type="post")
assert html =~ ~s(data-tab-id="post-1")
assert html =~ ~s(data-tab-type="media")
assert html =~ ~s(data-tab-id="media-1")
assert html =~ ~s(class="tab active transient")
end
test "shell live renders the legacy git activity badge from remote behind count" do
Application.put_env(:bds, :git_remote_state_provider, fn _project_id, _opts ->
{:ok, %{local_branch: "main", upstream_branch: "origin/main", has_upstream: true, ahead: 0, behind: 7}}

View File

@@ -103,6 +103,7 @@ defmodule BDS.UI.ShellTest do
test "desktop shell keeps the compact frame metrics and live bootstrap assets" do
css = File.read!("/Users/gb/Projects/bDS2/priv/ui/app.css")
live_js = File.read!("/Users/gb/Projects/bDS2/priv/ui/live.js")
template = File.read!("/Users/gb/Projects/bDS2/lib/bds/desktop/shell_live/index.html.heex")
assert File.exists?("/Users/gb/Projects/bDS2/priv/ui/app.css")
assert File.exists?("/Users/gb/Projects/bDS2/priv/ui/live.js")
@@ -113,6 +114,20 @@ defmodule BDS.UI.ShellTest do
assert css =~ "height: 22px"
assert live_js =~ "LiveView.LiveSocket"
assert live_js =~ "Phoenix.Socket"
assert template =~ "data-project-id={@projects.active_project_id || \"\"}"
assert template =~ "data-workbench-session={encoded_workbench_session(@workbench)}"
end
test "desktop shell assets persist workbench layout per project" do
live_js = File.read!("/Users/gb/Projects/bDS2/priv/ui/live.js")
live_ex = File.read!("/Users/gb/Projects/bDS2/lib/bds/desktop/shell_live.ex")
assert live_js =~ "bds-workbench-"
assert live_js =~ "restore_workbench_session"
assert live_js =~ "dataset.workbenchSession"
assert live_ex =~ ~s(def handle_event("restore_workbench_session")
assert live_ex =~ "Session.restore"
assert live_ex =~ "encoded_workbench_session"
end
test "desktop shell css keeps the status bar and hidden menu alignment rules" do