module Test.FeatureFlags.MeetingPremium where
import SetupHelpers (createTeam)
import Test.FeatureFlags.Util
import Testlib.Prelude
testPatchMeetingPremium :: (HasCallStack) => App ()
testPatchMeetingPremium :: HasCallStack => App ()
testPatchMeetingPremium = 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
"meetingsPremium" Value
disabledLocked
testMeetingPremium :: (HasCallStack) => APIAccess -> App ()
testMeetingPremium :: HasCallStack => APIAccess -> App ()
testMeetingPremium 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
"meetingsPremium"
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
testMeetingPremiumRemovedAtV17 :: (HasCallStack) => App ()
testMeetingPremiumRemovedAtV17 :: HasCallStack => App ()
testMeetingPremiumRemovedAtV17 = 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
"meetingsPremium"]
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") $ \Response
resp -> do
Response
resp.status Int -> Int -> App ()
forall a. (MakesValue a, HasCallStack) => a -> Int -> App ()
`shouldMatchInt` Int
404
bindResponse (baseRequest owner Galley (ExplicitVersion 17) p <&> addJSON body >>= submit "PUT") $ \Response
resp -> do
Response
resp.status Int -> Int -> App ()
forall a. (MakesValue a, HasCallStack) => a -> Int -> App ()
`shouldMatchInt` Int
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"
testMeetingPremiumListedAtV17 :: (HasCallStack) => App ()
testMeetingPremiumListedAtV17 :: HasCallStack => App ()
testMeetingPremiumListedAtV17 = 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 assertMeetingPremium r
resp = do
r
resp.status a -> Int -> App ()
forall a. (MakesValue a, HasCallStack) => a -> Int -> App ()
`shouldMatchInt` Int
200
mp <- r
resp.json a -> String -> App Value
forall a. (HasCallStack, MakesValue a) => a -> String -> App Value
%. String
"meetingsPremium"
mp %. "status" `shouldMatch` "enabled"
mp %. "lockStatus" `shouldMatch` "locked"
teamFeatures = [String] -> String
joinHttpPath [String
"teams", String
tid, String
"features"]
bindResponse (baseRequest owner Galley (ExplicitVersion 17) "/feature-configs" >>= submit "GET") assertMeetingPremium
bindResponse (baseRequest owner Galley (ExplicitVersion 17) teamFeatures >>= submit "GET") assertMeetingPremium