feat: PLAN step 3 done
This commit is contained in:
@@ -351,8 +351,11 @@ defmodule BDS.UI.ShellTest do
|
||||
assert js =~ "case \"1\""
|
||||
assert js =~ "case \"2\""
|
||||
assert js =~ "case \"\\\\\""
|
||||
assert js =~ "case \"view_posts\""
|
||||
assert js =~ "case \"view_media\""
|
||||
assert js =~ "function isSidebarViewCommand(action)"
|
||||
assert js =~ "function isSingletonEditorCommand(action)"
|
||||
assert js =~ "action.startsWith(\"view_\")"
|
||||
assert js =~ "action.startsWith(\"open_\")"
|
||||
assert js =~ "openSingletonTab(action.slice(5));"
|
||||
assert js =~ "executeBackendShellCommand(action)"
|
||||
assert js =~ "case \"metadata_diff\""
|
||||
assert js =~ "case \"regenerate_calendar\""
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
defmodule BDS.UI.WorkbenchTest do
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
alias BDS.UI.Registry
|
||||
alias BDS.UI.MenuBar
|
||||
alias BDS.UI.Workbench
|
||||
|
||||
@@ -187,4 +188,39 @@ defmodule BDS.UI.WorkbenchTest do
|
||||
assert state.panel.visible == true
|
||||
assert state.active_view == :media
|
||||
end
|
||||
|
||||
test "shared menu command routing covers every sidebar view and singleton editor route" do
|
||||
sidebar_views = Registry.sidebar_views()
|
||||
|
||||
state =
|
||||
Enum.reduce(sidebar_views, Workbench.new(sidebar_visible: false), fn view, acc ->
|
||||
command = String.to_atom("view_#{view.id}")
|
||||
next = MenuBar.execute(acc, command)
|
||||
|
||||
assert next.active_view == view.id
|
||||
assert next.sidebar_visible == true
|
||||
|
||||
%{next | sidebar_visible: false}
|
||||
end)
|
||||
|
||||
singleton_routes =
|
||||
Registry.editor_routes()
|
||||
|> Enum.filter(& &1.singleton)
|
||||
|> Enum.reject(&(&1.id == :dashboard))
|
||||
|
||||
final_state =
|
||||
Enum.reduce(singleton_routes, state, fn route, acc ->
|
||||
command = String.to_atom("open_#{route.id}")
|
||||
next = MenuBar.execute(acc, command)
|
||||
|
||||
assert next.active_tab == {route.id, Atom.to_string(route.id)}
|
||||
assert next.editor_route == route.id
|
||||
|
||||
next
|
||||
end)
|
||||
|
||||
assert Enum.any?(final_state.tabs, &(&1.type == :settings and &1.id == "settings"))
|
||||
assert Enum.any?(final_state.tabs, &(&1.type == :menu_editor and &1.id == "menu_editor"))
|
||||
assert Enum.any?(final_state.tabs, &(&1.type == :find_duplicates and &1.id == "find_duplicates"))
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user