feat: improve sidebar handling
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Simon 2026-01-06 10:29:20 +01:00
parent 16ca4efc03
commit aba8737c38
Signed by: simon
GPG key ID: 40E7A58C4AA1EDB2
6 changed files with 93 additions and 15 deletions

View file

@ -712,19 +712,19 @@ defmodule MvWeb.Layouts.SidebarTest do
html = render_sidebar(authenticated_assigns(false))
# Toggle button has onclick handler
assert html =~ ~s(onclick="toggleSidebar()")
assert html =~ ~r/onclick="toggleSidebar\(\)"/
end
test "no duplicate IDs in layout" do
html = render_sidebar(authenticated_assigns())
# Check that main-sidebar ID appears only once
id_count = html |> String.split(~s(id="main-sidebar")) |> length() |> Kernel.-(1)
id_count = html |> String.split(~r/id="main-sidebar"/) |> length() |> Kernel.-(1)
assert id_count == 1, "main-sidebar ID should appear exactly once"
# Check that sidebar-toggle ID appears only once (if present)
if html =~ ~s(id="sidebar-toggle") do
toggle_count = html |> String.split(~s(id="sidebar-toggle")) |> length() |> Kernel.-(1)
if html =~ ~r/id="sidebar-toggle"/ do
toggle_count = html |> String.split(~r/id="sidebar-toggle"/) |> length() |> Kernel.-(1)
assert toggle_count == 1, "sidebar-toggle ID should appear exactly once"
end
end
@ -844,7 +844,7 @@ defmodule MvWeb.Layouts.SidebarTest do
assert has_class?(html, "dropdown-content")
# Should have both Profile and Logout links
assert html =~ ~s(href="/sign-out")
assert html =~ "sign-out"
end
end
end