on develop help sign in
Fix broken selectElement value tests
d694699Tom Smalley
reflex-dom-core/test/hydration.hs+9−4
@@ -697,13 +697,18 @@ tests wdConfig caps _selenium = do
697 testWidget (pure ()) checkValue $ prerender_ (pure ()) $ do
697 testWidget (pure ()) checkValue $ prerender_ (pure ()) $ do
698 (e, ()) <- selectElement def options
698 (e, ()) <- selectElement def options
699 performEvent_ $ liftIO . writeRef focusRef <$> updated (_selectElement_hasFocus e)
699 performEvent_ $ liftIO . writeRef focusRef <$> updated (_selectElement_hasFocus e)
700+ it "has correct initial value" $ runWD $ do
701+ valueRef :: IORef Text <- newRef ""
702+ let checkValue = readRef valueRef >>= flip shouldBe "one"
703+ testWidget (pure ()) checkValue $ do
704+ prerender_ (pure ()) $ do
705+ (e, ()) <- selectElement def { _selectElementConfig_initialValue = "one" } options
706+ liftIO . writeRef valueRef <=< sample $ current $ _selectElement_value e
700 it "sets value appropriately" $ runWD $ do
707 it "sets value appropriately" $ runWD $ do
701 valueByUIRef :: IORef Text <- newRef ""
708 valueByUIRef :: IORef Text <- newRef ""
702 valueRef :: IORef Text <- newRef ""
709 valueRef :: IORef Text <- newRef ""
703 setValueChan :: Chan Text <- liftIO newChan
710 setValueChan :: Chan Text <- liftIO newChan
704 let checkValue = do
711 let checkValue = do
705− readRef valueByUIRef >>= flip shouldBe "one"
706− readRef valueRef >>= flip shouldBe "one"
707 WD.click <=< WD.findElem $ WD.ById "two"
712 WD.click <=< WD.findElem $ WD.ById "two"
708 liftIO $ threadDelay 100000
713 liftIO $ threadDelay 100000
709 readRef valueByUIRef >>= flip shouldBe "two"
714 readRef valueByUIRef >>= flip shouldBe "two"
@@ -1357,8 +1362,8 @@ getFreePort = liftIO $ withSocketsDo $ do
1357 bind sock (addrAddress addr)
1362 bind sock (addrAddress addr)
1358 return sock
1363 return sock
1359
1364
1360−testWidgetDebug :: (forall m js. TestWidget js (SpiderTimeline Global) m => m ()) -> IO ()
1365+testWidgetDebug :: MonadIO n => (forall m js. TestWidget js (SpiderTimeline Global) m => m ()) -> n ()
1361−testWidgetDebug bodyWidget = do
1366+testWidgetDebug bodyWidget = liftIO $ do
1362 let staticApp = do
1367 let staticApp = do
1363 el "head" $ pure ()
1368 el "head" $ pure ()
1364 el "body" $ do
1369 el "body" $ do