StrikekitStrikekit

API orders example

Platform api create, assert, store, and verbs as a complete .stk

Requires $API_BASE_URL and $API_TOKEN. Place create-order.json beside the .stk (or under files/) for the body-file scenario.

Platform: api

Group: Tier F — API orders

Scenario: Create order and assert json
  When I api set header "Authorization" to "Bearer $API_TOKEN"
  When I api post "/orders" with body '{"item":"book"}'
  Then I api should status "201"
  And I api should body contain "book"
  And I api should json path "$.id" exist
  And I api should json path "$.item" be "book"
  When I store "@order-id" from api json "$.id"
  Then I api should json path "$.id" be "@order-id"
  When I api get "/orders"
  Then I api should status "200"
  And I api should body contain "@order-id"

Scenario: Post with body file
  When I api set header "Authorization" to "Bearer $API_TOKEN"
  When I api post "/orders" with body file "create-order.json"
  Then I api should status "201"
  And I api should json path "$.item" be "notebook"

Scenario: Put patch delete
  When I api set header "Authorization" to "Bearer $API_TOKEN"
  When I api put "/orders/ord-1" with body '{"item":"pen"}'
  Then I api should status "200"
  When I api patch "/orders/ord-1" with body '{"item":"pencil"}'
  Then I api should status "200"
  When I api delete "/orders/ord-1"
  Then I api should status "204"

On this page