Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 changelog.d/5-internal/deflake-phone
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid a flaky test to fail related to phone updates and improve failure output.
3 changes: 3 additions & 0 deletions services/brig/test/integration/API/User/Account.hs
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,9 @@ testPhoneUpdateBlacklisted brig = do
const 200 === statusCode
const (Right Nothing) === fmap userPhone . responseJsonEither

-- cleanup to avoid other tests failing sporadically
deletePrefix brig prefix

testCreateAccountPendingActivationKey :: Opt.Opts -> Brig -> Http ()
testCreateAccountPendingActivationKey (Opt.setRestrictUserCreation . Opt.optSettings -> Just True) _ = pure ()
testCreateAccountPendingActivationKey _ brig = do
Expand Down
8 changes: 5 additions & 3 deletions services/brig/test/integration/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -727,12 +727,14 @@ randomPhone = liftIO $ do
let phone = parsePhone . Text.pack $ "+0" ++ concat nrs
return $ fromMaybe (error "Invalid random phone#") phone

updatePhone :: Brig -> UserId -> Phone -> Http ()
updatePhone :: HasCallStack => Brig -> UserId -> Phone -> Http ()
updatePhone brig uid phn = do
-- update phone
let phoneUpdate = RequestBodyLBS . encode $ PhoneUpdate phn
put (brig . path "/self/phone" . contentJson . zUser uid . zConn "c" . body phoneUpdate)
!!! (const 202 === statusCode)
failMsg = "updatePhone (PUT /self/phone): failed to update to " <> show phn <> " - might be a flaky test tracked in https://wearezeta.atlassian.net/browse/BE-526"
put (brig . path "/self/phone" . contentJson . zUser uid . zConn "c" . body phoneUpdate) !!! do
const 202 === statusCode
assertTrue failMsg ((== 202) . statusCode)
-- activate
act <- getActivationCode brig (Right phn)
case act of
Expand Down