Skip to content

Commit 971cb80

Browse files
authored
Merge branch 'development' into unitTestingForAuth
2 parents 34da343 + 0ccf273 commit 971cb80

34 files changed

+1826
-817
lines changed

.github/workflows/pr-instructions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
echo ${{ steps.instruction.outputs.result }} > addingPrInstructions/artifact/artifact.txt
2929
3030
- name: Upload Artifacts
31-
uses: actions/upload-artifact@v3
31+
uses: actions/upload-artifact@v4
3232
with:
3333
name: adding-pr-instructions-artifact
3434
path: addingPrInstructions/artifact/

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
# vscode dirs
2+
.devcontainer
3+
.vscode
14

5+
# project dirs and files
26
node_modules/
37
npm-debug.log
48
.DS_Store

CONTRIBUTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,22 @@ Note: Understanding how git remotes work will make collaborating much easier. Yo
106106

107107
### **2.3 Get up and running**
108108

109+
1. Install [NVM (Node Version Manager)](https://github.com/nvm-sh/nvm). NVM allows you to easily manage and switch between multiple versions of Node.
110+
111+
- Verify the installation: `nvm --version`
112+
- Once NVM is verified, run the following commands from the root of the project:
113+
114+
```
115+
# Install the project's Node version (specified in the .nvmrc file)
116+
nvm install
117+
118+
# Instruct NVM to use the Node version defined in the .nvmrc file
119+
nvm use
120+
121+
```
122+
123+
> NOTE: If the major version of Node does not match the version specified in the .nvmrc file, you may need to be explicit with the version and use: `nvm install <version>` and `nvm use <version>`
124+
109125
1. Have [Node](https://nodejs.org/en/download/) and NPM installed locally:
110126

111127
- Verify with `node -v` and `npm -v` respectively.

VRMS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 7042af0f43f0b034977c7f64c613e9d8b7199edb

backend/controllers/project.controller.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,26 @@ ProjectController.bulkUpdateManagedByUsers = async function (req, res) {
130130
}
131131
};
132132

133+
// Update onboard/offboard visibility for a project
134+
ProjectController.updateOnboardOffboardVisibility = async function (req, res) {
135+
const { ProjectId } = req.params;
136+
const { onboardOffboardVisible } = req.body;
137+
138+
try {
139+
const project = await Project.findByIdAndUpdate(
140+
ProjectId,
141+
{ onboardOffboardVisible },
142+
{ new: true }
143+
);
144+
145+
if (!project) {
146+
return res.status(404).send({ message: 'Project not found' });
147+
}
148+
149+
return res.status(200).send(project);
150+
} catch (err) {
151+
return res.status(400).send({ message: 'Error updating visibility', error: err.message });
152+
}
153+
};
154+
133155
module.exports = ProjectController;

backend/models/project.model.js

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,49 +16,51 @@ Idea for the future: programmingLanguages, numberGithubContributions (pull these
1616
*/
1717

1818
const projectSchema = mongoose.Schema({
19-
name: { type: String, trim: true },
20-
description: { type: String, trim: true },
21-
githubIdentifier: { type: String, trim: true },
22-
projectStatus: { type: String }, // Active, Completed, or Paused
23-
location: { type: String, trim: true }, // DTLA, Westside, South LA, or Remote (hacknight)
24-
//teamMembers: { type: String }, // commented since we should be able to get this from Project Team Members table
25-
createdDate: { type: Date, default: Date.now }, // date/time project was created
26-
completedDate: { type: Date }, // only if Status = Completed, date/time completed
27-
githubUrl: { type: String, trim: true }, // link to main repo
28-
slackUrl: { type: String, trim: true }, // link to Slack channel
29-
googleDriveUrl: { type: String, trim: true },
30-
googleDriveId: { type: String },
31-
hflaWebsiteUrl: { type: String, trim: true },
32-
videoConferenceLink: { type: String },
33-
lookingDescription: { type: String }, // narrative on what the project is looking for
34-
recruitingCategories: [{ type: String }], // same as global Skills picklist
35-
partners: [{ type: String }], // any third-party partners on the project, e.g. City of LA
36-
managedByUsers: [{ type: String }] // Which users may manage this project.
19+
name: { type: String, trim: true },
20+
description: { type: String, trim: true },
21+
githubIdentifier: { type: String, trim: true },
22+
projectStatus: { type: String }, // Active, Completed, or Paused
23+
location: { type: String, trim: true }, // DTLA, Westside, South LA, or Remote (hacknight)
24+
//teamMembers: { type: String }, // commented since we should be able to get this from Project Team Members table
25+
createdDate: { type: Date, default: Date.now }, // date/time project was created
26+
completedDate: { type: Date }, // only if Status = Completed, date/time completed
27+
githubUrl: { type: String, trim: true }, // link to main repo
28+
slackUrl: { type: String, trim: true }, // link to Slack channel
29+
googleDriveUrl: { type: String, trim: true },
30+
googleDriveId: { type: String },
31+
hflaWebsiteUrl: { type: String, trim: true },
32+
videoConferenceLink: { type: String },
33+
lookingDescription: { type: String }, // narrative on what the project is looking for
34+
recruitingCategories: [{ type: String }], // same as global Skills picklist
35+
partners: [{ type: String }], // any third-party partners on the project, e.g. City of LA
36+
managedByUsers: [{ type: String }], // Which users may manage this project.
37+
onboardOffboardVisible: { type: Boolean, default: true }, // Whether onboarding/offboarding forms are visible on the project page
3738
});
3839

39-
projectSchema.methods.serialize = function() {
40-
return {
41-
id: this._id,
42-
name: this.name,
43-
description: this.description,
44-
githubIdentifier: this.githubIdentifier,
45-
// owner: this.owner,
46-
projectStatus: this.projectStatus,
47-
location: this.location,
48-
//teamMembers: this.teamMembers,
49-
createdDate: this.createdDate,
50-
completedDate: this.completedDate,
51-
githubUrl: this.githubUrl,
52-
slackUrl: this.slackUrl,
53-
googleDriveUrl: this.googleDriveUrl,
54-
googleDriveId: this.googleDriveId,
55-
hflaWebsiteUrl: this.hflaWebsiteUrl,
56-
videoConferenceLink: this.videoConferenceLink,
57-
lookingDescription: this.lookingDescription,
58-
recruitingCategories: this.recruitingCategories,
59-
partners: this.partners,
60-
managedByUsers: this.managedByUsers
61-
};
40+
projectSchema.methods.serialize = function () {
41+
return {
42+
id: this._id,
43+
name: this.name,
44+
description: this.description,
45+
githubIdentifier: this.githubIdentifier,
46+
// owner: this.owner,
47+
projectStatus: this.projectStatus,
48+
location: this.location,
49+
//teamMembers: this.teamMembers,
50+
createdDate: this.createdDate,
51+
completedDate: this.completedDate,
52+
githubUrl: this.githubUrl,
53+
slackUrl: this.slackUrl,
54+
googleDriveUrl: this.googleDriveUrl,
55+
googleDriveId: this.googleDriveId,
56+
hflaWebsiteUrl: this.hflaWebsiteUrl,
57+
videoConferenceLink: this.videoConferenceLink,
58+
lookingDescription: this.lookingDescription,
59+
recruitingCategories: this.recruitingCategories,
60+
partners: this.partners,
61+
managedByUsers: this.managedByUsers,
62+
onboardOffboardVisible: this.onboardOffboardVisible,
63+
};
6264
};
6365

6466
const Project = mongoose.model('Project', projectSchema);

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"morgan": "^1.10.0",
5757
"node-cron": "^2.0.3",
5858
"node-fetch": "^2.6.7",
59-
"nodemailer": "^6.6.1"
59+
"nodemailer": "^7.0.11"
6060
},
6161
"directories": {
6262
"test": "test"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Mock the healthCheck controller
2+
jest.mock('../controllers/healthCheck.controller.js');
3+
4+
// Import the healthCheck router and controller
5+
const healthCheck = require('./healthCheck.router.js');
6+
const { HealthCheckController } = require('../controllers');
7+
8+
// Create a mock test server
9+
const express = require('express');
10+
const supertest = require('supertest');
11+
const testapp = express();
12+
testapp.use('/api/healthcheck', healthCheck);
13+
14+
// Set up mock request for the controller
15+
const request = supertest(testapp);
16+
17+
describe('Unit testing for Health Check Router', () => {
18+
// Clear all mocks after each test
19+
afterEach(() => {
20+
jest.clearAllMocks();
21+
});
22+
23+
describe('READ', () => {
24+
it('should return status code 200 and message "I\'m Alive" with GET /api/healthcheck', async (done) => {
25+
// Mock the controller method
26+
HealthCheckController.isAlive.mockImplementationOnce((req, res) => {
27+
res.status(200).send("I'm Alive!");
28+
});
29+
30+
// Call GET API endpoint
31+
const response = await request.get('/api/healthcheck');
32+
33+
// Test
34+
expect(HealthCheckController.isAlive).toHaveBeenCalled();
35+
expect(response.status).toBe(200);
36+
expect(response.text).toBe("I'm Alive!");
37+
38+
// Marks completion of the test
39+
done();
40+
});
41+
});
42+
});

backend/routers/projects.router.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ router.patch('/:ProjectId', AuthUtil.verifyCookie, ProjectController.updateManag
2222
// Bulk update for editing project members
2323
router.post('/bulk-updates', AuthUtil.verifyCookie, ProjectController.bulkUpdateManagedByUsers);
2424

25+
// Update onboard/offboard visibility for a project
26+
router.patch('/:ProjectId/visibility', AuthUtil.verifyCookie, ProjectController.updateOnboardOffboardVisibility);
27+
2528
module.exports = router;

backend/routers/users.router.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ describe('Unit Tests for userRouter', () => {
130130
done();
131131
});
132132

133-
it('should get a specific User by UserId with GET to /api/users/:UserId through UserController', async (done) => {
133+
// @TODO: Fix failing test, require investigation. Please referece issue 2036
134+
it.skip('should get a specific User by UserId with GET to /api/users/:UserId through UserController', async (done) => {
134135
//Mock the UserController function that this route calls with expected results
135136
UserController.user_by_id.mockImplementationOnce((req, res) => {
136137
return res.status(200).send(mockUser);

0 commit comments

Comments
 (0)