Skip to content

Commit

Permalink
Merge branch 'development' into Carlos-Anniversary-Celebrated
Browse files Browse the repository at this point in the history
  • Loading branch information
cgomezhub authored Dec 4, 2024
2 parents 7ee2217 + 9f64271 commit fdc8fe3
Show file tree
Hide file tree
Showing 84 changed files with 6,201 additions and 653 deletions.
Binary file modified .DS_Store
Binary file not shown.
608 changes: 322 additions & 286 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"babel-plugin-module-resolver": "^5.0.0",
"bcryptjs": "^2.4.3",
"body-parser": "^1.18.3",
"cheerio": "^1.0.0-rc.12",
"cors": "^2.8.4",
"cron": "^1.8.2",
"dotenv": "^5.0.1",
Expand Down
23 changes: 23 additions & 0 deletions requirements/emailController/addNonHgnEmailSubscription.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Add Non-HGN Email Subscription Function

## Negative Cases

1.**Returns error 400 if `email` field is missing from the request**
- Ensures that the function checks for the presence of the `email` field in the request body and responds with a `400` status code if it's missing.

2.**Returns error 400 if the provided `email` already exists in the subscription list**
- This case checks that the function responds with a `400` status code and a message indicating that the email is already subscribed.

3.**Returns error 500 if there is an internal error while checking the subscription list**
- Covers scenarios where there's an issue querying the `EmailSubscriptionList` collection for the provided email (e.g., database connection issues).

4.**Returns error 500 if there is an error sending the confirmation email**
- This case handles any issues that occur while calling the `emailSender` function, such as network errors or service unavailability.

## Positive Cases

1.**Returns status 200 when a new email is successfully subscribed**
- Ensures that the function successfully creates a JWT token, constructs the email, and sends the subscription confirmation email to the user.

2.**Successfully sends a confirmation email containing the correct link**
- Verifies that the generated JWT token is correctly included in the confirmation link sent to the user in the email body.
18 changes: 18 additions & 0 deletions requirements/emailController/confirmNonHgnEmailSubscription.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Confirm Non-HGN Email Subscription Function Tests

## Negative Cases
1.**Returns error 400 if `token` field is missing from the request**
- (Test: `should return 400 if token is not provided`)

2.**Returns error 401 if the provided `token` is invalid or expired**
- (Test: `should return 401 if token is invalid`)

3.**Returns error 400 if the decoded `token` does not contain a valid `email` field**
- (Test: `should return 400 if email is missing from payload`)

4.**Returns error 500 if there is an internal error while saving the new email subscription**

## Positive Cases
1.**Returns status 200 when a new email is successfully subscribed**

2.**Returns status 200 if the email is already subscribed (duplicate email)**
10 changes: 10 additions & 0 deletions requirements/emailController/removeNonHgnEmailSubscription.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Remove Non-HGN Email Subscription Function Tests

## Negative Cases
1.**Returns error 400 if `email` field is missing from the request**
- (Test: `should return 400 if email is missing`)

2.**Returns error 500 if there is an internal error while deleting the email subscription**

## Positive Cases
1.**Returns status 200 when an email is successfully unsubscribed**
10 changes: 10 additions & 0 deletions requirements/emailController/sendEmail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Send Email Function

## Negative Cases

1.**Returns error 400 if `to`, `subject`, or `html` fields are missing from the request**
2.**Returns error 500 if there is an internal error while sending the email**

## Positive Cases

1.**Returns status 200 when email is successfully sent with `to`, `subject`, and `html` fields provided**
26 changes: 26 additions & 0 deletions requirements/emailController/sendEmailToAll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Send Email to All Function

## Negative Cases

1.**Returns error 400 if `subject` or `html` fields are missing from the request**
- The request should be rejected if either the `subject` or `html` content is not provided in the request body.

2.**Returns error 500 if there is an internal error while fetching users**
- This case covers scenarios where there's an error fetching users from the `userProfile` collection (e.g., database connection issues).

3.**Returns error 500 if there is an internal error while fetching the subscription list**
- This case covers scenarios where there's an error fetching emails from the `EmailSubcriptionList` collection.

4.**Returns error 500 if there is an error sending emails**
- This case handles any issues that occur while calling the `emailSender` function, such as network errors or service unavailability.

## Positive Cases

1.**Returns status 200 when emails are successfully sent to all active users**
- Ensures that the function sends emails correctly to all users meeting the criteria (`isActive` and `EmailSubcriptionList`).

2.**Returns status 200 when emails are successfully sent to all users in the subscription list**
- Verifies that the function sends emails to all users in the `EmailSubcriptionList`, including the unsubscribe link in the email body.

3.**Combines user and subscription list emails successfully**
- Ensures that the function correctly sends emails to both active users and the subscription list without issues.
20 changes: 20 additions & 0 deletions requirements/emailController/updateEmailSubscription.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Update Email Subscriptions Function

## Negative Cases

1.**Returns error 400 if `emailSubscriptions` field is missing from the request**
- This ensures that the function checks for the presence of the `emailSubscriptions` field in the request body and responds with a `400` status code if it's missing.

2.**Returns error 400 if `email` field is missing from the requestor object**
- Ensures that the function requires an `email` field within the `requestor` object in the request body and returns `400` if it's absent.

3.**Returns error 404 if the user with the provided `email` is not found**
- This checks that the function correctly handles cases where no user exists with the given `email` and responds with a `404` status code.

4.**Returns error 500 if there is an internal error while updating the user profile**
- Covers scenarios where there's a database error while updating the user's email subscriptions.

## Positive Cases

1.**Returns status 200 and the updated user when email subscriptions are successfully updated**
- Ensures that the function updates the `emailSubscriptions` field for the user and returns the updated user document along with a `200` status code.
16 changes: 16 additions & 0 deletions requirements/informationController/addInformation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Check mark: ✅
Cross Mark: ❌

# Add Information

> ## Positive case
1. ✅ Returns 201 if adding new information successfullyn and no cache.
2. ✅ Returns if adding new information successfully and hascache.

> ## Negative case
1. ✅ Returns error 500 if if there are no information in the database and any error occurs when finding the infoName.
2. ✅ Returns error 400 if if there are duplicate infoName in the database.
3. ✅ Returns error 400 if if there are issues when saving new informations.
4. ✅ Returns error 400 if if there are errors when saving the new information.

> ## Edge case
13 changes: 13 additions & 0 deletions requirements/informationController/deleteInformation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Check mark: ✅
Cross Mark: ❌

# Delete Information

> ## Positive case
1. ✅ Returns 200 if deleting informations successfull and no cache.
2. ✅ Returns if deleting informations successfully and has cache.

> ## Negative case
1. ✅ Returns error 400 if if there is any error when finding the information by information id.

> ## Edge case
13 changes: 13 additions & 0 deletions requirements/informationController/getInformation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Check mark: ✅
Cross Mark: ❌

# Get Information

> ## Positive case
1. ✅ Returns 200 if the informations key exists in NodeCache.
2. ✅ Returns 200 if there are information in the database.

> ## Negative case
1. ✅ Returns error 404 if if there are no information in the database and any error occurs when finding the information.

> ## Edge case
13 changes: 13 additions & 0 deletions requirements/informationController/updateInformation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Check mark: ✅
Cross Mark: ❌

# Update Information

> ## Positive case
1. ✅ Returns 200 if updating informations successfully when no cache.
2. ✅ Returns if updating informations successfully when hascache.

> ## Negative case
1. ✅ Returns error 400 if if there is any error when finding the information by information id.

> ## Edge case
14 changes: 14 additions & 0 deletions requirements/popUpEditorController/createPopPopupEditor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Check mark: ✅
Cross Mark: ❌

# createPopPopupEditor Function

> ### Positive case
> 1. ✅ Should return 201 and the new pop-up editor on success
> ### Negative case
> 1. ✅ Should return 403 if user does not have permission to create a pop-up editor
> 2. ✅ Should return 400 if the request body is missing required fields
> 3. ✅ Should return 500 if there is an error saving the new pop-up editor to the database
10 changes: 10 additions & 0 deletions requirements/popUpEditorController/getAllPopupEditors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Check mark: ✅
Cross Mark: ❌

# getAllPopupEditors Function

> ## Positive case
> 1. ✅ Should return 200 and all pop-up editors on success
> ## Negative case
> 1. ✅ Should return 404 if there is an error retrieving the pop-up editors from the database
10 changes: 10 additions & 0 deletions requirements/popUpEditorController/getPopupEditorById.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Check mark: ✅
Cross Mark: ❌

# getPopupEditorById Function

> ## Positive case
> 1. ✅ Should return 200 and the pop-up editor on success
> ## Negative case
> 1. ✅ Should return 404 if the pop-up editor is not found
11 changes: 11 additions & 0 deletions requirements/popUpEditorController/updatePopupEditor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Check mark: ✅
Cross Mark: ❌

# updatePopupEditor Function

> ## Positive case
> 1. ✅ Should return 200 and the updated pop-up editor on success

> ## Negative case
> 1. ✅ Should return 404 if the pop-up editor is not found
16 changes: 16 additions & 0 deletions requirements/reasonSchedulingController/deleteReason.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Check mark: ✅
Cross Mark: ❌

# deleteReason

> ## Positive case
1. ✅ Receives a POST request in the **/api/reason/:userId/** route.
2. ✅ Return 200 if delete reason successfully.

> ## Negative case
1. ✅ Returns 403 when no permission to delete.
2. ✅ Returns 404 when error in finding user Id.
3. ✅ Returns 404 when error in finding reason.
4. ✅ Returns 500 when error in deleting.

> ## Edge case
14 changes: 14 additions & 0 deletions requirements/reasonSchedulingController/getAllReasons.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Check mark: ✅
Cross Mark: ❌

# getAllReasons

> ## Positive case
1. ✅ Receives a GET request in the **/api/reason/:userId** route.
2. ✅ Return 200 if get schedule reason successfully.

> ## Negative case
1. ✅ Returns 404 when error in finding user by Id.
2. ✅ Returns 400 when any error in fetching the user

> ## Edge case
15 changes: 15 additions & 0 deletions requirements/reasonSchedulingController/getSingleReason.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Check mark: ✅
Cross Mark: ❌

# getSingleReason

> ## Positive case
1. ✅ Receives a GET request in the **/api/reason/single/:userId** route.
2. ✅ Return 200 if not found schedule reason and return empty object successfully.
3. ✅ Return 200 if found schedule reason and return reason successfully.

> ## Negative case
1. ✅ Returns 404 when any error in find user by Id
2. ✅ Returns 400 when any error in fetching the user

> ## Edge case
16 changes: 16 additions & 0 deletions requirements/reasonSchedulingController/patchReason.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Check mark: ✅
Cross Mark: ❌

# patchReason

> ## Positive case
1. ✅ Receives a POST request in the **/api/breason/** route.
2. ✅ Return 200 if updated schedule reason and send blue sqaure email successfully.

> ## Negative case
1. ✅ Returns 400 for not providing reason.
2. ✅ Returns 404 when error in finding user Id.
3. ✅ Returns 404 when not finding provided reason.
4. ✅ Returns 400 when any error in saving.

> ## Edge case
18 changes: 18 additions & 0 deletions requirements/reasonSchedulingController/postReason.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Check mark: ✅
Cross Mark: ❌

# postReason

> ## Positive case
1. ✅ Receives a POST request in the **/api/reason/** route.
2. ✅ Return 200 if s dchedule reason and send blue sqaure email successfully.

> ## Negative case
1. ✅ Returns 400 for warning to choose Sunday.
2. ✅ Returns 400 for warning to choose a funture date.
3. ✅ Returns 400 for not providing reason.
4. ✅ Returns 404 when error in finding user Id.
5. ✅ Returns 403 when duplicate reason to the date.
6. ✅ Returns 400 when any error in saving.

> ## Edge case
15 changes: 15 additions & 0 deletions requirements/taskController/deleteTask.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Check mark: ✅
Cross Mark: ❌

# deleteTask Function

> ## Positive case
1. ✅ Returns status 200 on successful deletion.

> ## Negative case
1. ✅ Returns status 400 if either no record is found in Task collection or some error occurs while saving the tasks.

2. ✅ Returns status 403 if the request.body.requestor does not have `deleteTask` permission.


> ## Edge case
15 changes: 15 additions & 0 deletions requirements/taskController/deleteTaskByWBS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Check mark: ✅
Cross Mark: ❌

# deleteTaskByWBS Function

> ## Positive case
1. ✅ Returns status 200 on successful deletion.

> ## Negative case
1. ✅ Returns status 400 if either no record is found in Task collection or some error occurs while saving the tasks.

2. ✅ Returns status 403 if the request.body.requestor does not have `deleteTask` permission.


> ## Edge case
11 changes: 11 additions & 0 deletions requirements/taskController/fixTasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Check mark: ✅
Cross Mark: ❌

# updateAllParents Function

> ## Positive case
1. ✅ Returns status 200 on without performing an operation.

> ## Negative case
> ## Edge case
14 changes: 14 additions & 0 deletions requirements/taskController/getTaskById.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Check mark: ✅
Cross Mark: ❌

# getTaskById Function

> ## Positive case
1. ✅ Returns status 200 on successfully getting a taskById.

> ## Negative case
1. ✅ Returns status 400 if either req.params.id is missing or is `undefined` or if no task is found in Task collection.

2. ✅ Returns status 500 if some error occurs.

> ## Edge case
12 changes: 12 additions & 0 deletions requirements/taskController/getTasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Check mark: ✅
Cross Mark: ❌

# getTasks Function

> ## Positive case
1. ✅ Returns status 200 on successfully querying the Task collection.

> ## Negative case
1. ✅ Returns status 404 if any error occurs while querying the Task collection.

> ## Edge case
Loading

0 comments on commit fdc8fe3

Please sign in to comment.