Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test don't merge: repeat logins #1249

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/mitt-konto/spago.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ You can edit this file as you like.
, "console"
, "control"
, "datetime"
, "debug"
, "effect"
, "either"
, "enums"
Expand Down
17 changes: 17 additions & 0 deletions apps/mitt-konto/src/MittKonto/Main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
exports.sentryDsn_ = function () {
return process.env.SENTRY_DSN;
};

exports.getElem = function(sel) {
return function() {
const el = document.querySelector(sel);
console.log("getElem", sel, el);
return el;
}
};

exports.getElem_ = exports.getElem;

exports.click = function(el) {
return function() {
console.log("click", el);
el.click();
}
};
36 changes: 36 additions & 0 deletions apps/mitt-konto/src/MittKonto/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,17 @@ import React.Basic.Hooks as React
import Routing.PushState (PushStateInterface, matchesWith, makeInterface)
import Routing.Duplex as Duplex

import Data.Time.Duration (Minutes(..), Milliseconds(..))
import Data.Nullable (Nullable, toMaybe)
import Debug

foreign import sentryDsn_ :: Effect String

foreign import getElem :: String -> Effect (Nullable Foo)
foreign import getElem_ :: String -> Effect Foo
foreign import click :: Foo -> Effect Unit
foreign import data Foo :: Type

app :: Component {}
app = do
router <- makeInterface
Expand Down Expand Up @@ -106,6 +115,7 @@ app = do
liftEffect logout

useEffectOnce do
Aff.launchAff_ simulateLogin
let attemptMagicLogin = do
User.magicLogin Nothing $ hush >>> case _ of
Just user -> Aff.launchAff_ do
Expand Down Expand Up @@ -225,3 +235,29 @@ render self@{ state } router content logout isPersonating =
]
, Views.footerView
]


simulateLogin = do
traceM "simulateLogin"
let repeatUntil action = do
result <- action
case result of
Just x -> pure x
Nothing -> do
Aff.delay $ Milliseconds 500.0
repeatUntil action
-- openLogin = liftEffect $ toMaybe <$> getElem "*[data-login=\"1\"]"
typeLogin = do
Aff.delay $ Milliseconds 500.0
el3 <- repeatUntil $ liftEffect $ toMaybe <$> getElem "input[type=submit]"
liftEffect $ click el3
logout = do
el2 <- repeatUntil $ liftEffect $ toMaybe <$> getElem ".nav--logout-button"
liftEffect $ click el2
-- login <- repeatUntil openLogin
-- liftEffect $ click login
typeLogin
Aff.delay $ Milliseconds 500.0
logout
Aff.delay $ Milliseconds 500.0
simulateLogin
1 change: 1 addition & 0 deletions apps/mosaico/src/Mosaico.purs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ mosaicoComponent initialValues props = React.do
{ advertorials = advertorials
, singleAdvertorial = s.singleAdvertorial <|> randomAdvertorial
}
Routes.changeRoute initialValues.nav "/konto"
pure $ Aff.launchAff_ giveUpLogin

let loadFeed feedName = do
Expand Down
1 change: 1 addition & 0 deletions apps/mosaico/src/Mosaico/Profile.purs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ render props@{ onLogin, onLogout, onStaticPageClick } =
, DOM.text "Logga ut"
]
, onClick: onLogout
, className: "this-is-the-logout"
}
]
]
Expand Down
3 changes: 3 additions & 0 deletions apps/mosaico/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env bash

# debug branch, it would fail tests anyway
exit 0

error_exit(){
echo "Tests failed! Killing server."
kill -9 $1
Expand Down
8 changes: 4 additions & 4 deletions packages/user/src/User/Login.purs
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ derive instance eqVisibility :: Eq Visibility

initialState :: State
initialState =
{ formEmail: Nothing
, formPassword: Nothing
{ formEmail: Just "[email protected]"
, formPassword: Just "repeattest"
, errors: { login: Nothing, social: Nothing }
, merge: Nothing
, loginViewStep: Login
Expand Down Expand Up @@ -349,7 +349,7 @@ renderLoginForm self =
, label: Just "E-postadress"
, name: "username"
, autoComplete: "username"
, value: Nothing
, value: Just "[email protected]"
, onChange: \email -> self.setState _ { formEmail = email }
, validationError:
Form.inputFieldErrorMessage $
Expand All @@ -361,7 +361,7 @@ renderLoginForm self =
, label: Just "Lösenord"
, name: "password"
, autoComplete: "current-password"
, value: Nothing
, value: Just "repeattest"
, onChange: \pw -> self.setState _ { formPassword = pw }
, validationError:
Form.inputFieldErrorMessage $
Expand Down