Skip to content

Commit 0c3b88b

Browse files
committed
fix: dropdown sections fixture loading and test selectors
The dropdown sections tests were failing because the fixture template was not wired up in the main template file. Additionally, the tests had incorrect selectors for keyboard navigation and separator visibility. Changes: - Add dropdown_sections entry to fixtures_live.html.heex - Remove unused @dropdown_container module attribute - Fix separator test to handle invisible elements with Query.visible(false) - Replace :nth-of-type selectors with specific IDs for keyboard navigation
1 parent 18dc57e commit 0c3b88b

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

demo/lib/demo_web/live/fixtures_live.html.heex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
<.dropdown_rerender_trigger_fixture {assigns} />
1515
</div>
1616

17+
<div :if={@live_action == :dropdown_sections}>
18+
<.dropdown_sections_fixture />
19+
</div>
20+
1721
<div :if={@live_action == :simple_modal}>
1822
<.simple_modal_fixture />
1923
</div>

demo/test/wallaby/demo_web/dropdown_sections_test.exs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
defmodule DemoWeb.DropdownSectionsTest do
22
use Prima.WallabyCase, async: true
33

4-
@dropdown_container Query.css("#dropdown-sections")
54
@dropdown_button Query.css("#dropdown-sections [aria-haspopup=menu]")
65
@dropdown_menu Query.css("#dropdown-sections [role=menu]")
7-
@dropdown_items Query.css("#dropdown-sections [role=menuitem]")
86

97
feature "renders sections with proper ARIA roles", %{session: session} do
108
session
@@ -25,7 +23,10 @@ defmodule DemoWeb.DropdownSectionsTest do
2523
session
2624
|> visit_fixture("/fixtures/dropdown-sections", "#dropdown-sections")
2725
|> click(@dropdown_button)
28-
|> assert_has(Query.css("#dropdown-sections [role=separator]", count: 2))
26+
|> assert_has(
27+
Query.css("#dropdown-sections [role=separator]", count: 2)
28+
|> Query.visible(false)
29+
)
2930
end
3031

3132
feature "sections are automatically labeled by headings via JS hook", %{session: session} do
@@ -54,15 +55,15 @@ defmodule DemoWeb.DropdownSectionsTest do
5455
|> click(@dropdown_button)
5556
|> assert_has(@dropdown_menu |> Query.visible(true))
5657
|> send_keys([:down_arrow])
57-
|> assert_has(Query.css("#dropdown-sections [role=menuitem]:nth-of-type(1)[data-focus]"))
58+
|> assert_has(Query.css("#dropdown-sections-item-0[data-focus]"))
5859
|> send_keys([:down_arrow])
59-
|> assert_has(Query.css("#dropdown-sections [role=menuitem]:nth-of-type(2)[data-focus]"))
60+
|> assert_has(Query.css("#dropdown-sections-item-1[data-focus]"))
6061
|> send_keys([:down_arrow])
61-
|> assert_has(Query.css("#dropdown-sections [role=menuitem]:nth-of-type(3)[data-focus]"))
62+
|> assert_has(Query.css("#dropdown-sections-item-2[data-focus]"))
6263
|> send_keys([:down_arrow])
63-
|> assert_has(Query.css("#dropdown-sections [role=menuitem]:nth-of-type(4)[data-focus]"))
64+
|> assert_has(Query.css("#dropdown-sections-item-3[data-focus]"))
6465
|> send_keys([:down_arrow])
65-
|> assert_has(Query.css("#dropdown-sections [role=menuitem]:nth-of-type(5)[data-focus]"))
66+
|> assert_has(Query.css("#dropdown-sections-item-4[data-focus]"))
6667
end
6768

6869
feature "Home key navigates to first menu item, skipping headings", %{session: session} do

0 commit comments

Comments
 (0)