diff --git a/README.md b/README.md index 2c41956..3807c51 100644 --- a/README.md +++ b/README.md @@ -13,28 +13,33 @@ To enhance performance and scalability, the system incorporates Redis for cachin - [With Docker](#with-docker) - [Running Tests](#running-tests) - [API Documentation](#api-documentation) +- [API Collections](/API/API%20postmanCollection.json) ## Running the Application ### Locally 1. **Clone the Repository**: + ```bash git clone https://github.com/PrasanthVijayy/product-management-system.git ``` 2. **Install Dependencies**: + ```bash npm install ``` 3. **Create a `.env` File**: Copy the example `.env` file and adjust the configuration as needed: + ```bash cp .env.example .env ``` 4. **Run the Application**: + ```bash npm start ``` @@ -45,6 +50,7 @@ To enhance performance and scalability, the system incorporates Redis for cachin 1. **Build and Start Containers**: Ensure Docker and Docker Compose are installed, then run: + ```bash docker-compose up --build ``` @@ -57,7 +63,11 @@ To enhance performance and scalability, the system incorporates Redis for cachin ## Running Tests 1. **Unit and Integration Tests**: + Folder for [Unit Test](/tests/restAPI/unitTesting/) + Folder for [Integration Test](/tests/restAPI/intergration/) + Run the following command to execute the test suite: + ```bash npm test ``` @@ -65,9 +75,8 @@ To enhance performance and scalability, the system incorporates Redis for cachin This will run all unit and integration tests defined in the `test` directory using Jest. 2. **Test Status**: - To view the test status and results in a more readable format, an HTML report is generated after test execution. You can open the generated HTML file to see a detailed view of the test results. + To view the test status and results in a more readable format, an HTML report is generated after test execution. You can open the generated HTML file to see a detailed view of the test results. The HTML report is usually located in the `test/reports.html` file, and you can open it with any web browser. - ## API Documentation diff --git a/test-report.html b/test-report.html index 7a3726a..b5832ac 100644 --- a/test-report.html +++ b/test-report.html @@ -257,4 +257,4 @@ font-size: 1rem; padding: 0 0.5rem; } -

Test Report

Started: 2024-10-16 12:18:33
Suites (10)
10 passed
0 failed
0 pending
Tests (46)
46 passed
0 failed
0 pending
CategoryController > createCategory
should create a category successfully
passed
0.031s
CategoryController > createCategory
should return a BadRequestError if name is missing
passed
0.008s
CategoryController > getCategories
should return a list of categories with pagination
passed
0.009s
CategoryController > getCategoryById
should return a category by ID
passed
0.008s
CategoryController > getCategoryById
should return a NotFoundError if category is not found
passed
0.009s
CategoryController > updateCategory
should update a category successfully
passed
0.009s
CategoryController > updateCategory
should return a BadRequestError if name is missing
passed
0.009s
CategoryController > deleteCategory
should delete a category successfully
passed
0.007s
CategoryController > deleteCategory
should return a NotFoundError if category is not found
passed
0.006s
ProductsRepo > createProduct
should create a product and return it
passed
0.016s
ProductsRepo > getProducts
should return products with pagination
passed
0.005s
ProductsRepo > getProductById
should return a product by ID
passed
0.007s
ProductsRepo > getProductById
should throw a NotFoundError if product ID does not exist
passed
0.036s
ProductsRepo > updateProduct
should update a product
passed
0.006s
ProductsRepo > deleteProduct
should delete a product successfully
passed
0.009s
ProductsRepo > deleteProduct
should throw a NotFoundError if product ID does not exist
passed
0.008s
UserController > register
should register a user successfully
passed
0.021s
UserController > register
should handle missing fields error
passed
0.008s
UserController > login
should login successfully and set access_token cookie
passed
0.013s
CategoryService
getCategoryById failure
passed
0.154s
ProductService > createProduct
should create a product and return it
passed
0.01s
ProductService > updateProduct
should update a product
passed
0.004s
ProductService > deleteProduct
should delete a product successfully
passed
0.004s
ProductService > deleteProduct
should throw a NotFoundError if product ID does not exist
passed
0.021s
CategoryService > createCategory
should create a category and return it
passed
0.01s
CategoryService > createCategory
should throw a ConflictError if category already exists
passed
0.023s
CategoryService > getCategories
should return categories with pagination
passed
0.008s
CategoryService > getCategoryById
should return a category by ID
passed
0.007s
CategoryService > getCategoryById
should throw a NotFoundError if category is not found
passed
0.008s
CategoryService > updateCategory
should update a category
passed
0.007s
CategoryService > updateCategory
should throw a NotFoundError if category ID does not exist
passed
0.006s
CategoryService > deleteCategory
should delete a category successfully
passed
0.006s
CategoryService > deleteCategory
should throw a NotFoundError if category ID does not exist
passed
0.007s
UserController > register
should handle missing fields error
passed
0.011s
UserController > login
should login successfully and set access_token cookie
passed
0.019s
UserController > login
should handle missing email or password
passed
0.008s
UserController > login
should handle service error
passed
0.012s
UserRepo > checkUser
should find a user by email
passed
0.012s
UserRepo > checkUser
should return null if no user found
passed
0.004s
UserRepo > register
should create a new user
passed
0.003s
CategoryRepo > createCategory
should create a category and return it
passed
0.008s
CategoryRepo > getCategoryById
should return a category by ID
passed
0.004s
CategoryRepo > updateCategory
should update a category
passed
0.004s
ProductController > createProduct
should handle service error
passed
0.014s
ProductController > updateProduct
should handle not found error
passed
0.002s
ProductController > deleteProduct
should handle not found error
passed
0.002s
\ No newline at end of file +

Test Report

Started: 2024-10-16 17:20:57
Suites (10)
10 passed
0 failed
0 pending
Tests (46)
46 passed
0 failed
0 pending
CategoryController > createCategory
should create a category successfully
passed
0.028s
CategoryController > createCategory
should return a BadRequestError if name is missing
passed
0.012s
CategoryController > getCategories
should return a list of categories with pagination
passed
0.01s
CategoryController > getCategoryById
should return a category by ID
passed
0.009s
CategoryController > getCategoryById
should return a NotFoundError if category is not found
passed
0.013s
CategoryController > updateCategory
should update a category successfully
passed
0.01s
CategoryController > updateCategory
should return a BadRequestError if name is missing
passed
0.009s
CategoryController > deleteCategory
should delete a category successfully
passed
0.008s
CategoryController > deleteCategory
should return a NotFoundError if category is not found
passed
0.006s
ProductsRepo > createProduct
should create a product and return it
passed
0.025s
ProductsRepo > getProducts
should return products with pagination
passed
0.005s
ProductsRepo > getProductById
should return a product by ID
passed
0.008s
ProductsRepo > getProductById
should throw a NotFoundError if product ID does not exist
passed
0.034s
ProductsRepo > updateProduct
should update a product
passed
0.005s
ProductsRepo > deleteProduct
should delete a product successfully
passed
0.006s
ProductsRepo > deleteProduct
should throw a NotFoundError if product ID does not exist
passed
0.01s
UserController > register
should register a user successfully
passed
0.026s
UserController > register
should handle missing fields error
passed
0.014s
UserController > login
should login successfully and set access_token cookie
passed
0.021s
CategoryService
getCategoryById failure
passed
0.191s
ProductService > createProduct
should create a product and return it
passed
0.012s
ProductService > updateProduct
should update a product
passed
0.004s
ProductService > deleteProduct
should delete a product successfully
passed
0.005s
ProductService > deleteProduct
should throw a NotFoundError if product ID does not exist
passed
0.024s
UserController > register
should handle missing fields error
passed
0.009s
UserController > login
should login successfully and set access_token cookie
passed
0.012s
UserController > login
should handle missing email or password
passed
0.006s
UserController > login
should handle service error
passed
0.009s
CategoryService > createCategory
should create a category and return it
passed
0.01s
CategoryService > createCategory
should throw a ConflictError if category already exists
passed
0.022s
CategoryService > getCategories
should return categories with pagination
passed
0.005s
CategoryService > getCategoryById
should return a category by ID
passed
0.005s
CategoryService > getCategoryById
should throw a NotFoundError if category is not found
passed
0.007s
CategoryService > updateCategory
should update a category
passed
0.012s
CategoryService > updateCategory
should throw a NotFoundError if category ID does not exist
passed
0.007s
CategoryService > deleteCategory
should delete a category successfully
passed
0.005s
CategoryService > deleteCategory
should throw a NotFoundError if category ID does not exist
passed
0.006s
UserRepo > checkUser
should find a user by email
passed
0.014s
UserRepo > checkUser
should return null if no user found
passed
0.006s
UserRepo > register
should create a new user
passed
0.005s
CategoryRepo > createCategory
should create a category and return it
passed
0.008s
CategoryRepo > getCategoryById
should return a category by ID
passed
0.004s
CategoryRepo > updateCategory
should update a category
passed
0.003s
ProductController > createProduct
should handle service error
passed
0.012s
ProductController > updateProduct
should handle not found error
passed
0.001s
ProductController > deleteProduct
should handle not found error
passed
0.002s
\ No newline at end of file