Create Test Cases for User, Product and Cart
admin login
Request Header
none
Request Body
email : [email protected]
password : adminganteng
Response(200)
{
id: 1,
username: admin,
email: [email protected]
access_token : "token string"
}
Response(400)
{
message : "Wrong email/password"
}
Response(500)
{
message : "Internal server error"
}
Register
Request Header
none
Request Body
username : icanq
email : [email protected]
password : okeoke
Response(201)
{
id: 1,
username: icanq,
email: [email protected]
}
Response(400)
{
message : "username taken",
message : "Username is required, cannot be blank",
message : "Email have been registered",
message : "Password is required cannot be blank",
message : "Password minimal 6 character",
}
Response(500)
{
message : "Internal server error"
}
login
Request Header
none
Request Body
email : [email protected]
password : okeoke
Response(200)
{
access_token : "token string"
}
Response(404)
{
message : 'Account not found'
}
Response(400)
{
message : "Wrong email/password"
}
Response(500)
{
message : "Internal server error"
}
create product
Request Header
access_token : 'token string'
Request Body
{
"name": "rendang daging mantap betul",
"image_url": "https://www.kitchensanctuary.com/wp-content/uploads/2018/01/Beef-Rendang-square-FS-28.jpg",
"price": 30000,
"stock": 300,
}
Response(201)
{
"id": 5,
"name": "rendang daging mantap betul",
"image_url": "https://www.kitchensanctuary.com/wp-content/uploads/2018/01/Beef-Rendang-square-FS-28.jpg",
"price": 30000,
"stock": 300,
"UserId": 1,
"updatedAt": "2020-12-18T02:45:27.504Z",
"createdAt": "2020-12-18T02:45:27.504Z"
}
Response(401)
{
message : 'login first'
}
Response(400)
{
message : "Name is required, cannot be blank",
message : "Name cannot be null",
message : "ImageUrl is required, cannot be blank",
message : "ImageUrl cannot be null",
message : "Price is required, cannot be blank",
message : "Price must be number",
message : "Cannot set to minus",
message : "Stock is required, cannot be blank",
message : "Stock must be number",
message : "Cannot set to minus",
}
Response(500)
{
message : "Internal server error"
}
fetch all products
Request Header
access_token : 'token string'
Request Body
{
none
}
Response(200)
[
{
"id": 1,
"name": "rendang rancak bana",
"image_url": "https://asset.kompas.com/crops/gi24VPQMhftubxYIWPJATjHrxTA=/0x0:1000x667/750x500/data/photo/2020/06/30/5efb0cb4a0226.jpg",
"price": 125000,
"stock": 200,
"UserId": 1,
"createdAt": "2020-12-12T09:20:38.587Z",
"updatedAt": "2020-12-12T09:20:49.098Z"
},
{
"id": 2,
"name": "nasi daging enak pokoknya",
"image_url": "https://i0.wp.com/www.pesenmakan.id/wp-content/uploads/2020/02/makanan-enak-di-jakarta-3.jpg?resize=696%2C696&ssl=1",
"price": 20000,
"stock": 333,
"UserId": 1,
"createdAt": "2020-12-12T16:16:25.240Z",
"updatedAt": "2020-12-12T16:16:36.714Z"
},
{
"id": 4,
"name": "Sandal Baginda",
"image_url": "https://www.static-src.com/wcsstore/Indraprastha/images/catalog/full//85/MTA-2825131/swallow_swallow-sandal-jepit-original_full03.jpg",
"price": 10000,
"stock": 5,
"UserId": 1,
"createdAt": "2020-12-15T02:41:31.458Z",
"updatedAt": "2020-12-15T02:41:50.408Z"
},
{
"id": 5,
"name": "rendang daging mantap betul",
"image_url": "https://www.kitchensanctuary.com/wp-content/uploads/2018/01/Beef-Rendang-square-FS-28.jpg",
"price": 30000,
"stock": 300,
"UserId": 1,
"createdAt": "2020-12-18T02:45:27.504Z",
"updatedAt": "2020-12-18T02:45:27.504Z"
}
]
Response(500)
{
message : "Internal server error"
}
find by id
Request Header
access_token : 'token string'
Request Body
{
none
}
Request Params
{
id : 2
}
Response(200)
{
"id": 2,
"name": "nasi daging enak pokoknya",
"image_url": "https://i0.wp.com/www.pesenmakan.id/wp-content/uploads/2020/02/makanan-enak-di-jakarta-3.jpg?resize=696%2C696&ssl=1",
"price": 20000,
"stock": 333,
"UserId": 1,
"createdAt": "2020-12-12T16:16:25.240Z",
"updatedAt": "2020-12-12T16:16:36.714Z"
}
Response(500)
{
message : "Internal server error"
}
edit product
Request Header
access_token : 'token string'
Request Params
id : 2
Request Body
{
"name" : "nasi kapau",
"image_url" : "https://i0.wp.com/www.pesenmakan.id/wp-content/uploads/2020/02/makanan-enak-di-jakarta-3.jpg?resize=696%2C696&ssl=1",
"price" : 40000,
"stock" : 3000,
}
Response(200)
{
"id": 2,
"name": "nasi daging enak pokoknya",
"image_url": "https://i0.wp.com/www.pesenmakan.id/wp-content/uploads/2020/02/makanan-enak-di-jakarta-3.jpg?resize=696%2C696&ssl=1",
"price": 20000,
"stock": 333,
"UserId": 1,
"createdAt": "2020-12-12T16:16:25.240Z",
"updatedAt": "2020-12-12T16:16:36.714Z"
}
Response(404)
{
"message": "Product not found"
}
Response(401)
{
"message": "login first"
}
Response(401)
{
"message": "Unauthorized"
}
Response(400)
{
"message": [
"Name is required, cannot be blank",
"Name cannot be null",
"ImageUrl is required, cannot be blank",
"ImageUrl cannot be null",
"Price is required, cannot be blank",
"Price must be number",
"Cannot set to minus",
"Stock is required, cannot be blank",
"Stock must be number",
"Cannot set to minus",
]
}
delete product
Request Header
access_token : 'token string'
Request Params
id : 3
Request Body
{
none
}
Response(200)
{
"message": "Succesfully deleted"
}
Response(401)
{
"message": "login first"
}
Response(401)
{
"message": "Unauthorized"
}
create or edit a cart for customer
Request Header
access_token: 'token string'
Request Body
ProductId: integer
Response(201)
{
"Cart": {
"id": 11,
"ProductId": 5,
"UserId": 3,
"quantity": 1,
"Status": false,
"updatedAt": "2020-12-18T02:58:22.117Z",
"createdAt": "2020-12-18T02:58:22.117Z"
}
}
Response(200)
{
"Cart": {
"id": 11,
"ProductId": 5,
"UserId": 3,
"quantity": 2,
"Status": false,
"updatedAt": "2020-12-18T02:58:22.117Z",
"createdAt": "2020-12-18T02:58:22.117Z"
}
}
Response(401)
{
message: 'lack of stock'
}
Response(500)
{
message: 'Internal server error'
}
fetch all carts with status false(unpaid)
Request Header
access_token: 'string'
Request Body
none
Response(200)
{
"data": [
{
"id": 2,
"ProductId": 2,
"UserId": 1,
"quantity": 5,
"Status": false,
"createdAt": "2020-12-17T04:46:10.299Z",
"updatedAt": "2020-12-17T05:50:24.331Z",
"Product": {
"id": 2,
"name": "nasi daging enak pokoknya",
"image_url": "https://i0.wp.com/www.pesenmakan.id/wp-content/uploads/2020/02/makanan-enak-di-jakarta-3.jpg?resize=696%2C696&ssl=1",
"price": 20000,
"stock": 333,
"UserId": 1,
"createdAt": "2020-12-12T16:16:25.240Z",
"updatedAt": "2020-12-12T16:16:36.714Z"
}
},
{
"id": 1,
"ProductId": 1,
"UserId": 1,
"quantity": 1,
"Status": false,
"createdAt": "2020-12-17T04:45:50.940Z",
"updatedAt": "2020-12-17T07:07:13.826Z",
"Product": {
"id": 1,
"name": "rendang rancak bana",
"image_url": "https://asset.kompas.com/crops/gi24VPQMhftubxYIWPJATjHrxTA=/0x0:1000x667/750x500/data/photo/2020/06/30/5efb0cb4a0226.jpg",
"price": 125000,
"stock": 200,
"UserId": 1,
"createdAt": "2020-12-12T09:20:38.587Z",
"updatedAt": "2020-12-12T09:20:49.098Z"
}
}
],
"totalPrice": 225000
}
Response(500)
{
message: 'internal server error'
}
delete a cart for customer
Request Header
access_token: 'string'
Request Body
cartId
Response(200)
{
message: 'remove product from cart succeed'
}
Response(500)
{
message: 'Internal server error'
}
checkout all active cart for customer
Request Header
access_token: 'string'
Request Body
none
Response(200)
{
message: "checkout success"
}
Response(400)
{
message: "Internal server error"
}