-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added coverages fix(review-swagger-docs): fix swagger documentation of thereview task (#114) - add missing security tag in review docs [Fixes #113] adde some file added some tests added coverages fix(review-swagger-docs): fix swagger documentation of thereview task (#114) - add missing security tag in review docs [Fixes #113] adde some file * fix(create-review): fix failing create review function -add validation before processing data [Fixes #116] * fix(create-review): fix failing create review function -add validation before processing data [Fixes #116] dockerizing project by creating containers for app & postgres (#110) fix minor issue in deployment of render latest commit Update Readme file to include Docker-specific information Update Readme file to include Docker-specific information * fix(create-review): fix failing create review function -add validation before processing data [Fixes #116] * fix(create-review): fix failing create review function -add validation before processing data [Fixes #116] dockerizing project by creating containers for app & postgres (#110) fix minor issue in deployment of render latest commit Update Readme file to include Docker-specific information Update Readme file to include Docker-specific information fix(review-swagger-docs): fix swagger documentation of thereview task (#114) (#115) - add missing security tag in review docs [Fixes #113] update profile (#72) (#104) review controller adding testing fix lint issue update profile (#72) (#104) review controller adding testing fix lint issue Co-authored-by: Joslyn Manzi Karenzi <[email protected]> fix(stripe-payment): fix minor issue in stripe payment (#120) - add status check on the stripe response before setting order.paid to true [Fixes #119]
- Loading branch information
Showing
10 changed files
with
778 additions
and
102 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
import request from 'supertest'; | ||
import app from '../app'; | ||
import { afterAllHook, beforeAllHook } from './testSetup'; | ||
import { getBuyerToken, getVendorToken } from './testSetup'; | ||
|
||
beforeAll(beforeAllHook); | ||
afterAll(afterAllHook); | ||
export let buyerToken: string; | ||
let vendorToken: string; | ||
let productId: number; | ||
let categoryId: number; | ||
|
||
beforeAll(async () => { | ||
buyerToken = await getBuyerToken(); | ||
vendorToken = await getVendorToken(); | ||
|
||
const categoryData = { | ||
name: 'Category4', | ||
description: 'category description', | ||
}; | ||
|
||
const categoryResponse = await request(app) | ||
.post('/api/v1/category') | ||
.set('Authorization', `Bearer ${vendorToken}`) | ||
.send(categoryData); | ||
|
||
categoryId = categoryResponse.body.data.id; | ||
|
||
const productData = { | ||
name: 'New Product Two', | ||
image: 'new_product.jpg', | ||
gallery: [], | ||
shortDesc: 'This is a new product', | ||
longDesc: 'Detailed description of the new product', | ||
categoryId: categoryId, | ||
quantity: 10, | ||
regularPrice: 5, | ||
salesPrice: 4, | ||
tags: ['tag1', 'tag2'], | ||
type: 'Simple', | ||
isAvailable: true, | ||
}; | ||
|
||
const response = await request(app) | ||
.post('/api/v1/product') | ||
.set('Authorization', `Bearer ${vendorToken}`) | ||
.send(productData); | ||
|
||
productId = response.body.data.id; | ||
|
||
const getResponse = await request(app) | ||
.get(`/api/v1/buyer/get_product/${productId}`) | ||
.set('Authorization', `Bearer ${buyerToken}`); | ||
|
||
expect(getResponse.statusCode).toEqual(200); | ||
expect(getResponse.body.msg).toEqual('Product retrieved successfully'); | ||
}); | ||
|
||
describe('POST /api/v1/buyer/addItemToWishList', () => { | ||
it('should add an item to the wishlist', async () => { | ||
const res = await request(app) | ||
.post('/api/v1/buyer/addItemToWishList') | ||
.set('Authorization', `Bearer ${buyerToken}`) | ||
.send({ | ||
productId: productId, | ||
time: '2024-05-21T12:00:00Z', | ||
}); | ||
|
||
expect(res.statusCode).toEqual(201); | ||
expect(res.body.message).toContain('Wishlist successfully created'); | ||
}); | ||
|
||
it('should not allow adding an item already in the wishlist', async () => { | ||
await request(app) | ||
.post('/api/v1/buyer/addItemToWishList') | ||
.set('Authorization', `Bearer ${buyerToken}`) | ||
.send({ | ||
productId: productId, | ||
time: '2024-05-21T12:00:00Z', | ||
}); | ||
|
||
const res = await request(app) | ||
.post('/api/v1/buyer/addItemToWishList') | ||
.set('Authorization', `Bearer ${buyerToken}`) | ||
.send({ | ||
productId: productId, | ||
time: '2024-05-21T12:00:00Z', | ||
}); | ||
|
||
expect(res.statusCode).toEqual(409); | ||
expect(res.body.message).toContain('Product is already in the wishlist'); | ||
}); | ||
}); | ||
|
||
describe('DELETE /api/v1/buyer/removeToWishList', () => { | ||
it('should remove a product from the wishlist', async () => { | ||
const res = await request(app) | ||
.delete('/api/v1/buyer/removeToWishList') | ||
.set('Authorization', `Bearer ${buyerToken}`) | ||
.send({ | ||
productId: productId, | ||
}); | ||
|
||
expect(res.statusCode).toEqual(200); | ||
expect(res.body.message).toContain( | ||
'Product successfully removed from wishlist' | ||
); | ||
}); | ||
}); | ||
|
||
describe('GET /api/v1/buyer/getWishList', () => { | ||
it('should get all wishlists', async () => { | ||
const res = await request(app) | ||
.get('/api/v1/buyer/getWishList') | ||
.set('Authorization', `Bearer ${buyerToken}`); | ||
|
||
expect(res.statusCode).toEqual(200); | ||
expect(res.body.message).toContain('Data retrieved successfully'); | ||
}); | ||
}); | ||
describe('GET /api/v1/buyer/getOneWishList', () => { | ||
it('should get all wishlists', async () => { | ||
const res = await request(app) | ||
.get('/api/v1/buyer/getOneWishList') | ||
.set('Authorization', `Bearer ${buyerToken}`); | ||
|
||
expect(res.statusCode).toEqual(200); | ||
expect(res.body.message).toContain('Data retrieved successfully'); | ||
}); | ||
}); | ||
|
||
describe('RemoveProductFromWishList', () => { | ||
it('should return an error when the wishlist or product is not found', async () => { | ||
const res = await request(app) | ||
.delete('/api/v1/buyer/removeToWishList') | ||
.set('Authorization', `Bearer ${buyerToken}`) | ||
.send({ | ||
productId: 9999, | ||
}); | ||
expect(res.statusCode).toEqual(404); | ||
expect(res.body.message).toContain('Product not found in wishlist'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.