feat: add v2 hub and widget create endpoints
This commit is contained in:
parent
0a4646bf44
commit
4ebc04e1f4
11 changed files with 536 additions and 154 deletions
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue