Skip to content

Commit

Permalink
[client] Messing more with Quickstrom specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Prior committed Apr 2, 2022
1 parent cae7aaf commit f8f2732
Showing 1 changed file with 32 additions and 14 deletions.
46 changes: 32 additions & 14 deletions client/specs/Rooms.spec.purs
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,60 @@ module Rooms
where

import Quickstrom
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..), isJust, isNothing)

readyWhen :: Selector
readyWhen = "#rooms"

rooms = queryOne "#rooms" {}

chat = queryOne "section.af" {}

newRoomButtonDisplay :: Maybe String
newRoomButtonDisplay = case (queryOne "a.new-room.r" { display: cssValue "display"}) of
Just el -> Just el.display
Nothing -> Nothing
newRoomButtonDisplay = map _.display (queryOne "a.new-room.r" { display: cssValue "display"})

newRoomName :: Maybe String
newRoomName = case queryOne ".rooms form input" { value } of
Just el -> Just el.value
Nothing -> Nothing
newRoomName = map _.value (queryOne "#rooms form input" { value })

actions :: Actions
actions =
clicks
<> [ click "a.new-room"
`followedBy` enterText "new-quickstrom-room"
`followedBy` click "form.r button"
]
-- <> [ click "form.r button" ]
<> [ click "h2" ]

proposition :: Boolean
proposition =
let

buttonHidden = newRoomButtonDisplay == Just "none"
|| newRoomButtonDisplay == Nothing

noName = newRoomName == Nothing
|| newRoomName == Just ""

goCreate = buttonHidden && next (not buttonHidden)
filledName = newRoomName == Just "new-quickstrom-room"

doneCreate = (not buttonHidden) && next buttonHidden
initial = (isJust rooms) && (not buttonHidden) && noName

noName = newRoomName == Nothing
goCreate = (not buttonHidden)
&& next buttonHidden
&& next filledName

cancelCreate = buttonHidden
&& next noName
&& next (not buttonHidden)

visitNewRoom = filledName
&& next (isJust chat)
&& next (isNothing rooms)

addName = noName && next newRoomName == Just "new-quickstrom-room"
addName = noName && not next noName

noop = noName && next noName
noop = newRoomName == next newRoomName
&& newRoomButtonDisplay == next newRoomButtonDisplay
in
always (goCreate || doneCreate || addName || noop)
initial
&& always ((isJust rooms) `implies` (goCreate || addName || cancelCreate || noop))

0 comments on commit f8f2732

Please sign in to comment.