API endpoint test cases - WgtTelia/Telia-e-shop-front-end GitHub Wiki

API test cases.

Preconditions for all API endpoints:

> The API is up and running. > The id's for the endpoints are valid. > The API returns a response within a reasonable time frame.

PUT requests:

  • /api/classifiers/productGroups/{id}
  • /api/classifiers/priceIntervals/{id}
  • /api/classifiers/colors/{id}
  • /api/classifiers/brands/{id}

POST requests:

  • /api/classifiers/productGroups
  • /api/classifiers/priceIntervals
  • /api/classifiers/colors
  • /api/classifiers/brands

DELETE requests:

  • /api/classifiers/productGroups/{id}
  • /api/classifiers/priceIntervals/{id}
  • /api/classifiers/colors/{id}
  • /api/classifiers/brands/{id}

GET requests:

*** /api/classifiers**

Typical error scenarios:

  • Unauthorized Request: Status Code: 401 Unauthorized Response: {"error": "Authentication required"}
  • Service Unavailable: Status Code: 503 Service Unavailable Response: {"error": "Service is currently unavailable"}
  • Invalid ID: Status Code: 404 Not Found Response: {"error": "Classifier not found"}
  Test case Endpoint Expected result Status code
get Fetch all products /api/classifiers {   "productGroups": [     "string"   ],   "brands": [     "string"   ],   "colors": [     "string"   ],   "priceIntervals": [     "string"   ],   "stockOptions": [     "string"   ] } 200
get Fetch a product with an invalid/non-existent ID /api/classifiers/{id} Nothing 404
post Create a new classifier /api/classifiers/ {   "productGroups": [     "string"   ],   "brands": [     "string"   ],   "colors": [     "string"   ],   "priceIntervals": [     "string"   ],   "stockOptions": [     "string"   ] } 200
post Create a new classifier with missing fields /api/classifiers/ Nothing 400
put Update existing classifier /api/classifiers/{id} {   "productGroups": [     "string"   ],   "brands": [     "string"   ],   "colors": [     "string"   ],   "priceIntervals": [     "string"   ],   "stockOptions": [     "string"   ] } 200
  Update existing classifier with invalid fields /api/classifiers/{id} Nothing 400
delete Delete classifier with invalid id /api/classifiers/{id} Nothing 404
  Test case Endpoint Expected result Status code
get Fetch all product groups /api/classifiers/productGroups{id} {   "id": 0,   "name": "string" } 200
get Fetch a product group with an invalid/non-existent ID /api/classifiers/productGroups{id} Nothing 404
post Create a new product group /api/classifiers/productGroups{id} {   "id": 0,   "name": "string" } 200
post Create a new product group with missing field /api/classifiers/productGroups{id} Nothing 400
put Update existing product group /api/classifiers/productGroups{id} {   "id": 0,   "name": "string" } 200
  Update existing product group with invalid fields /api/classifiers/productGroups{id} Nothing 400
delete Delete product group with invalid id /api/classifiers/productGroups{id} Nothing 404
delete Delete product group  with valid id /api/classifiers/productGroups{id} Resource should be deleted 204
  Test case Endpoint Expected result Status code
get Fetch all price intervals /api/classifiers/priceIntervals/{id} {   "id": 0,   "name": "string",   "minPrice": 0,   "maxPrice": 0 } 200
-- -- -- -- --
get Fetch a price interval with an invalid/non-existent ID /api/classifiers/priceIntervals/{id} Nothing 404
post Create a new price interval /api/classifiers/priceIntervals/{id} {   "id": 0,   "name": "string",   "minPrice": 0,   "maxPrice": 0 } 200
post Create a new price interval with missing field /api/classifiers/priceIntervals/{id} Nothing 400
post Create a new price interval with invalid prices /api/classifiers/priceIntervals/{id} Nothing 400
put Update existing price interval /api/classifiers/priceIntervals/{id} {   "id": 0,   "name": "string",   "minPrice": 0,   "maxPrice": 0 } 200
  Update existing price interval with invalid fields /api/classifiers/priceIntervals/{id} Nothing 400
delete Delete price interval with invalid id /api/classifiers/priceIntervals/{id} Nothing 404
  Delete price interval with valid id /api/classifiers/priceIntervals/{id} Resource should be deleted 204
  Test case Endpoint Expected result Status code
get Fetch all colors /api/classifiers/colors/{id} {   "id": 0,   "name": "string" } 200
-- -- -- -- --
get Fetch a color with an invalid/non-existent ID /api/classifiers/colors/{id} Nothing 404
post Create a new color /api/classifiers/colors/{id} {   "id": 0,   "name": "string" } 200
post Create a new color with missing field /api/classifiers/colors/{id} Nothing 400
post Create a new color with invalid prices /api/classifiers/colors/{id} Nothing 400
put Update existing color /api/classifiers/colors/{id} {   "id": 0,   "name": "string" } 200
  Update existing colorl with invalid fields /api/classifiers/colors/{id} Nothing 400
delete Delete color with invalid id /api/classifiers/colors/{id} Nothing 404
  Delete color with valid id /api/classifiers/colors/{id} Resource should be deleted 204
  Test case Endpoint Expected result Status code
get Fetch all brands /api/classifiers/brands/{id} {   "id": 0,   "name": "string" } 200
-- -- -- -- --
  Fetch a brand with an invalid/non-existent ID /api/classifiers/brands/{id} Nothing 404
post Create a new brand /api/classifiers/brands/{id} {   "id": 0,   "name": "string" } 200
  Create a new brand with missing field /api/classifiers/brands/{id} Nothing 400
  Create a new brand with invalid prices /api/classifiers/brands/{id} Nothing 400
put Update existing brand /api/classifiers/brands/{id} {   "id": 0,   "name": "string" } 200
  Update existing brand with invalid fields /api/classifiers/brands/{id} Nothing 400
delete Delete brand with invalid id /api/classifiers/brands/{id} Nothing 404
  Delete brand with valid id /api/classifiers/brands/{id} Resource should be deleted 204
  Test case Endpoint Expected result Status code
get Fetch all products /api/shop/products {   "content": [     {       "id": 0,       "productGroup": "string",       "brand": "string",       "code": "string",       "name": "string",       "shortDescription": "string",       "orderCount": 0,       "productVariants": [         {           "color": "string",           "imgUrl": "string",           "monthlyPrice": 0,           "defaultVariant": true,           "stock": [             {               "qtyInStock": 0             }           ]         }       ]     }   ],   "page": {     "size": 0,     "number": 0,     "totalElements": 0,     "totalPages": 0   } } 200
  Fetch a product with an invalid/non-existent ID /api/shop/products Nothing 404
post Create a new product /api/shop/products {   "content": [     {       "id": 0,       "productGroup": "string",       "brand": "string",       "code": "string",       "name": "string",       "shortDescription": "string",       "orderCount": 0,       "productVariants": [         {           "color": "string",           "imgUrl": "string",           "monthlyPrice": 0,           "defaultVariant": true,           "stock": [             {               "qtyInStock": 0             }           ]         }       ]     }   ],   "page": {     "size": 0,     "number": 0,     "totalElements": 0,     "totalPages": 0   } } 200
  Create a new product with missing field /api/shop/products Nothing 400
  Create a new product with invalid prices /api/shop/products Nothing 400
put Update existing product /api/shop/products {   "content": [     {       "id": 0,       "productGroup": "string",       "brand": "string",       "code": "string",       "name": "string",       "shortDescription": "string",       "orderCount": 0,       "productVariants": [         {           "color": "string",           "imgUrl": "string",           "monthlyPrice": 0,           "defaultVariant": true,           "stock": [             {               "qtyInStock": 0             }           ]         }       ]     }   ],   "page": {     "size": 0,     "number": 0,     "totalElements": 0,     "totalPages": 0   } } 200
  Update existing product with invalid fields /api/shop/products Nothing 400
delete Delete product with invalid id /api/shop/products Nothing 404
  Delete product with valid id /api/shop/products Resource should be deleted 204

api test cases.xlsx

⚠️ **GitHub.com Fallback** ⚠️