generated from coulomb/repo-seed
feat: add v2 hub and widget create endpoints
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
This commit is contained in:
30
Test/Main.hs
30
Test/Main.hs
@@ -8,6 +8,8 @@ import Web.Controller.Api.V2.InteractionEvents
|
||||
( declaredEventTypeNames, manifestAllowsEvent, metadataFromJsonBody
|
||||
, metadataParamOrEmpty
|
||||
)
|
||||
import Web.Controller.Api.V2.Hubs (missingRequiredFields, validCreateHubKind)
|
||||
import Web.Controller.Api.V2.Widgets (missingWidgetCreateFields, validWidgetStatus)
|
||||
|
||||
main :: IO ()
|
||||
main = hspec do
|
||||
@@ -44,4 +46,32 @@ main = hspec do
|
||||
metadataParamOrEmpty (Just metadata) `shouldBe` metadata
|
||||
metadataParamOrEmpty Nothing `shouldBe` object []
|
||||
|
||||
describe "API v2 hub and widget create validation" do
|
||||
it "accepts scriptable domain/shared hub kinds only" do
|
||||
validCreateHubKind "domain" `shouldBe` True
|
||||
validCreateHubKind "shared" `shouldBe` True
|
||||
validCreateHubKind "framework" `shouldBe` False
|
||||
|
||||
it "reports missing hub create fields including empty strings" do
|
||||
missingRequiredFields
|
||||
[ ("slug", Just "")
|
||||
, ("name", Nothing)
|
||||
, ("domain", Just "operations")
|
||||
]
|
||||
`shouldBe` ["slug", "name"]
|
||||
|
||||
it "accepts widget statuses supported by the UI create flow" do
|
||||
validWidgetStatus "active" `shouldBe` True
|
||||
validWidgetStatus "deprecated" `shouldBe` True
|
||||
validWidgetStatus "draft" `shouldBe` True
|
||||
validWidgetStatus "archived" `shouldBe` False
|
||||
|
||||
it "reports missing widget create fields including empty strings" do
|
||||
missingWidgetCreateFields
|
||||
[ ("hubId", Just "")
|
||||
, ("name", Just "Ops endpoint card")
|
||||
, ("widgetType", Nothing)
|
||||
]
|
||||
`shouldBe` ["hubId", "widgetType"]
|
||||
|
||||
LayerBoundary.spec
|
||||
|
||||
Reference in New Issue
Block a user