mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-11-13 07:48:26 +03:00
Move avh4/elm-program-test to test-dependencies
Require users to use ProgramTest.SimulateDomEvent as first argument when using Nri.Test.* modules That way there is no hard dependency on avh4/elm-program-test version
This commit is contained in:
parent
520f6b7700
commit
25466b5a7b
@ -36,6 +36,7 @@ suite =
|
||||
switchIt : String -> ProgramTest a b c -> ProgramTest a b c
|
||||
switchIt name =
|
||||
MouseHelpers.click
|
||||
ProgramTest.simulateDomEvent
|
||||
[ attribute Role.switch
|
||||
, containing [ text name ]
|
||||
, id "view-switch-example"
|
||||
|
2
elm.json
2
elm.json
@ -101,7 +101,6 @@
|
||||
"dependencies": {
|
||||
"BrianHicks/elm-particle": "1.5.0 <= v < 2.0.0",
|
||||
"Gizra/elm-keyboard-event": "1.0.1 <= v < 2.0.0",
|
||||
"avh4/elm-program-test": "4.0.0 <= v < 5.0.0",
|
||||
"elm/browser": "1.0.2 <= v < 2.0.0",
|
||||
"elm/core": "1.0.1 <= v < 2.0.0",
|
||||
"elm/http": "2.0.0 <= v < 3.0.0",
|
||||
@ -123,6 +122,7 @@
|
||||
"tesk9/palette": "3.0.1 <= v < 4.0.0"
|
||||
},
|
||||
"test-dependencies": {
|
||||
"avh4/elm-program-test": "4.0.0 <= v < 5.0.0",
|
||||
"elm/html": "1.0.0 <= v < 2.0.0",
|
||||
"tesk9/accessible-html": "5.0.0 <= v < 6.0.0"
|
||||
}
|
||||
|
@ -18,24 +18,29 @@ module Nri.Test.KeyboardHelpers.V1 exposing
|
||||
-}
|
||||
|
||||
import Json.Encode as Encode
|
||||
import ProgramTest exposing (ProgramTest)
|
||||
import Test.Html.Event as Event
|
||||
import Test.Html.Query as Query
|
||||
import Test.Html.Selector exposing (Selector)
|
||||
|
||||
|
||||
type alias SimulateDomEvent msg programTest =
|
||||
(Query.Single msg -> Query.Single msg) -> ( String, Encode.Value ) -> programTest -> programTest
|
||||
|
||||
|
||||
{-| Simulate a "keydown" event on the given element.
|
||||
-}
|
||||
pressKey :
|
||||
{ targetDetails : List ( String, Encode.Value )
|
||||
, keyCode : Int
|
||||
, shiftKey : Bool
|
||||
}
|
||||
SimulateDomEvent msg programTest
|
||||
->
|
||||
{ targetDetails : List ( String, Encode.Value )
|
||||
, keyCode : Int
|
||||
, shiftKey : Bool
|
||||
}
|
||||
-> List Selector
|
||||
-> ProgramTest model msg effect
|
||||
-> ProgramTest model msg effect
|
||||
pressKey { targetDetails, keyCode, shiftKey } selectors =
|
||||
ProgramTest.simulateDomEvent
|
||||
-> programTest
|
||||
-> programTest
|
||||
pressKey simulateDomEvent { targetDetails, keyCode, shiftKey } selectors =
|
||||
simulateDomEvent
|
||||
(Query.find selectors)
|
||||
(Event.custom
|
||||
"keydown"
|
||||
@ -53,15 +58,17 @@ pressKey { targetDetails, keyCode, shiftKey } selectors =
|
||||
{-| Simulate a "keyup" event on the given element.
|
||||
-}
|
||||
releaseKey :
|
||||
{ targetDetails : List ( String, Encode.Value )
|
||||
, keyCode : Int
|
||||
, shiftKey : Bool
|
||||
}
|
||||
SimulateDomEvent msg programTest
|
||||
->
|
||||
{ targetDetails : List ( String, Encode.Value )
|
||||
, keyCode : Int
|
||||
, shiftKey : Bool
|
||||
}
|
||||
-> List Selector
|
||||
-> ProgramTest model msg effect
|
||||
-> ProgramTest model msg effect
|
||||
releaseKey { targetDetails, keyCode, shiftKey } selectors =
|
||||
ProgramTest.simulateDomEvent
|
||||
-> programTest
|
||||
-> programTest
|
||||
releaseKey simulateDomEvent { targetDetails, keyCode, shiftKey } selectors =
|
||||
simulateDomEvent
|
||||
(Query.find selectors)
|
||||
(Event.custom
|
||||
"keyup"
|
||||
@ -79,141 +86,154 @@ releaseKey { targetDetails, keyCode, shiftKey } selectors =
|
||||
{-| Simulate a tab key press on the given element.
|
||||
-}
|
||||
pressTab :
|
||||
{ targetDetails : List ( String, Encode.Value ) }
|
||||
SimulateDomEvent msg programTest
|
||||
-> { targetDetails : List ( String, Encode.Value ) }
|
||||
-> List Selector
|
||||
-> ProgramTest model msg effect
|
||||
-> ProgramTest model msg effect
|
||||
pressTab { targetDetails } =
|
||||
pressKey { targetDetails = targetDetails, keyCode = 9, shiftKey = False }
|
||||
-> programTest
|
||||
-> programTest
|
||||
pressTab simulateDomEvent { targetDetails } =
|
||||
pressKey simulateDomEvent { targetDetails = targetDetails, keyCode = 9, shiftKey = False }
|
||||
|
||||
|
||||
{-| Simulate a shift-tab key press on the given element.
|
||||
-}
|
||||
pressTabBack :
|
||||
{ targetDetails : List ( String, Encode.Value ) }
|
||||
SimulateDomEvent msg programTest
|
||||
-> { targetDetails : List ( String, Encode.Value ) }
|
||||
-> List Selector
|
||||
-> ProgramTest model msg effect
|
||||
-> ProgramTest model msg effect
|
||||
pressTabBack { targetDetails } =
|
||||
pressKey { targetDetails = targetDetails, keyCode = 9, shiftKey = True }
|
||||
-> programTest
|
||||
-> programTest
|
||||
pressTabBack simulateDomEvent { targetDetails } =
|
||||
pressKey simulateDomEvent { targetDetails = targetDetails, keyCode = 9, shiftKey = True }
|
||||
|
||||
|
||||
{-| Simulate an escape key press on the given element.
|
||||
-}
|
||||
pressEsc :
|
||||
{ targetDetails : List ( String, Encode.Value ) }
|
||||
SimulateDomEvent msg programTest
|
||||
-> { targetDetails : List ( String, Encode.Value ) }
|
||||
-> List Selector
|
||||
-> ProgramTest model msg effect
|
||||
-> ProgramTest model msg effect
|
||||
pressEsc { targetDetails } =
|
||||
pressKey { targetDetails = targetDetails, keyCode = 27, shiftKey = False }
|
||||
-> programTest
|
||||
-> programTest
|
||||
pressEsc simulateDomEvent { targetDetails } =
|
||||
pressKey simulateDomEvent { targetDetails = targetDetails, keyCode = 27, shiftKey = False }
|
||||
|
||||
|
||||
{-| Simulate a spacebar key press on the given element.
|
||||
-}
|
||||
pressSpace :
|
||||
{ targetDetails : List ( String, Encode.Value ) }
|
||||
SimulateDomEvent msg programTest
|
||||
-> { targetDetails : List ( String, Encode.Value ) }
|
||||
-> List Selector
|
||||
-> ProgramTest model msg effect
|
||||
-> ProgramTest model msg effect
|
||||
pressSpace { targetDetails } =
|
||||
pressKey { targetDetails = targetDetails, keyCode = 32, shiftKey = False }
|
||||
-> programTest
|
||||
-> programTest
|
||||
pressSpace simulateDomEvent { targetDetails } =
|
||||
pressKey simulateDomEvent { targetDetails = targetDetails, keyCode = 32, shiftKey = False }
|
||||
|
||||
|
||||
{-| Simulate a down arrow key press on the given element.
|
||||
-}
|
||||
pressDownArrow :
|
||||
{ targetDetails : List ( String, Encode.Value ) }
|
||||
SimulateDomEvent msg programTest
|
||||
-> { targetDetails : List ( String, Encode.Value ) }
|
||||
-> List Selector
|
||||
-> ProgramTest model msg effect
|
||||
-> ProgramTest model msg effect
|
||||
pressDownArrow { targetDetails } =
|
||||
pressKey { targetDetails = targetDetails, keyCode = 40, shiftKey = False }
|
||||
-> programTest
|
||||
-> programTest
|
||||
pressDownArrow simulateDomEvent { targetDetails } =
|
||||
pressKey simulateDomEvent { targetDetails = targetDetails, keyCode = 40, shiftKey = False }
|
||||
|
||||
|
||||
{-| Simulate a right arrow key press on the given element.
|
||||
-}
|
||||
pressRightArrow :
|
||||
{ targetDetails : List ( String, Encode.Value ) }
|
||||
SimulateDomEvent msg programTest
|
||||
-> { targetDetails : List ( String, Encode.Value ) }
|
||||
-> List Selector
|
||||
-> ProgramTest model msg effect
|
||||
-> ProgramTest model msg effect
|
||||
pressRightArrow { targetDetails } =
|
||||
pressKey { targetDetails = targetDetails, keyCode = 39, shiftKey = False }
|
||||
-> programTest
|
||||
-> programTest
|
||||
pressRightArrow simulateDomEvent { targetDetails } =
|
||||
pressKey simulateDomEvent { targetDetails = targetDetails, keyCode = 39, shiftKey = False }
|
||||
|
||||
|
||||
{-| Simulate a left arrow key press on the given element.
|
||||
-}
|
||||
pressLeftArrow :
|
||||
{ targetDetails : List ( String, Encode.Value ) }
|
||||
SimulateDomEvent msg programTest
|
||||
-> { targetDetails : List ( String, Encode.Value ) }
|
||||
-> List Selector
|
||||
-> ProgramTest model msg effect
|
||||
-> ProgramTest model msg effect
|
||||
pressLeftArrow { targetDetails } =
|
||||
pressKey { targetDetails = targetDetails, keyCode = 37, shiftKey = False }
|
||||
-> programTest
|
||||
-> programTest
|
||||
pressLeftArrow simulateDomEvent { targetDetails } =
|
||||
pressKey simulateDomEvent { targetDetails = targetDetails, keyCode = 37, shiftKey = False }
|
||||
|
||||
|
||||
{-| Simulate a right arrow key press with the shift key held down on the given element.
|
||||
-}
|
||||
pressShiftRight :
|
||||
{ targetDetails : List ( String, Encode.Value ) }
|
||||
SimulateDomEvent msg programTest
|
||||
-> { targetDetails : List ( String, Encode.Value ) }
|
||||
-> List Selector
|
||||
-> ProgramTest model msg effect
|
||||
-> ProgramTest model msg effect
|
||||
pressShiftRight { targetDetails } =
|
||||
pressKey { targetDetails = targetDetails, keyCode = 39, shiftKey = True }
|
||||
-> programTest
|
||||
-> programTest
|
||||
pressShiftRight simulateDomEvent { targetDetails } =
|
||||
pressKey simulateDomEvent { targetDetails = targetDetails, keyCode = 39, shiftKey = True }
|
||||
|
||||
|
||||
{-| Simulate a left arrow key press with the shift key held down on the given element.
|
||||
-}
|
||||
pressShiftLeft :
|
||||
{ targetDetails : List ( String, Encode.Value ) }
|
||||
SimulateDomEvent msg programTest
|
||||
-> { targetDetails : List ( String, Encode.Value ) }
|
||||
-> List Selector
|
||||
-> ProgramTest model msg effect
|
||||
-> ProgramTest model msg effect
|
||||
pressShiftLeft { targetDetails } =
|
||||
pressKey { targetDetails = targetDetails, keyCode = 37, shiftKey = True }
|
||||
-> programTest
|
||||
-> programTest
|
||||
pressShiftLeft simulateDomEvent { targetDetails } =
|
||||
pressKey simulateDomEvent { targetDetails = targetDetails, keyCode = 37, shiftKey = True }
|
||||
|
||||
|
||||
{-| Simulate a right arrow key release on the given element.
|
||||
-}
|
||||
releaseRightArrow :
|
||||
{ targetDetails : List ( String, Encode.Value ) }
|
||||
SimulateDomEvent msg programTest
|
||||
-> { targetDetails : List ( String, Encode.Value ) }
|
||||
-> List Selector
|
||||
-> ProgramTest model msg effect
|
||||
-> ProgramTest model msg effect
|
||||
releaseRightArrow { targetDetails } =
|
||||
releaseKey { targetDetails = targetDetails, keyCode = 39, shiftKey = False }
|
||||
-> programTest
|
||||
-> programTest
|
||||
releaseRightArrow simulateDomEvent { targetDetails } =
|
||||
releaseKey simulateDomEvent { targetDetails = targetDetails, keyCode = 39, shiftKey = False }
|
||||
|
||||
|
||||
{-| Simulate a left arrow key release on the given element.
|
||||
-}
|
||||
releaseLeftArrow :
|
||||
{ targetDetails : List ( String, Encode.Value ) }
|
||||
SimulateDomEvent msg programTest
|
||||
-> { targetDetails : List ( String, Encode.Value ) }
|
||||
-> List Selector
|
||||
-> ProgramTest model msg effect
|
||||
-> ProgramTest model msg effect
|
||||
releaseLeftArrow { targetDetails } =
|
||||
releaseKey { targetDetails = targetDetails, keyCode = 37, shiftKey = False }
|
||||
-> programTest
|
||||
-> programTest
|
||||
releaseLeftArrow simulateDomEvent { targetDetails } =
|
||||
releaseKey simulateDomEvent { targetDetails = targetDetails, keyCode = 37, shiftKey = False }
|
||||
|
||||
|
||||
{-| Simulate a right arrow key release with the shift key held down on the given element.
|
||||
-}
|
||||
releaseShiftRight :
|
||||
{ targetDetails : List ( String, Encode.Value ) }
|
||||
SimulateDomEvent msg programTest
|
||||
-> { targetDetails : List ( String, Encode.Value ) }
|
||||
-> List Selector
|
||||
-> ProgramTest model msg effect
|
||||
-> ProgramTest model msg effect
|
||||
releaseShiftRight { targetDetails } =
|
||||
releaseKey { targetDetails = targetDetails, keyCode = 39, shiftKey = True }
|
||||
-> programTest
|
||||
-> programTest
|
||||
releaseShiftRight simulateDomEvent { targetDetails } =
|
||||
releaseKey simulateDomEvent { targetDetails = targetDetails, keyCode = 39, shiftKey = True }
|
||||
|
||||
|
||||
{-| Simulate a left arrow key release with the shift key held down on the given element.
|
||||
-}
|
||||
releaseShiftLeft :
|
||||
{ targetDetails : List ( String, Encode.Value ) }
|
||||
SimulateDomEvent msg programTest
|
||||
-> { targetDetails : List ( String, Encode.Value ) }
|
||||
-> List Selector
|
||||
-> ProgramTest model msg effect
|
||||
-> ProgramTest model msg effect
|
||||
releaseShiftLeft { targetDetails } =
|
||||
releaseKey { targetDetails = targetDetails, keyCode = 37, shiftKey = True }
|
||||
-> programTest
|
||||
-> programTest
|
||||
releaseShiftLeft simulateDomEvent { targetDetails } =
|
||||
releaseKey simulateDomEvent { targetDetails = targetDetails, keyCode = 37, shiftKey = True }
|
||||
|
@ -18,53 +18,56 @@ module Nri.Test.MouseHelpers.V1 exposing
|
||||
-}
|
||||
|
||||
import Json.Encode as Encode
|
||||
import ProgramTest exposing (ProgramTest)
|
||||
import Test.Html.Event as Event
|
||||
import Test.Html.Query as Query
|
||||
import Test.Html.Selector exposing (Selector)
|
||||
|
||||
|
||||
type alias SimulateDomEvent msg programTest =
|
||||
(Query.Single msg -> Query.Single msg) -> ( String, Encode.Value ) -> programTest -> programTest
|
||||
|
||||
|
||||
{-| Simulate a click event on elements that match the given selectors.
|
||||
-}
|
||||
click : List Selector -> ProgramTest model msg effect -> ProgramTest model msg effect
|
||||
click selectors =
|
||||
ProgramTest.simulateDomEvent
|
||||
click : SimulateDomEvent msg programTest -> List Selector -> programTest -> programTest
|
||||
click simulateDomEvent selectors =
|
||||
simulateDomEvent
|
||||
(Query.find selectors)
|
||||
Event.click
|
||||
|
||||
|
||||
{-| Simulate a mouse down event on elements that match the given selectors.
|
||||
-}
|
||||
mouseDown : List Selector -> ProgramTest model msg effect -> ProgramTest model msg effect
|
||||
mouseDown selectors =
|
||||
ProgramTest.simulateDomEvent
|
||||
mouseDown : SimulateDomEvent msg programTest -> List Selector -> programTest -> programTest
|
||||
mouseDown simulateDomEvent selectors =
|
||||
simulateDomEvent
|
||||
(Query.find selectors)
|
||||
Event.mouseDown
|
||||
|
||||
|
||||
{-| Simulate a mouse up event on elements that match the given selectors.
|
||||
-}
|
||||
mouseUp : List Selector -> ProgramTest model msg effect -> ProgramTest model msg effect
|
||||
mouseUp selectors =
|
||||
ProgramTest.simulateDomEvent
|
||||
mouseUp : SimulateDomEvent msg programTest -> List Selector -> programTest -> programTest
|
||||
mouseUp simulateDomEvent selectors =
|
||||
simulateDomEvent
|
||||
(Query.find selectors)
|
||||
Event.mouseUp
|
||||
|
||||
|
||||
{-| Simulate a mouse over event on elements that match the given selectors.
|
||||
-}
|
||||
mouseOver : List Selector -> ProgramTest model msg effect -> ProgramTest model msg effect
|
||||
mouseOver selectors =
|
||||
ProgramTest.simulateDomEvent
|
||||
mouseOver : SimulateDomEvent msg programTest -> List Selector -> programTest -> programTest
|
||||
mouseOver simulateDomEvent selectors =
|
||||
simulateDomEvent
|
||||
(Query.find selectors)
|
||||
Event.mouseOver
|
||||
|
||||
|
||||
{-| Simulate a cancelable mouse down event on elements that match the given selectors.
|
||||
-}
|
||||
cancelableMouseDown : List Selector -> ProgramTest model msg effect -> ProgramTest model msg effect
|
||||
cancelableMouseDown selectors =
|
||||
ProgramTest.simulateDomEvent
|
||||
cancelableMouseDown : SimulateDomEvent msg programTest -> List Selector -> programTest -> programTest
|
||||
cancelableMouseDown simulateDomEvent selectors =
|
||||
simulateDomEvent
|
||||
(Query.find selectors)
|
||||
(Event.custom
|
||||
"mousedown"
|
||||
@ -74,9 +77,9 @@ cancelableMouseDown selectors =
|
||||
|
||||
{-| Simulate a cancelable mouse up event on elements that match the given selectors.
|
||||
-}
|
||||
cancelableMouseUp : List Selector -> ProgramTest model msg effect -> ProgramTest model msg effect
|
||||
cancelableMouseUp selectors =
|
||||
ProgramTest.simulateDomEvent
|
||||
cancelableMouseUp : SimulateDomEvent msg programTest -> List Selector -> programTest -> programTest
|
||||
cancelableMouseUp simulateDomEvent selectors =
|
||||
simulateDomEvent
|
||||
(Query.find selectors)
|
||||
(Event.custom
|
||||
"mouseup"
|
||||
@ -86,9 +89,9 @@ cancelableMouseUp selectors =
|
||||
|
||||
{-| Simulate a cancelable mouse over event on elements that match the given selectors.
|
||||
-}
|
||||
cancelableMouseOver : List Selector -> ProgramTest model msg effect -> ProgramTest model msg effect
|
||||
cancelableMouseOver selectors =
|
||||
ProgramTest.simulateDomEvent
|
||||
cancelableMouseOver : SimulateDomEvent msg programTest -> List Selector -> programTest -> programTest
|
||||
cancelableMouseOver simulateDomEvent selectors =
|
||||
simulateDomEvent
|
||||
(Query.find selectors)
|
||||
(Event.custom
|
||||
"mouseover"
|
||||
|
@ -124,7 +124,7 @@ helpfullyDisabledCheckbox =
|
||||
|
||||
pressSpace : TestContext -> TestContext
|
||||
pressSpace =
|
||||
KeyboardHelpers.pressSpace { targetDetails = [] } checkbox
|
||||
KeyboardHelpers.pressSpace ProgramTest.simulateDomEvent { targetDetails = [] } checkbox
|
||||
|
||||
|
||||
clickIt : TestContext -> TestContext
|
||||
|
@ -182,7 +182,8 @@ viewSpec =
|
||||
[ test "moves focus right on right arrow" <|
|
||||
\() ->
|
||||
program
|
||||
|> pressRightArrow { targetDetails = [] }
|
||||
|> pressRightArrow ProgramTest.simulateDomEvent
|
||||
{ targetDetails = [] }
|
||||
[ Selector.all
|
||||
[ Selector.tag "button"
|
||||
, Selector.containing
|
||||
@ -194,7 +195,8 @@ viewSpec =
|
||||
, test "moves focus left on left arrow" <|
|
||||
\() ->
|
||||
program
|
||||
|> pressLeftArrow { targetDetails = [] }
|
||||
|> pressLeftArrow ProgramTest.simulateDomEvent
|
||||
{ targetDetails = [] }
|
||||
[ Selector.all
|
||||
[ Selector.tag "button"
|
||||
, Selector.containing
|
||||
@ -206,7 +208,8 @@ viewSpec =
|
||||
, test "loops to end" <|
|
||||
\() ->
|
||||
program
|
||||
|> pressLeftArrow { targetDetails = [] }
|
||||
|> pressLeftArrow ProgramTest.simulateDomEvent
|
||||
{ targetDetails = [] }
|
||||
[ Selector.all
|
||||
[ Selector.tag "button"
|
||||
, Selector.containing
|
||||
@ -218,7 +221,8 @@ viewSpec =
|
||||
, test "loops to beginning" <|
|
||||
\() ->
|
||||
program
|
||||
|> pressRightArrow { targetDetails = [] }
|
||||
|> pressRightArrow ProgramTest.simulateDomEvent
|
||||
{ targetDetails = [] }
|
||||
[ Selector.all
|
||||
[ Selector.tag "button"
|
||||
, Selector.containing
|
||||
|
@ -29,7 +29,8 @@ viewSpec =
|
||||
[ test "moves focus right on right arrow" <|
|
||||
\() ->
|
||||
program
|
||||
|> pressRightArrow { targetDetails = [] }
|
||||
|> pressRightArrow ProgramTest.simulateDomEvent
|
||||
{ targetDetails = [] }
|
||||
[ Selector.all
|
||||
[ Selector.tag "button"
|
||||
, Selector.containing
|
||||
@ -41,7 +42,8 @@ viewSpec =
|
||||
, test "moves focus left on left arrow" <|
|
||||
\() ->
|
||||
program
|
||||
|> pressLeftArrow { targetDetails = [] }
|
||||
|> pressLeftArrow ProgramTest.simulateDomEvent
|
||||
{ targetDetails = [] }
|
||||
[ Selector.all
|
||||
[ Selector.tag "button"
|
||||
, Selector.containing
|
||||
@ -53,7 +55,8 @@ viewSpec =
|
||||
, test "loops to end" <|
|
||||
\() ->
|
||||
program
|
||||
|> pressLeftArrow { targetDetails = [] }
|
||||
|> pressLeftArrow ProgramTest.simulateDomEvent
|
||||
{ targetDetails = [] }
|
||||
[ Selector.all
|
||||
[ Selector.tag "button"
|
||||
, Selector.containing
|
||||
@ -65,7 +68,8 @@ viewSpec =
|
||||
, test "loops to beginning" <|
|
||||
\() ->
|
||||
program
|
||||
|> pressRightArrow { targetDetails = [] }
|
||||
|> pressRightArrow ProgramTest.simulateDomEvent
|
||||
{ targetDetails = [] }
|
||||
[ Selector.all
|
||||
[ Selector.tag "button"
|
||||
, Selector.containing
|
||||
|
@ -519,54 +519,61 @@ highlightable index selector =
|
||||
|
||||
space : TestContext -> TestContext
|
||||
space =
|
||||
KeyboardHelpers.pressSpace { targetDetails = [] }
|
||||
KeyboardHelpers.pressSpace ProgramTest.simulateDomEvent
|
||||
{ targetDetails = [] }
|
||||
[ Selector.attribute (Key.tabbable True) ]
|
||||
|
||||
|
||||
rightArrow : TestContext -> TestContext
|
||||
rightArrow =
|
||||
KeyboardHelpers.pressRightArrow { targetDetails = [] }
|
||||
KeyboardHelpers.pressRightArrow ProgramTest.simulateDomEvent
|
||||
{ targetDetails = [] }
|
||||
[ Selector.attribute (Key.tabbable True) ]
|
||||
|
||||
|
||||
leftArrow : TestContext -> TestContext
|
||||
leftArrow =
|
||||
KeyboardHelpers.pressLeftArrow { targetDetails = [] }
|
||||
KeyboardHelpers.pressLeftArrow ProgramTest.simulateDomEvent
|
||||
{ targetDetails = [] }
|
||||
[ Selector.attribute (Key.tabbable True) ]
|
||||
|
||||
|
||||
shiftRight : TestContext -> TestContext
|
||||
shiftRight =
|
||||
KeyboardHelpers.pressShiftRight { targetDetails = [] }
|
||||
KeyboardHelpers.pressShiftRight ProgramTest.simulateDomEvent
|
||||
{ targetDetails = [] }
|
||||
[ Selector.attribute (Key.tabbable True) ]
|
||||
|
||||
|
||||
shiftLeft : TestContext -> TestContext
|
||||
shiftLeft =
|
||||
KeyboardHelpers.pressShiftLeft { targetDetails = [] }
|
||||
KeyboardHelpers.pressShiftLeft ProgramTest.simulateDomEvent
|
||||
{ targetDetails = [] }
|
||||
[ Selector.attribute (Key.tabbable True) ]
|
||||
|
||||
|
||||
releaseShiftRight : TestContext -> TestContext
|
||||
releaseShiftRight =
|
||||
KeyboardHelpers.releaseShiftRight { targetDetails = [] }
|
||||
KeyboardHelpers.releaseShiftRight ProgramTest.simulateDomEvent
|
||||
{ targetDetails = [] }
|
||||
[ Selector.attribute (Key.tabbable True) ]
|
||||
|
||||
|
||||
releaseShiftLeft : TestContext -> TestContext
|
||||
releaseShiftLeft =
|
||||
KeyboardHelpers.releaseShiftLeft { targetDetails = [] }
|
||||
KeyboardHelpers.releaseShiftLeft ProgramTest.simulateDomEvent
|
||||
{ targetDetails = [] }
|
||||
[ Selector.attribute (Key.tabbable True) ]
|
||||
|
||||
|
||||
mouseDown : String -> TestContext -> TestContext
|
||||
mouseDown word =
|
||||
MouseHelpers.cancelableMouseDown [ Selector.tag "span", Selector.containing [ Selector.text word ] ]
|
||||
MouseHelpers.cancelableMouseDown ProgramTest.simulateDomEvent [ Selector.tag "span", Selector.containing [ Selector.text word ] ]
|
||||
|
||||
|
||||
mouseUp : String -> TestContext -> TestContext
|
||||
mouseUp word =
|
||||
MouseHelpers.cancelableMouseUp [ Selector.tag "span", Selector.containing [ Selector.text word ] ]
|
||||
MouseHelpers.cancelableMouseUp ProgramTest.simulateDomEvent [ Selector.tag "span", Selector.containing [ Selector.text word ] ]
|
||||
|
||||
|
||||
click : String -> TestContext -> TestContext
|
||||
@ -576,7 +583,7 @@ click word =
|
||||
|
||||
mouseOver : String -> TestContext -> TestContext
|
||||
mouseOver word =
|
||||
MouseHelpers.cancelableMouseOver [ Selector.tag "span", Selector.containing [ Selector.text word ] ]
|
||||
MouseHelpers.cancelableMouseOver ProgramTest.simulateDomEvent [ Selector.tag "span", Selector.containing [ Selector.text word ] ]
|
||||
|
||||
|
||||
markerModel : Maybe String -> Tool String
|
||||
|
@ -57,14 +57,16 @@ spec =
|
||||
, test "Opens on down arrow" <|
|
||||
\() ->
|
||||
program []
|
||||
|> KeyboardHelpers.pressDownArrow { targetDetails = targetDetails "hello-button" }
|
||||
|> KeyboardHelpers.pressDownArrow ProgramTest.simulateDomEvent
|
||||
{ targetDetails = targetDetails "hello-button" }
|
||||
[ Selector.tag "button", Selector.id "hello-button" ]
|
||||
|> ensureViewHas (menuContentSelector menuContent)
|
||||
|> ProgramTest.done
|
||||
, test "Opens on down arrow when there's a tooltip attached" <|
|
||||
\() ->
|
||||
program [ Menu.withTooltip [ Tooltip.onToggle ToggleTooltip ] ]
|
||||
|> KeyboardHelpers.pressDownArrow { targetDetails = targetDetails "hello-button" }
|
||||
|> KeyboardHelpers.pressDownArrow ProgramTest.simulateDomEvent
|
||||
{ targetDetails = targetDetails "hello-button" }
|
||||
[ Selector.tag "button", Selector.id "hello-button" ]
|
||||
|> ensureViewHas (menuContentSelector menuContent)
|
||||
|> ProgramTest.done
|
||||
@ -225,20 +227,20 @@ targetDetails targetId =
|
||||
|
||||
pressTab : { targetId : String } -> ProgramTest model msg effect -> ProgramTest model msg effect
|
||||
pressTab { targetId } =
|
||||
KeyboardHelpers.pressTab
|
||||
KeyboardHelpers.pressTab ProgramTest.simulateDomEvent
|
||||
{ targetDetails = targetDetails targetId }
|
||||
[ Selector.class "Container" ]
|
||||
|
||||
|
||||
pressTabBack : { targetId : String } -> ProgramTest model msg effect -> ProgramTest model msg effect
|
||||
pressTabBack { targetId } =
|
||||
KeyboardHelpers.pressTabBack
|
||||
KeyboardHelpers.pressTabBack ProgramTest.simulateDomEvent
|
||||
{ targetDetails = targetDetails targetId }
|
||||
[ Selector.class "Container" ]
|
||||
|
||||
|
||||
pressEsc : { targetId : String } -> ProgramTest model msg effect -> ProgramTest model msg effect
|
||||
pressEsc { targetId } =
|
||||
KeyboardHelpers.pressEsc
|
||||
KeyboardHelpers.pressEsc ProgramTest.simulateDomEvent
|
||||
{ targetDetails = targetDetails targetId }
|
||||
[ Selector.class "Container" ]
|
||||
|
@ -81,12 +81,12 @@ focusTests =
|
||||
|
||||
tabBackWithinModal : String -> ProgramTest a b c -> ProgramTest a b c
|
||||
tabBackWithinModal onElementId =
|
||||
pressTabBack { targetDetails = [ ( "id", Encode.string onElementId ) ] } focusTrapNode
|
||||
pressTabBack ProgramTest.simulateDomEvent { targetDetails = [ ( "id", Encode.string onElementId ) ] } focusTrapNode
|
||||
|
||||
|
||||
tabForwardWithinModal : String -> ProgramTest a b c -> ProgramTest a b c
|
||||
tabForwardWithinModal onElementId =
|
||||
pressTab { targetDetails = [ ( "id", Encode.string onElementId ) ] } focusTrapNode
|
||||
pressTab ProgramTest.simulateDomEvent { targetDetails = [ ( "id", Encode.string onElementId ) ] } focusTrapNode
|
||||
|
||||
|
||||
focusTrapNode : List Selector
|
||||
|
@ -155,13 +155,15 @@ ensureOnlyOneTabInSequence tabs testContext =
|
||||
|
||||
releaseRightArrow : TestContext -> TestContext
|
||||
releaseRightArrow =
|
||||
KeyboardHelpers.releaseRightArrow { targetDetails = [] }
|
||||
KeyboardHelpers.releaseRightArrow ProgramTest.simulateDomEvent
|
||||
{ targetDetails = [] }
|
||||
[ Selector.attribute Role.tab, Selector.attribute (Key.tabbable True) ]
|
||||
|
||||
|
||||
releaseLeftArrow : TestContext -> TestContext
|
||||
releaseLeftArrow =
|
||||
KeyboardHelpers.releaseLeftArrow { targetDetails = [] }
|
||||
KeyboardHelpers.releaseLeftArrow ProgramTest.simulateDomEvent
|
||||
{ targetDetails = [] }
|
||||
[ Selector.attribute Role.tab, Selector.attribute (Key.tabbable True) ]
|
||||
|
||||
|
||||
|
@ -74,12 +74,12 @@ helpfullyDisabledSwitch =
|
||||
|
||||
pressSpace : TestContext -> TestContext
|
||||
pressSpace =
|
||||
KeyboardHelpers.pressSpace { targetDetails = [] } switch
|
||||
KeyboardHelpers.pressSpace ProgramTest.simulateDomEvent { targetDetails = [] } switch
|
||||
|
||||
|
||||
click : TestContext -> TestContext
|
||||
click =
|
||||
MouseHelpers.click switch
|
||||
MouseHelpers.click ProgramTest.simulateDomEvent switch
|
||||
|
||||
|
||||
switch : List Selector
|
||||
|
@ -155,7 +155,8 @@ spec =
|
||||
, Tooltip.onTriggerKeyDown
|
||||
[ Key.space SpaceKeyPressed ]
|
||||
]
|
||||
|> KeyboardHelpers.pressSpace { targetDetails = [] }
|
||||
|> KeyboardHelpers.pressSpace ProgramTest.simulateDomEvent
|
||||
{ targetDetails = [] }
|
||||
[ Selector.id triggerId
|
||||
]
|
||||
|> ProgramTest.expectModel (\model -> Expect.equal (Just SpaceKeyPressed) model.lastMsg)
|
||||
|
@ -86,11 +86,13 @@ ensureOnlyOneTabInSequence tabs testContext =
|
||||
|
||||
releaseRightArrow : ProgramTest model msg effect -> ProgramTest model msg effect
|
||||
releaseRightArrow =
|
||||
KeyboardHelpers.releaseRightArrow { targetDetails = [] }
|
||||
KeyboardHelpers.releaseRightArrow ProgramTest.simulateDomEvent
|
||||
{ targetDetails = [] }
|
||||
[ Selector.attribute Role.tab, Selector.attribute (Key.tabbable True) ]
|
||||
|
||||
|
||||
releaseLeftArrow : ProgramTest model msg effect -> ProgramTest model msg effect
|
||||
releaseLeftArrow =
|
||||
KeyboardHelpers.releaseLeftArrow { targetDetails = [] }
|
||||
KeyboardHelpers.releaseLeftArrow ProgramTest.simulateDomEvent
|
||||
{ targetDetails = [] }
|
||||
[ Selector.attribute Role.tab, Selector.attribute (Key.tabbable True) ]
|
||||
|
@ -4,6 +4,7 @@
|
||||
"Browser.Events.Extra",
|
||||
"Nri.Test.KeyboardHelpers.V1",
|
||||
"Nri.Test.MouseHelpers.V1",
|
||||
"Nri.Ui",
|
||||
"Nri.Ui.Accordion.V3",
|
||||
"Nri.Ui.AnimatedIcon.V1",
|
||||
"Nri.Ui.AssignmentIcon.V2",
|
||||
|
Loading…
Reference in New Issue
Block a user