module Test.FeatureFlags.BackgroundEffects where
import SetupHelpers (createTeam)
import Test.FeatureFlags.Util
import Testlib.Prelude
testPatchBackgroundEffects :: (HasCallStack) => App ()
testPatchBackgroundEffects :: HasCallStack => App ()
testPatchBackgroundEffects = Int -> App () -> App ()
forall a. Int -> App a -> App a
withAPIVersion Int
16 (App () -> App ()) -> App () -> App ()
forall a b. (a -> b) -> a -> b
$ Domain -> String -> Value -> App ()
forall domain.
(HasCallStack, MakesValue domain) =>
domain -> String -> Value -> App ()
checkPatch Domain
OwnDomain String
"backgroundEffects" Value
enabled
testBackgroundEffects :: (HasCallStack) => APIAccess -> App ()
testBackgroundEffects :: HasCallStack => APIAccess -> App ()
testBackgroundEffects APIAccess
access =
Int -> App () -> App ()
forall a. Int -> App a -> App a
withAPIVersion Int
16
(App () -> App ()) -> App () -> App ()
forall a b. (a -> b) -> a -> b
$ String -> FeatureTests
mkFeatureTests String
"backgroundEffects"
FeatureTests -> (FeatureTests -> FeatureTests) -> FeatureTests
forall a b. a -> (a -> b) -> b
& Value -> FeatureTests -> FeatureTests
addUpdate Value
enabled
FeatureTests -> (FeatureTests -> App ()) -> App ()
forall a b. a -> (a -> b) -> b
& Domain -> APIAccess -> FeatureTests -> App ()
forall domain.
(HasCallStack, MakesValue domain) =>
domain -> APIAccess -> FeatureTests -> App ()
runFeatureTests Domain
OwnDomain APIAccess
access
testBackgroundEffectsRemovedAtV17 :: (HasCallStack) => App ()
testBackgroundEffectsRemovedAtV17 :: HasCallStack => App ()
testBackgroundEffectsRemovedAtV17 = do
(owner, tid, []) <- Domain -> Int -> App (Value, String, [Value])
forall domain.
(HasCallStack, MakesValue domain) =>
domain -> Int -> App (Value, String, [Value])
createTeam Domain
OwnDomain Int
0
let p = [String] -> String
joinHttpPath [String
"teams", String
tid, String
"features", String
"backgroundEffects"]
body = [Pair] -> Value
object [String
"status" String -> String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= String
"enabled", String
"lockStatus" String -> String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= String
"locked"]
bindResponse (baseRequest owner Galley (ExplicitVersion 17) p >>= submit "GET") $ assertStatus 404
bindResponse (baseRequest owner Galley (ExplicitVersion 17) p <&> addJSON body >>= submit "PUT") $ assertStatus 404
bindResponse (baseRequest owner Galley (ExplicitVersion 16) p >>= submit "GET") $ \Response
resp -> do
Response
resp.status Int -> Int -> App ()
forall a. (MakesValue a, HasCallStack) => a -> Int -> App ()
`shouldMatchInt` Int
200
Response
resp.json Maybe Value -> String -> App Value
forall a. (HasCallStack, MakesValue a) => a -> String -> App Value
%. String
"status" App Value -> String -> App ()
forall a b.
(MakesValue a, MakesValue b, HasCallStack) =>
a -> b -> App ()
`shouldMatch` String
"enabled"
Response
resp.json Maybe Value -> String -> App Value
forall a. (HasCallStack, MakesValue a) => a -> String -> App Value
%. String
"lockStatus" App Value -> String -> App ()
forall a b.
(MakesValue a, MakesValue b, HasCallStack) =>
a -> b -> App ()
`shouldMatch` String
"locked"
testBackgroundEffectsListedAtV17 :: (HasCallStack) => App ()
testBackgroundEffectsListedAtV17 :: HasCallStack => App ()
testBackgroundEffectsListedAtV17 = do
(owner, tid, []) <- Domain -> Int -> App (Value, String, [Value])
forall domain.
(HasCallStack, MakesValue domain) =>
domain -> Int -> App (Value, String, [Value])
createTeam Domain
OwnDomain Int
0
let assertBackgroundEffects r
resp = do
r
resp.status a -> Int -> App ()
forall a. (MakesValue a, HasCallStack) => a -> Int -> App ()
`shouldMatchInt` Int
200
be <- r
resp.json a -> String -> App Value
forall a. (HasCallStack, MakesValue a) => a -> String -> App Value
%. String
"backgroundEffects"
be %. "status" `shouldMatch` "enabled"
be %. "lockStatus" `shouldMatch` "locked"
teamFeatures = [String] -> String
joinHttpPath [String
"teams", String
tid, String
"features"]
bindResponse (baseRequest owner Galley (ExplicitVersion 17) "/feature-configs" >>= submit "GET") assertBackgroundEffects
bindResponse (baseRequest owner Galley (ExplicitVersion 17) teamFeatures >>= submit "GET") assertBackgroundEffects