Skip to content

Commit cdde49d

Browse files
committed
Extract Prima.WallabyCase
1 parent c7c51b1 commit cdde49d

File tree

7 files changed

+28
-26
lines changed

7 files changed

+28
-26
lines changed

test/support/wallaby_case.ex

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
defmodule Prima.WallabyCase do
2+
use ExUnit.CaseTemplate
3+
4+
using do
5+
quote do
6+
use Wallaby.Feature
7+
import Prima.WallabyTestHelpers
8+
end
9+
end
10+
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
defmodule Prima.WallabyTestHelpers do
2+
@moduledoc "Test helpers for headless browser tests"
3+
import Wallaby.Browser
4+
alias Wallaby.Query
5+
6+
@doc """
7+
A better alternative to refute_has. The built-in refute_has will wait up to 3 seconds for the element to appear before giving up. This slows down the tests a lot.
8+
Assert_missing will return immediately if the element is indeed missing from DOM.
9+
"""
10+
def assert_missing(session, query) do
11+
assert_has(session, query |> Query.count(0))
12+
end
13+
end

test/wallaby/prima_web/async_modal_test.exs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
defmodule PrimaWeb.AsyncModalTest do
2-
use ExUnit.Case, async: true
3-
use Wallaby.Feature
4-
5-
def assert_missing(session, query) do
6-
assert_has(session, query |> Query.count(0))
7-
end
2+
use Prima.WallabyCase, async: true
83

94
@modal_panel Query.css("#demo-form-modal [prima-ref=modal-panel]")
105
@modal_overlay Query.css("#demo-form-modal [prima-ref=modal-overlay]")

test/wallaby/prima_web/combobox_test.exs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
defmodule PrimaWeb.ComboboxTest do
2-
use ExUnit.Case, async: true
3-
use Wallaby.Feature
4-
5-
def assert_missing(session, query) do
6-
assert_has(session, query |> Query.count(0))
7-
end
2+
use Prima.WallabyCase, async: true
83

94
@combobox_container Query.css("#demo-combobox")
105
@search_input Query.css("#demo-combobox input[data-prima-ref=search_input]")

test/wallaby/prima_web/creatable_combobox_test.exs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
defmodule PrimaWeb.CreatableComboboxTest do
2-
use ExUnit.Case, async: true
3-
use Wallaby.Feature
4-
5-
def assert_missing(session, query) do
6-
assert_has(session, query |> Query.count(0))
7-
end
2+
use Prima.WallabyCase, async: true
83

94
@combobox_container Query.css("#demo-creatable-combobox")
105
@search_input Query.css("#demo-creatable-combobox input[data-prima-ref=search_input]")

test/wallaby/prima_web/dropdown_test.exs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
defmodule PrimaWeb.DropdownTest do
2-
use ExUnit.Case, async: true
3-
use Wallaby.Feature
2+
use Prima.WallabyCase, async: true
43

54
@dropdown_container Query.css("#dropdown")
65
@dropdown_button Query.css("#dropdown [aria-haspopup=menu]")
76
@dropdown_menu Query.css("#dropdown [role=menu]")
87
@dropdown_items Query.css("#dropdown [role=menuitem]")
98

10-
def assert_missing(session, query) do
11-
assert_has(session, query |> Query.count(0))
12-
end
13-
149
feature "shows dropdown menu when button is clicked", %{session: session} do
1510
session
1611
|> visit("/fixtures/dropdown")

test/wallaby/prima_web/simple_modal_test.exs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
defmodule PrimaWeb.SimpleModalTest do
2-
use ExUnit.Case, async: true
3-
use Wallaby.Feature
2+
use Prima.WallabyCase, async: true
43

54
@modal_panel Query.css("#simple-modal [prima-ref=modal-panel]")
65
@modal_overlay Query.css("#simple-modal [prima-ref=modal-overlay]")

0 commit comments

Comments
 (0)