From e2cb492d26537ee8e527ff1043e272cbf921e24e Mon Sep 17 00:00:00 2001 From: awlfccamp Date: Sun, 10 Aug 2025 18:13:57 -0500 Subject: [PATCH 1/3] add script to out put list of files containing linting errors --- lint-files.count.txt | 1 + lint-report.json | 10402 +++++++++++++++++++++++++++++++++++ package.json | 5 +- scripts/list-lint-files.js | 46 + 4 files changed, 10453 insertions(+), 1 deletion(-) create mode 100644 lint-files.count.txt create mode 100644 lint-report.json create mode 100644 scripts/list-lint-files.js diff --git a/lint-files.count.txt b/lint-files.count.txt new file mode 100644 index 000000000..ca4cd6a80 --- /dev/null +++ b/lint-files.count.txt @@ -0,0 +1 @@ +After running the lint found total number of the files has linting problems: 185 \ No newline at end of file diff --git a/lint-report.json b/lint-report.json new file mode 100644 index 000000000..9562f378b --- /dev/null +++ b/lint-report.json @@ -0,0 +1,10402 @@ +[ + { + "filePath": "/backend/app.js", + "messages": [ + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'runOpenCheckinWorker' is assigned a value but never used.", + "line": 55, + "column": 7, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 55, + "endColumn": 27 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'runCloseCheckinWorker' is assigned a value but never used.", + "line": 56, + "column": 7, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 56, + "endColumn": 28 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'runCreateRecurringEventsWorker' is assigned a value but never used.", + "line": 59, + "column": 7, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 59, + "endColumn": 37 + } + ], + "suppressedMessages": [], + "errorCount": 3, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "// app.js - Entry point for our application\n\n// Load in all of our node modules. Their uses are explained below as they are called.\nconst express = require('express');\nconst cron = require('node-cron');\nconst fetch = require('node-fetch');\nconst morgan = require('morgan');\nconst cookieParser = require('cookie-parser');\n\nconst customRequestHeaderName = 'x-customrequired-header';\nconst dontCheckCustomRequestHeaderApis = ['GET::/api/recurringevents', 'GET::/api/healthcheck'];\n\n// Import environment variables\nconst dotenv = require('dotenv');\nconst dotenvExpand = require('dotenv-expand');\n\nconst myEnv = dotenv.config();\ndotenvExpand(myEnv);\n\n// Verify environment variables\nrequire('assert-env')([\n 'CUSTOM_REQUEST_HEADER',\n 'SLACK_OAUTH_TOKEN',\n 'SLACK_BOT_TOKEN',\n 'SLACK_TEAM_ID',\n 'SLACK_CHANNEL_ID',\n 'SLACK_CLIENT_ID',\n 'SLACK_CLIENT_SECRET',\n 'SLACK_SIGNING_SECRET',\n 'BACKEND_PORT',\n 'REACT_APP_PROXY',\n 'GMAIL_CLIENT_ID',\n 'GMAIL_SECRET_ID',\n 'GMAIL_REFRESH_TOKEN',\n 'GMAIL_EMAIL',\n 'MAILHOG_PORT',\n 'MAILHOG_USER',\n 'MAILHOG_PASSWORD',\n]);\n\n// Create a new application using the Express framework\nconst app = express();\n\n// Required to view Request Body (req.body) in JSON\napp.use(express.json());\napp.use(express.urlencoded({ extended: true }));\n\n// Used to save JWT token from MagicLink\napp.use(cookieParser());\n\n// HTTP Request Logger\napp.use(morgan('dev'));\n\n// WORKERS\nconst runOpenCheckinWorker = require('./workers/openCheckins')(cron, fetch);\nconst runCloseCheckinWorker = require('./workers/closeCheckins')(cron, fetch);\n\nconst { createRecurringEvents } = require('./workers/createRecurringEvents');\nconst runCreateRecurringEventsWorker = createRecurringEvents(cron, fetch);\n\n// const runSlackBot = require(\"./workers/slackbot\")(fetch);\n\n// MIDDLEWARE\nconst errorhandler = require('./middleware/errorhandler.middleware');\n\n// ROUTES\nconst eventsRouter = require('./routers/events.router');\nconst checkInsRouter = require('./routers/checkIns.router');\nconst usersRouter = require('./routers/users.router');\nconst questionsRouter = require('./routers/questions.router');\nconst checkUserRouter = require('./routers/checkUser.router');\nconst grantPermissionRouter = require('./routers/grantpermission.router');\nconst projectsRouter = require('./routers/projects.router');\nconst recurringEventsRouter = require('./routers/recurringEvents.router');\nconst projectTeamMembersRouter = require('./routers/projectTeamMembers.router');\n//const slackRouter = require(\"./routers/slack.router\");\nconst authRouter = require('./routers/auth.router');\nconst healthCheckRouter = require('./routers/healthCheck.router');\n\n// Check that clients to the API are sending the custom request header on all methods\n// except for ones described in the dontCheckCustomRequestHeaderApis array.\napp.use(function customHeaderCheck(req, res, next) {\n let pathToCheck = req.path;\n\n if (pathToCheck.endsWith('/')) {\n pathToCheck = pathToCheck.substr(0, pathToCheck.length - 1);\n }\n\n const key = `${req.method}::${pathToCheck}`;\n\n if (dontCheckCustomRequestHeaderApis.includes(key)) {\n next();\n } else {\n const { headers } = req;\n const expectedHeader = process.env.CUSTOM_REQUEST_HEADER;\n\n if (headers[customRequestHeaderName] !== expectedHeader) {\n console.log(\"REQUEST SHOULD CONTAIN CUSTOM HEADER BUT IT ISN'T FOUND\");\n res.sendStatus(401);\n } else {\n next();\n }\n }\n});\n\napp.use('/api/auth', authRouter);\napp.use('/api/events', eventsRouter);\napp.use('/api/checkins', checkInsRouter);\napp.use('/api/users', usersRouter);\napp.use('/api/questions', questionsRouter);\napp.use('/api/checkuser', checkUserRouter);\napp.use('/api/grantpermission', grantPermissionRouter);\napp.use('/api/projects', projectsRouter);\napp.use('/api/recurringevents', recurringEventsRouter);\napp.use('/api/projectteammembers', projectTeamMembersRouter);\n//app.use('/api/slack', slackRouter);\napp.use('/api/healthcheck', healthCheckRouter);\n\n// 404 for all non-defined endpoints.\napp.get('*', (req, res, next) => {\n const error = new Error('Not Found');\n error.status = 404;\n next(error);\n});\n\napp.use(errorhandler);\n\nmodule.exports = app;\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/config/auth.config.js", + "messages": [ + { + "ruleId": null, + "message": "Unused eslint-disable directive (no problems were reported).", + "line": 1, + "column": 1, + "severity": 1, + "nodeType": null, + "fix": { + "range": [0, 19], + "text": " " + } + } + ], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 1, + "fixableErrorCount": 0, + "fixableWarningCount": 1, + "source": "/*eslint-disable */\nmodule.exports = {\n SECRET:\n 'c0d7d0716e4cecffe9dcc77ff90476d98f5aace08ea40f5516bd982b06401021191f0f24cd6759f7d8ca41b64f68d0b3ad19417453bddfd1dbe8fcb197245079',\n CUSTOM_REQUEST_HEADER: process.env.CUSTOM_REQUEST_HEADER,\n TOKEN_EXPIRATION_SEC: 900,\n};\n/* eslint-enable */", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/config/auth.config.test.js", + "messages": [ + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 1, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 1, + "endColumn": 5 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 3, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 3, + "endColumn": 9 + } + ], + "suppressedMessages": [], + "errorCount": 2, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "test.skip('Environment variables are working as expected', () => {\n const backendUrl = process.env.REACT_APP_PROXY;\n expect(backendUrl).toBe(`http://localhost:${process.env.BACKEND_PORT}`);\n});\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/config/database.config.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/config/index.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/controllers/email.controller.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/controllers/email.controller.test.js", + "messages": [ + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 3, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 3, + "endColumn": 5 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 4, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 4, + "endColumn": 9 + } + ], + "suppressedMessages": [], + "errorCount": 2, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "const EmailController = require('./email.controller');\n\ntest('Can import the email controller', async () => {\n expect(EmailController).not.toBeUndefined();\n});\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/controllers/event.controller.js", + "messages": [ + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'err' is defined but never used.", + "line": 11, + "column": 12, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 11, + "endColumn": 15 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'err' is defined but never used.", + "line": 22, + "column": 12, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 22, + "endColumn": 15 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'err' is defined but never used.", + "line": 33, + "column": 12, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 33, + "endColumn": 15 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'err' is defined but never used.", + "line": 44, + "column": 12, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 44, + "endColumn": 15 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'err' is defined but never used.", + "line": 55, + "column": 12, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 55, + "endColumn": 15 + } + ], + "suppressedMessages": [], + "errorCount": 5, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "const { Event } = require('../models');\n\nconst EventController = {};\n\nEventController.event_list = async function (req, res) {\n const { query } = req;\n\n try {\n const events = await Event.find(query).populate('project');\n return res.status(200).send(events);\n } catch (err) {\n return res.sendStatus(400);\n }\n};\n\nEventController.event_by_id = async function (req, res) {\n const { EventId } = req.params;\n\n try {\n const events = await Event.findById(EventId).populate('project');\n return res.status(200).send(events);\n } catch (err) {\n return res.sendStatus(400);\n }\n};\n\nEventController.create = async function (req, res) {\n const { body } = req;\n\n try {\n const event = await Event.create(body);\n return res.status(201).send(event);\n } catch (err) {\n return res.sendStatus(400);\n }\n};\n\nEventController.destroy = async function (req, res) {\n const { EventId } = req.params;\n\n try {\n const event = await Event.findByIdAndDelete(EventId);\n return res.status(200).send(event);\n } catch (err) {\n return res.sendStatus(400);\n }\n};\n\nEventController.update = async function (req, res) {\n const { EventId } = req.params;\n\n try {\n const event = await Event.findByIdAndUpdate(EventId, req.body);\n return res.status(200).send(event);\n } catch (err) {\n return res.sendStatus(400);\n }\n};\n\nmodule.exports = EventController;\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/controllers/event.controller.test.js", + "messages": [ + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 3, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 3, + "endColumn": 5 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 4, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 4, + "endColumn": 9 + } + ], + "suppressedMessages": [], + "errorCount": 2, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "const EventController = require('./event.controller');\n\ntest('Can import the email controller', async () => {\n expect(EventController).not.toBeUndefined();\n});\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/controllers/healthCheck.controller.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/controllers/index.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/controllers/project.controller.js", + "messages": [ + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'err' is defined but never used.", + "line": 11, + "column": 12, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 11, + "endColumn": 15 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'e' is defined but never used.", + "line": 21, + "column": 12, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 21, + "endColumn": 13 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'err' is defined but never used.", + "line": 32, + "column": 12, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 32, + "endColumn": 15 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'err' is defined but never used.", + "line": 43, + "column": 12, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 43, + "endColumn": 15 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'err' is defined but never used.", + "line": 53, + "column": 12, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 53, + "endColumn": 15 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'err' is defined but never used.", + "line": 64, + "column": 12, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 64, + "endColumn": 15 + } + ], + "suppressedMessages": [], + "errorCount": 6, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "const { Project } = require('../models');\n\nconst ProjectController = {};\n\nProjectController.project_list = async function (req, res) {\n const { query } = req;\n\n try {\n const projects = await Project.find(query);\n return res.status(200).send(projects);\n } catch (err) {\n return res.sendStatus(400);\n }\n};\n\nProjectController.pm_filtered_projects = async function (req, res) {\n try {\n const projectList = await Project.find({});\n const projects = projectList.filter((proj) => req.body.includes(proj._id.toString()));\n return res.status(200).send(projects);\n } catch (e) {\n return res.sendStatus(400);\n }\n};\n\nProjectController.create = async function (req, res) {\n const { body } = req;\n\n try {\n const newProject = await Project.create(body);\n return res.status(201).send(newProject);\n } catch (err) {\n return res.sendStatus(400);\n }\n};\n\nProjectController.project_by_id = async function (req, res) {\n const { ProjectId } = req.params;\n\n try {\n const project = await Project.findById(ProjectId);\n return res.status(200).send(project);\n } catch (err) {\n return res.sendStatus(400);\n }\n};\n\nProjectController.update = async function (req, res) {\n const { ProjectId } = req.params;\n try {\n const project = await Project.findOneAndUpdate({ _id: ProjectId }, req.body, { new: true });\n return res.status(200).send(project);\n } catch (err) {\n return res.sendStatus(400);\n }\n};\n\nProjectController.destroy = async function (req, res) {\n const { ProjectId } = req.params;\n\n try {\n const project = await Project.findByIdAndDelete(ProjectId);\n return res.status(200).send(project);\n } catch (err) {\n return res.sendStatus(400);\n }\n};\n\nmodule.exports = ProjectController;\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/controllers/project.controller.test.js", + "messages": [ + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 3, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 3, + "endColumn": 5 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 4, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 4, + "endColumn": 9 + } + ], + "suppressedMessages": [], + "errorCount": 2, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "const ProjectController = require('./project.controller');\n\ntest('Can import the project controller', async () => {\n expect(ProjectController).not.toBeUndefined();\n});\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/controllers/recurringEvent.controller.js", + "messages": [ + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'err' is defined but never used.", + "line": 18, + "column": 12, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 18, + "endColumn": 15 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'err' is defined but never used.", + "line": 39, + "column": 12, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 39, + "endColumn": 15 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'err' is defined but never used.", + "line": 52, + "column": 11, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 52, + "endColumn": 14 + } + ], + "suppressedMessages": [], + "errorCount": 3, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "const { RecurringEvent } = require('../models');\nconst expectedHeader = process.env.CUSTOM_REQUEST_HEADER;\n\nconst RecurringEventController = {};\n\n\n// // Add User with POST\nRecurringEventController.create = async function (req, res) {\n const { headers } = req;\n\n if (headers['x-customrequired-header'] !== expectedHeader) {\n return res.sendStatus(403);\n }\n\n try {\n const rEvent = await RecurringEvent.create(req.body);\n return res.status(200).send(rEvent);\n } catch (err) {\n return res.sendStatus(400);\n }\n};\n\n// Update Recurring Event using PATCH\nRecurringEventController.update = async function (req, res) {\n\n\tconst { headers } = req;\n\tconst { RecurringEventId } = req.params;\n\n\tif (headers['x-customrequired-header'] !== expectedHeader) {\n return res.sendStatus(403);\n }\n\n\tconst filter = {_id: RecurringEventId};\n\tconst update = req.body;\n\n try {\n const uEvent = await RecurringEvent.findOneAndUpdate(filter, update, {new: true});\n return res.status(200).send(uEvent);\n } catch (err) {\n return res.sendStatus(400);\n }\n};\n\n\n// Delete Recurring Event\nRecurringEventController.destroy = async function (req, res) {\n\tconst { RecurringEventId } = req.params;\n \n\ttry {\n\t const rEvent = await RecurringEvent.findByIdAndDelete(RecurringEventId);\n\t return res.status(200).send(rEvent);\n\t} catch (err) {\n\t return res.sendStatus(400);\n\t}\n };\n\nmodule.exports = RecurringEventController;", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/controllers/user.controller.js", + "messages": [], + "suppressedMessages": [ + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'usr' is defined but never used.", + "line": 195, + "column": 19, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 195, + "endColumn": 22, + "suppressions": [ + { + "kind": "directive", + "justification": "" + } + ] + } + ], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/controllers/user.controller.test.js", + "messages": [ + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 3, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 3, + "endColumn": 5 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 4, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 4, + "endColumn": 9 + } + ], + "suppressedMessages": [], + "errorCount": 2, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "const userContoller = require('./user.controller');\n\ntest('Can import the email controller', async () => {\n expect(userContoller).not.toBeUndefined();\n});\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/jest.config.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/jest.setup.js", + "messages": [ + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 9, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 9, + "endColumn": 5 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 13, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 13, + "endColumn": 5 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 14, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 14, + "endColumn": 5 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 15, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 15, + "endColumn": 5 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 16, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 16, + "endColumn": 5 + } + ], + "suppressedMessages": [], + "errorCount": 5, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "// Be able to use Env variables in Github Actions\nconst dotenv = require('dotenv');\nconst dotenvExpand = require('dotenv-expand');\n\nconst myEnv = dotenv.config();\ndotenvExpand(myEnv);\n\n\njest.setTimeout(30000)\n\n// TODO: Refactor worker routes. These are setup to run cron jobs every time the app\n// is instantiated. These break any integration tests. \njest.mock('./workers/openCheckins');\njest.mock('./workers/closeCheckins');\njest.mock('./workers/createRecurringEvents');\njest.mock('./workers/slackbot');\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/middleware/auth.middleware.js", + "messages": [ + { + "ruleId": null, + "message": "Unused eslint-disable directive (no problems were reported from 'dot-notation').", + "line": 6, + "column": 3, + "severity": 1, + "nodeType": null, + "fix": { + "range": [155, 195], + "text": " " + } + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'err' is defined but never used.", + "line": 21, + "column": 12, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 21, + "endColumn": 15 + } + ], + "suppressedMessages": [], + "errorCount": 1, + "fatalErrorCount": 0, + "warningCount": 1, + "fixableErrorCount": 0, + "fixableWarningCount": 1, + "source": "const jwt = require('jsonwebtoken');\nconst { CONFIG_AUTH } = require('../config');\n\nfunction verifyToken(req, res, next) {\n // Allow users to set token\n // eslint-disable-next-line dot-notation\n let token = req.headers['x-access-token'] || req.headers['authorization'];\n if (token.startsWith('Bearer ')) {\n // Remove Bearer from string\n token = token.slice(7, token.length);\n }\n if (!token) {\n return res.sendStatus(403);\n }\n\n try {\n const decoded = jwt.verify(token, CONFIG_AUTH.SECRET);\n res.cookie('token', token, { httpOnly: true });\n req.userId = decoded.id;\n return next();\n } catch (err) {\n return res.sendStatus(401);\n }\n}\n\nfunction verifyCookie(req, res, next) {\n jwt.verify(req.cookies.token, CONFIG_AUTH.SECRET, (err, decoded) => {\n if (err) {\n return res.sendStatus(401);\n }\n req.userId = decoded.id;\n req.role = decoded.accessLevel;\n\n next();\n });\n}\n\nconst AuthUtil = {\n verifyToken,\n verifyCookie,\n};\nmodule.exports = AuthUtil;\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/middleware/errorhandler.middleware.js", + "messages": [ + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'next' is defined but never used.", + "line": 1, + "column": 41, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 1, + "endColumn": 45 + } + ], + "suppressedMessages": [], + "errorCount": 1, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "function errorHandler (error, req, res, next) {\n error.status = error.status || 500;\n\n res.status(error.status).json({\n error: {\n status: error.status,\n message: error.message || 'Internal Server Error',\n stack: error.stack || ''\n }\n });\n}\n\nmodule.exports = errorHandler;\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/middleware/index.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/middleware/token.middleware.js", + "messages": [ + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'err' is defined but never used.", + "line": 18, + "column": 12, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 18, + "endColumn": 15 + } + ], + "suppressedMessages": [], + "errorCount": 1, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "const jwt = require('jsonwebtoken');\nconst { CONFIG_AUTH } = require('../config');\n\nasync function isTokenValid(req, res, next) {\n let token = req.headers['x-access-token'] || req.headers['authorization'];\n if (token.startsWith('Bearer ')) {\n // Remove Bearer from string\n token = token.slice(7, token.length);\n }\n\n if (!token) {\n return res.sendStatus(400);\n }\n\n try {\n jwt.verify(token, CONFIG_AUTH.SECRET);\n next();\n } catch (err) {\n return res.sendStatus(403);\n }\n}\n\nconst verifyToken = {\n isTokenValid,\n};\n\nmodule.exports = verifyToken;\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/middleware/user.middleware.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/models/checkIn.model.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/models/event.model.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/models/index.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/models/project.model.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/models/projectTeamMember.model.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/models/question.model.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/models/recurringEvent.model.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/models/role.model.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/models/timeTracker.model.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/models/user.model.js", + "messages": [ + { + "ruleId": "no-dupe-keys", + "severity": 2, + "message": "Duplicate key 'githubHandle'.", + "line": 33, + "column": 3, + "nodeType": "ObjectExpression", + "messageId": "unexpected", + "endLine": 33, + "endColumn": 15 + } + ], + "suppressedMessages": [], + "errorCount": 1, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "const mongoose = require(\"mongoose\");\n// const bcrypt = require('bcrypt-nodejs');\n\nmongoose.Promise = global.Promise;\n\nconst userSchema = mongoose.Schema({\n name: {\n firstName: { type: String },\n lastName: { type: String },\n },\n email: { type: String, unique: true },\n accessLevel: { \n type: String, \n enum: [\"user\", \"admin\", \"superadmin\"], // restricts values to \"user\", \"admin\" and \"superadmin\"\n default: \"user\" \n },\n createdDate: { type: Date, default: Date.now },\n currentRole: { type: String }, // will remove but need to update check-in form\n desiredRole: { type: String }, // will remove but need to update check-in form\n newMember: { type: Boolean },\n currentJobTitle: { type: String }, // free-text of their current job title\n desiredJobTitle: { type: String }, // free-text of their desired job title\n skillsToMatch: [{ type: String }], // skills the user either has or wants to learn - will use to match to projects\n firstAttended: { type: String },\n attendanceReason: { type: String },\n githubHandle: { type: String },\n projects: [\n {\n type: mongoose.Schema.Types.ObjectId,\n ref: \"Project\",\n },\n ],\n githubHandle: { type: String }, // handle not including @, not the URL\n phone: { type: String },\n textingOk: { type: Boolean, default: false }, // is the user OK with texting at the phone number provided?\n slackName: { type: String }, // does the user input this?\n isHflaGithubMember: { type: Boolean }, // pull from API once github handle in place?\n githubPublic2FA: { type: Boolean }, // does the user have 2FA enabled on their github and membership set to public?\n availability: { type: String }, // availability to meet outside of hacknight times; string for now, more structured in future\n managedProjects: [{ type: String}], // Which projects managed by user.\n //currentProject: { type: String } // no longer need this as we can get it from Project Team Member table\n // password: { type: String, required: true }\n isActive: { type: Boolean, default: true }\n});\n\nuserSchema.methods.serialize = function () {\n return {\n id: this._id,\n name: {\n firstName: this.name.firstName,\n lastName: this.name.lastName,\n },\n email: this.email,\n accessLevel: this.accessLevel,\n createdDate: this.createdDate,\n currentRole: this.currentRole, // will remove but need to update check-in form\n desiredRole: this.desiredRole, // will remove but need to update check-in form\n newMember: this.newMember,\n currentJobTitle: this.currentRole,\n desiredJobTitle: this.desiredRole,\n skillsToMatch: this.skillsToMatch,\n firstAttended: this.firstAttended,\n attendanceReason: this.attendanceReason,\n githubHandle: this.githubHandle,\n projects: this.projects,\n //currentProject: this.currentProject\n phone: this.phone,\n textingOk: this.textingOk,\n slackName: this.slackName,\n isHflaGithubMember: this.isHflaGithubMember,\n githubPublic2FA: this.githubPublic2FA,\n availability: this.availability,\n managedProjects: this.managedProjects,\n isActive: this.isActive\n };\n};\n\nconst User = mongoose.model(\"User\", userSchema);\n\nmodule.exports = { User };\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/models/user.model.test.js", + "messages": [ + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 5, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 5, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'afterEach' is not defined.", + "line": 7, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 7, + "endColumn": 12 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 8, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 8, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 11, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 11, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 12, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 12, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 48, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 48, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 79, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 79, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 80, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 80, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 95, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 95, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 96, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 96, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 99, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 99, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 119, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 119, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 120, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 120, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 121, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 121, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 122, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 122, + "endColumn": 19 + } + ], + "suppressedMessages": [], + "errorCount": 15, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "// import necessary modules\nconst mongoose = require('mongoose');\nconst { User } = require('./user.model');\n\ndescribe('Unit tests for User Model', () => {\n // Clears all mocks after each test\n afterEach(() => {\n jest.restoreAllMocks();\n });\n\n describe('Serialization test', () => {\n it('should return the correct serialized user object', async () => {\n // Create mock user data\n const userObj = {\n _id: new mongoose.Types.ObjectId(),\n name: {\n firstName: 'mock',\n lastName: 'user',\n },\n email: 'mock.user@example.com',\n accessLevel: 'user',\n createdDate: new Date(),\n currentRole: 'developer',\n desiredRole: 'lead developer',\n newMember: false,\n currentJobTitle: 'Software Engineer',\n desiredJobTitle: 'Senior Software Engineer',\n skillsToMatch: ['Jest', 'Node.js'],\n firstAttended: '2025-01-01',\n attendanceReason: 'To learn and contribute',\n githubHandle: 'mockuser',\n projects: ['ProjectId1', 'ProjectId2'],\n phone: '123-456-7890',\n textingOk: true,\n slackName: 'mockuser',\n isHflaGithubMember: true,\n githubPublic2FA: true,\n availability: 'Weekdays',\n managedProjects: ['Project1', 'Project2'],\n isActive: true,\n };\n\n // Create a mock user instance\n const mockUser = new User(userObj);\n const serializedUser = mockUser.serialize();\n\n // Test\n expect(serializedUser).toEqual({\n id: mockUser._id,\n name: {\n firstName: mockUser.name.firstName,\n lastName: mockUser.name.lastName,\n },\n email: mockUser.email,\n accessLevel: mockUser.accessLevel,\n createdDate: mockUser.createdDate,\n currentRole: mockUser.currentRole,\n desiredRole: mockUser.desiredRole,\n newMember: mockUser.newMember,\n currentJobTitle: mockUser.currentRole,\n desiredJobTitle: mockUser.desiredRole,\n skillsToMatch: mockUser.skillsToMatch,\n firstAttended: mockUser.firstAttended,\n attendanceReason: mockUser.attendanceReason,\n githubHandle: mockUser.githubHandle,\n projects: mockUser.projects,\n phone: mockUser.phone,\n textingOk: mockUser.textingOk,\n slackName: mockUser.slackName,\n isHflaGithubMember: mockUser.isHflaGithubMember,\n githubPublic2FA: mockUser.githubPublic2FA,\n availability: mockUser.availability,\n managedProjects: mockUser.managedProjects,\n isActive: mockUser.isActive,\n });\n });\n });\n\n describe('Validation test', () => {\n it('should fail validation check if accessLevel is invalid', async () => {\n // Create a mock user with an invalid accessLevel\n const mockuser = new User({\n accessLevel: 'projectleader', // not 'user', 'admin', or 'superadmin'\n });\n\n // Attempt to validate the mock user by checking for valid accessLevel\n let error;\n try {\n await mockuser.validate();\n } catch (err) {\n error = err;\n }\n\n // Tests\n expect(error).toBeDefined();\n expect(error.errors.accessLevel).toBeDefined();\n });\n\n it('should pass validation with valid user data', async () => {\n // Create a mock user with valid data\n const mockUser = new User({\n name: {\n firstName: 'Valid',\n lastName: 'User',\n },\n email: 'mockuser@gmail.com',\n accessLevel: 'user',\n });\n\n // Attempt to save the mock user\n let error;\n try {\n await mockUser.validate();\n } catch (err) {\n error = err;\n }\n\n // Tests\n expect(error).toBeUndefined();\n expect(mockUser.email).toBe('mockuser@gmail.com');\n expect(mockUser.accessLevel).toBe('user');\n await expect(mockUser.validate()).resolves.toBeUndefined(); // async validation check\n });\n });\n});\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/routers/auth.router.js", + "messages": [ + { + "ruleId": null, + "message": "Unused eslint-disable directive (no problems were reported from 'func-names').", + "line": 8, + "column": 1, + "severity": 1, + "nodeType": null, + "fix": { + "range": [253, 291], + "text": " " + } + } + ], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 1, + "fixableErrorCount": 0, + "fixableWarningCount": 1, + "source": "const express = require('express');\nconst { AuthUtil, verifyUser, verifyToken } = require('../middleware');\nconst { UserController } = require('../controllers/');\nconst { authApiValidator } = require('../validators');\n\nconst router = express.Router();\n\n// eslint-disable-next-line func-names\nrouter.use(function (req, res, next) {\n res.header('Access-Control-Allow-Headers', 'x-access-token, Origin, Content-Type, Accept');\n next();\n});\n\n// The root is /api/auth\nrouter.post(\n '/signup',\n [authApiValidator.validateCreateUserAPICall, verifyUser.checkDuplicateEmail],\n UserController.createUser,\n);\n\nrouter.post(\n '/signin',\n [authApiValidator.validateSigninUserAPICall, verifyUser.isAdminByEmail],\n UserController.signin,\n);\n\nrouter.post('/verify-signin', [verifyToken.isTokenValid], UserController.verifySignIn);\n\nrouter.post('/me', [AuthUtil.verifyCookie], UserController.verifyMe);\n\nrouter.post('/logout', [AuthUtil.verifyCookie], UserController.logout);\n\nmodule.exports = router;\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/routers/checkIns.router.js", + "messages": [ + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'checkIn' is defined but never used.", + "line": 46, + "column": 12, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 46, + "endColumn": 19 + } + ], + "suppressedMessages": [], + "errorCount": 1, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "const express = require(\"express\");\nconst router = express.Router();\n\nconst { CheckIn } = require('../models/checkIn.model');\n\n// GET /api/checkins/\nrouter.get('/', (req, res) => {\n CheckIn.find()\n .then((checkIns) => {\n res.status(200).send(checkIns);\n })\n .catch((err) => {\n console.log(err);\n res.sendStatus(400);\n });\n});\n\nrouter.get(\"/:id\", (req, res) => {\n CheckIn.findById(req.params.id)\n .then((checkIn) => {\n res.status(200).send(checkIn);\n })\n .catch((err) => {\n console.log(err);\n res.sendStatus(400);\n });\n});\n\nrouter.get(\"/findEvent/:id\", (req, res) => {\n CheckIn.find({ eventId: req.params.id, userId: { $ne: \"undefined\" } })\n .populate({\n path: \"userId\",\n model: \"User\",\n })\n .then((checkIns) => {\n res.status(200).send(checkIns);\n })\n .catch((err) => {\n console.log(err);\n res.sendStatus(400);\n });\n});\n\nrouter.post(\"/\", (req, res) => {\n CheckIn.create(req.body)\n .then((checkIn) => {\n res.sendStatus(201);\n })\n .catch((err) => {\n console.log(err);\n res.sendStatus(400);\n });\n});\n\nmodule.exports = router;\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/routers/checkIns.router.test.js", + "messages": [ + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 2, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 2, + "endColumn": 5 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 17, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 17, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'afterEach' is not defined.", + "line": 25, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 25, + "endColumn": 12 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 26, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 26, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 29, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 29, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 30, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 30, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 37, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 37, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 38, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 38, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 39, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 39, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 45, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 45, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 52, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 52, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 53, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 53, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 54, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 54, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 60, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 60, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 67, + "column": 19, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 67, + "endColumn": 23 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 73, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 73, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 77, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 77, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 78, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 78, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 79, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 79, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 86, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 86, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 87, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 87, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 103, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 103, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 104, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 104, + "endColumn": 13 + } + ], + "suppressedMessages": [], + "errorCount": 23, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "// Mock and import CheckIn model\njest.mock('../models/checkIn.model');\nconst { CheckIn } = require('../models');\n\n// Import the check-ins router\nconst express = require('express');\nconst supertest = require('supertest');\nconst checkInsRouter = require('./checkIns.router');\n\n// Create a new Express application for testing\nconst testapp = express();\n// Allows for body parsing\ntestapp.use(express.json());\ntestapp.use('/api/checkins', checkInsRouter);\nconst request = supertest(testapp);\n\ndescribe('Unit tests for checkIns router', () => {\n // Mock data for check-ins\n const mockCheckIns = [\n { id: 1, eventId: 'event1', userId: 'user1', checkedIn: true, createdDate: String(new Date()) },\n { id: 2, eventId: 'event2', userId: 'user2', checkedIn: true, createdDate: String(new Date()) },\n ];\n\n // Clear mocks after each test\n afterEach(() => {\n jest.clearAllMocks();\n });\n\n describe('READ', () => {\n it('should return a list of check-ins with GET /api/checkins', async (done) => {\n // Mock Mongoose method\n CheckIn.find.mockResolvedValue(mockCheckIns);\n\n const response = await request.get('/api/checkins');\n\n // Tests\n expect(CheckIn.find).toHaveBeenCalled();\n expect(response.status).toBe(200);\n expect(response.body).toEqual(mockCheckIns);\n\n // Marks completion of test\n done();\n });\n\n it('should return a single check-in by id with GET /api/checkins/:id', async (done) => {\n // Mock Mongoose method\n CheckIn.findById.mockResolvedValue(mockCheckIns[0]);\n\n const response = await request.get('/api/checkins/1');\n\n // Tests\n expect(CheckIn.findById).toHaveBeenCalledWith('1');\n expect(response.status).toBe(200);\n expect(response.body).toEqual(mockCheckIns[0]);\n\n // Marks completion of test\n done();\n });\n\n it('should return a list of users who have checked into a specific event with GET /api/checkins/findEvent/:id', async (done) => {\n // Mock specific checkIn\n const mockCheckIn = mockCheckIns[1];\n const { eventId } = mockCheckIn;\n\n // Mock Mongoose methods\n CheckIn.find.mockReturnValue({\n populate: jest.fn().mockResolvedValue(mockCheckIn),\n });\n\n const response = await request.get(`/api/checkins/findEvent/${eventId}`);\n\n // Tests\n expect(CheckIn.find).toHaveBeenCalledWith({\n eventId: eventId,\n userId: { $ne: 'undefined' },\n });\n expect(CheckIn.find().populate).toHaveBeenCalledWith({ path: 'userId', model: 'User' });\n expect(response.status).toBe(200);\n expect(response.body).toEqual(mockCheckIn);\n\n // Marks completion of test\n done();\n });\n });\n\n describe('CREATE', () => {\n it('should create a new check-in with POST /api/checkins', async (done) => {\n // Mock new check-in data\n const newCheckIn = {\n id: 3,\n eventId: 'event3',\n userId: 'user3',\n checkedIn: true,\n createdDate: String(new Date()),\n };\n\n // Mock create method\n CheckIn.create.mockResolvedValue(newCheckIn);\n\n const response = await request.post('/api/checkins').send(newCheckIn);\n\n // Tests\n expect(CheckIn.create).toHaveBeenCalledWith(newCheckIn);\n expect(response.status).toBe(201);\n\n // Marks completion of test\n done();\n });\n });\n});\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/routers/checkUser.router.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/routers/checkUser.router.test.js", + "messages": [ + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 2, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 2, + "endColumn": 5 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 17, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 17, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'afterEach' is not defined.", + "line": 45, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 45, + "endColumn": 12 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 46, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 46, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 49, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 49, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 50, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 50, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 59, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 59, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 60, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 60, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 61, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 61, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 68, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 68, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 69, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 69, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 76, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 76, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 77, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 77, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 78, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 78, + "endColumn": 13 + } + ], + "suppressedMessages": [], + "errorCount": 14, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "// Mock and import User Model\njest.mock('../models/user.model');\nconst { User } = require('../models');\n\n// Import checkUser router\nconst express = require('express');\nconst supertest = require('supertest');\nconst checkUserRouter = require('./checkUser.router');\n\n// Create a new Express application for testing\nconst testapp = express();\n// express.json() is a body parser needed for POST API requests\ntestapp.use(express.json());\ntestapp.use('/api/checkuser', checkUserRouter);\nconst request = supertest(testapp);\n\ndescribe('Unit tests for checkUser router', () => {\n // Mock user for test\n const id = '123';\n const mockUser = {\n id,\n name: {\n firstName: 'mock',\n lastName: 'user',\n },\n accessLevel: 'user',\n skillsToMatch: [],\n projects: [],\n textingOk: false,\n managedProjects: [],\n isActive: true,\n email: 'mockuser@gmail.com',\n currentRole: 'Product Owner',\n desiredRole: 'Product Owner',\n newMember: false,\n firstAttended: 'NOV 2015',\n createdDate: '2020-01-14T02:14:22.407Z',\n attendanceReason: 'Civic Engagement',\n currentProject: 'Undebate',\n };\n\n const auth_origin = 'test-origin';\n\n // Clear all mocks after each test\n afterEach(() => {\n jest.clearAllMocks();\n });\n\n describe('CREATE', () => {\n it('should authenticate user with POST /api/checkuser', async (done) => {\n // Mock Mongoose method\n User.findOne.mockResolvedValue(mockUser);\n\n const response = await request\n .post('/api/checkuser')\n .send({ email: 'mockuser@gmail.com', auth_origin });\n\n // Tests\n expect(User.findOne).toHaveBeenCalledWith({ email: 'mockuser@gmail.com' });\n expect(response.status).toBe(200);\n expect(response.body).toEqual({ user: mockUser, auth_origin: auth_origin });\n\n // Marks completion of tests\n done();\n });\n });\n\n describe('READ', () => {\n it('should return a user by id with GET /api/checkuser/:id', async (done) => {\n // Mock Mongoose method\n User.findById.mockResolvedValue(mockUser);\n\n const response = await request.get(`/api/checkuser/${id}`);\n\n // Tests\n expect(User.findById).toHaveBeenCalledWith(id);\n expect(response.status).toBe(200);\n expect(response.body).toEqual(mockUser);\n\n // Marks completion of tests\n done();\n });\n });\n});\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/routers/events.router.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/routers/grantpermission.router.js", + "messages": [ + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'err' is defined but never used.", + "line": 59, + "column": 12, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 59, + "endColumn": 15 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'err' is defined but never used.", + "line": 123, + "column": 12, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 123, + "endColumn": 15 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'err' is defined but never used.", + "line": 157, + "column": 16, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 157, + "endColumn": 19 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'listFiles' is defined but never used.", + "line": 235, + "column": 10, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 235, + "endColumn": 19 + } + ], + "suppressedMessages": [], + "errorCount": 4, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "const express = require(\"express\");\nconst router = express.Router();\nconst fs = require(\"fs\");\n\nconst { google } = require(\"googleapis\");\nconst async = require('async');\nconst fetch = require(\"node-fetch\");\n\nconst SCOPES = [\"https://www.googleapis.com/auth/drive\"];\n\n// placeholder org for testing\nconst githubOrganization = \"testvrms\";\n\n// GET /api/grantpermission/googleDrive\nrouter.post(\"/googleDrive\", async (req, res) => {\n let credentials = JSON.parse(process.env.GOOGLECREDENTIALS);\n\n //checks if email and file to change are in req.body\n if (!req.body.email || !req.body.file) {\n return res.sendStatus(400);\n }\n\n const { client_secret, client_id, redirect_uris } = credentials;\n\n const oAuth2Client = new google.auth.OAuth2(\n client_id,\n client_secret,\n redirect_uris[1]\n );\n console.log(\"AFTERCLIENT\");\n // if (err)\n // return res.status(500).send({\n // message: \"Error loading client secret file:\" + err.message,\n // });\n\n const tokenObject = {\n access_token: process.env.GOOGLE_ACCESS_TOKEN,\n refresh_token: process.env.GOOGLE_REFRESH_TOKEN,\n scope: \"https://www.googleapis.com/auth/drive\",\n token_type: \"Bearer\",\n expiry_date: process.env.GOOGLE_EXPIRY_DATE,\n };\n oAuth2Client.setCredentials(tokenObject);\n\n console.log(\"AFTR OAUTH\");\n // sends google drive grant permission from VRMS to email\n try {\n const result = await grantPermission(\n oAuth2Client,\n req.body.email,\n req.body.file\n );\n if (result.success) {\n const successObject = { message: \"Success!\" };\n return res.status(200).send(successObject);\n } else {\n return res.sendStatus(400);\n }\n } catch (err) {\n return res.sendStatus(500);\n }\n});\n\n// GET /api/grantpermission/gitHub (checks if it can update the db data)\n\n// Route accounts for onboaring admins or regular users\nrouter.post(\"/gitHub\", async (req, res) => {\n const { teamName, accessLevel, handle } = req.body;\n const userHandle = handle;\n const baseTeamSlug = createSlug(teamName);\n const managerTeamSlug = baseTeamSlug + \"-managers\";\n const adminTeamSlug = baseTeamSlug + \"-admins\";\n\n const teamSlugs = [baseTeamSlug, managerTeamSlug];\n\n if (accessLevel === \"admin\" || accessLevel === \"superadmin\") teamSlugs.push(adminTeamSlug);\n\n function createSlug(string) {\n let slug = string.toLowerCase();\n return slug.split(\" \").join(\"-\");\n }\n\n try {\n // Is member of github organization? If not, add to organization\n const userStatus = await checkOrgMembershipStatus(userHandle);\n const orgMembershipStatus = userStatus\n ? userStatus\n : (await inviteToOrg(userHandle)) && \"pending\";\n\n // Add user to github project teams\n console.log({ teamSlugs });\n await Promise.all(\n teamSlugs.map(async (slug) => {\n const result = await addToTeam(userHandle, slug);\n console.log({ slug });\n if (result === \"team not found\") {\n throw new Error(\"team not found\");\n }\n if (!result) {\n throw new Error(\"user not added to one or more teams\");\n }\n return;\n })\n );\n\n const result = {\n orgMembershipStatus,\n teamMembershipStatus: \"pending\",\n };\n\n if (orgMembershipStatus === \"active\") {\n // user automatically added to team if active membership in org\n result.teamMembershipStatus = \"active\";\n\n // check if membership is public\n result.publicMembership = await checkPublicMembership(userHandle);\n\n // check if 2FA is enabled\n result.twoFAenabled = await check2FA(userHandle);\n }\n\n return res.status(200).send(result);\n } catch (err) {\n return res.status(400);\n }\n});\n\nrouter.post(\"/\", async (req, res) => {\n fs.readFile(\"credentials.json\", async (err, content) => {\n const credentialsObject = JSON.parse(content);\n const { client_secret, client_id, redirect_uris } = credentialsObject.web;\n const oAuth2Client = new google.auth.OAuth2(\n client_id,\n client_secret,\n redirect_uris[1]\n );\n\n // sends back error if credentials files cannot be read\n if (err) {\n return res.sendStatus(400);\n }\n\n let token;\n let setToken = false;\n\n // if the user did not send a refresh/access token with them in the body request\n if (!req.body.token && req.body.code) {\n try {\n const tokenResult = await sendToken(oAuth2Client, req.body.code);\n if (!tokenResult.success) {\n return res.sendStatus(400);\n } else {\n console.log(tokenResult);\n token = tokenResult.token;\n setToken = true;\n }\n } catch (err) {\n return res.sendStatus(400);\n }\n // if token is already placed into body request\n } else if (req.body.token) {\n token = req.body.token;\n }\n if (token) {\n oAuth2Client.setCredentials(token);\n try {\n // another callback function that returns promises can replace this method\n console.log(\"TRY\");\n const result = await grantPermission(\n oAuth2Client,\n req.body.email,\n req.body.file\n );\n if (result.success) {\n {\n const successObject = { message: \"Success!\" };\n if (setToken) {\n successObject.token = token;\n }\n return res.status(200).send(successObject);\n }\n } else {\n return res.sendStatus(400);\n }\n } catch (err) {\n console.log(err.message);\n return res.sendStatus(400);\n }\n } else {\n // returns a URL for the user to give permission\n return res.status(200).send({ url: sendURL(oAuth2Client) });\n }\n });\n});\n\n// If modifying these scopes, delete token.json.\n\n/**\n * Creates an auth URL that lets the user give permission to VRMS.\n * @param {oAuth2Client} oAuth2Client The OAuth2 client needed to generate an auth url.\n */\nfunction sendURL(oAuth2Client) {\n const authUrl = oAuth2Client.generateAuthUrl({\n access_type: \"offline\",\n scope: SCOPES,\n });\n return authUrl;\n}\n\n/**\n * Creates an token object including access token and refresh token that will allow the user to\n * be able to log in without needed to give permission each time\n * @param {oAuth2Client} oAuth2Client The authorization OAuth2 client needed to create a token object.\n * @param {String} code The code string from the auth URL.\n */\nfunction sendToken(oAuth2Client, code) {\n return new Promise(function (resolve, reject) {\n oAuth2Client.getToken(code, (err, token) => {\n if (err)\n reject({\n success: false,\n message: \"Error retrieving access token\" + err.message,\n });\n resolve({ success: true, token });\n });\n });\n}\n\n/**\n * Lists the names and IDs of up to 10 files.\n * @param {google.auth.OAuth2} auth An authorized OAuth2 client.\n * @returns {Promise} Promise with an object that contains the boolean success to determine\n * what to do in the route. Rejection objects also have a message field.\n */\nfunction listFiles(auth) {\n const drive = google.drive({ version: \"v3\", auth });\n return new Promise(function (resolve, reject) {\n drive.files.list(\n {\n pageSize: 10,\n fields: \"nextPageToken, files(id, name)\",\n },\n (err, res) => {\n if (err)\n reject({\n success: false,\n message: \"The API returned an error: \" + err.message,\n });\n const files = res.data.files;\n if (files.length) {\n console.log(\"Files:\");\n files.map((file) => {\n console.log(`${file.name} (${file.id})`);\n });\n resolve({ success: true });\n } else {\n return reject({\n success: false,\n message: \"No files found\",\n });\n }\n }\n );\n });\n}\n\n/**\n * Gives Google Drive permission to an email address for the file ID\n * @param {google.auth.OAuth2} auth An authorized OAuth2 client.\n * @param {String} email E-mail to receive Google Drive invite\n * @param {String} fileId File ID to give permissions\n * @returns {Promise} Promise with an object that contains the boolean success to determine\n * what to do in the route. Rejection objects also have a message field.\n */\nfunction grantPermission(auth, email, fileId) {\n console.log(\"GRANT PERMISSIONS\");\n var permissions = [\n {\n type: \"user\",\n role: \"writer\",\n emailAddress: email,\n },\n ];\n\n return new Promise(function (resolve, reject) {\n async.eachSeries(permissions, function (permission, permissionCallback) {\n const drive = google.drive({ version: \"v3\", auth });\n drive.permissions.create(\n {\n resource: permission,\n fileId: fileId,\n fields: \"id\",\n emailMessage:\n \"Hi there! You are receiving this message from the VRMS team. Enjoy!\",\n },\n (err, res) => {\n if (err) {\n console.log(\"PROMISE ERROR\", err);\n reject({\n success: false,\n message: \"The API returned an error: \" + err.message,\n });\n } else {\n console.log(\"RES\", res);\n permissionCallback();\n resolve({ success: true });\n }\n }\n );\n });\n });\n}\n\n/**\n * Checks if user is a public OR private member of the organization.\n * Requires authentication to the organization (currently via a token in env file).\n * @param {str} githubHandle\n */\nfunction checkOrgMembershipStatus(githubHandle) {\n return fetch(\n `https://api.github.com/orgs/${githubOrganization}/memberships/${githubHandle}`,\n {\n method: \"GET\",\n headers: {\n Authorization: `token ${process.env.GITHUB_TOKEN}`,\n },\n }\n )\n .then((res) => {\n if (res.status === 200) return res.json();\n if (res.status === 404) return false;\n\n return new Error(\"Unexpected result\");\n })\n .then((res) => {\n if (res) {\n return res.state === \"pending\" ? \"pending\" : \"active\";\n } else {\n return false;\n }\n });\n}\n\n/**\n * API call returns 200 if successfully invited or if already in organization\n * @param {str} githubHandle\n */\nfunction inviteToOrg(githubHandle) {\n return fetch(\n `https://api.github.com/orgs/${githubOrganization}/memberships/${githubHandle}?role=member`,\n {\n method: \"PUT\",\n headers: {\n Authorization: `token ${process.env.GITHUB_TOKEN}`,\n },\n }\n ).then((res) =>\n res.status === 200 ? true : new Error(\"Unexpected response\")\n );\n}\n\n/**\n * @returns \"active\" or \"pending\". Returns \"active\" if already on team OR\n * if already a member of the organization (automatically adds them without\n * sendaingn invitation ). Returns \"pending\" if membership is pending\n * (collaborator invite is sent).\n * @param {str} githubHandle\n * @param {str} teamSlug\n */\nfunction addToTeam(githubHandle, teamSlug) {\n return fetch(\n `https://api.github.com/orgs/${githubOrganization}/teams/${teamSlug}/memberships/${githubHandle}`,\n {\n method: \"PUT\",\n headers: {\n Authorization: `token ${process.env.GITHUB_TOKEN}`,\n },\n }\n )\n .then((res) => ({\n result: res.json(),\n status: res.status,\n }))\n .then((res) => {\n if (res.result.message === \"Not Found\") {\n return \"team not found\"; // how can I just throw an error here instead?\n } else {\n console.log(res.status);\n return Boolean(res.status === 200);\n }\n });\n}\n\nfunction check2FA(githubHandle) {\n return fetch(\n `https://api.github.com/orgs/${githubOrganization}/members?filter=2fa_disabled`\n ).then((no2FAMembersArr) => {\n if (no2FAMembersArr.length) {\n return !no2FAMembersArr.includes(\n (member) => member.login === githubHandle\n );\n }\n\n return true;\n });\n}\n\nfunction checkPublicMembership(githubHandle) {\n return fetch(\n `https://api.github.com/orgs/${githubOrganization}/public_members/${githubHandle}`\n ).then((res) => (res.status === 204 ? true : false));\n}\n\nmodule.exports = router;\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/routers/healthCheck.router.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/routers/projectTeamMembers.router.js", + "messages": [ + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'err' is defined but never used.", + "line": 80, + "column": 13, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 80, + "endColumn": 16 + } + ], + "suppressedMessages": [], + "errorCount": 1, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "const express = require(\"express\");\nconst router = express.Router();\n\nconst { ProjectTeamMember } = require('../models/projectTeamMember.model');\n\n// GET /api/projectteammembers/\nrouter.get(\"/\", (req, res) => {\n ProjectTeamMember.find()\n .populate(\"userId\")\n .then((teamMembers) => {\n return res.status(200).send(teamMembers);\n })\n .catch((err) => {\n console.log(err);\n return res.sendStatus(400);\n });\n});\n\nrouter.get(\"/:id\", (req, res) => {\n ProjectTeamMember.find({ projectId: req.params.id })\n .populate(\"userId\")\n .then((teamMembers) => {\n return res.status(200).send(teamMembers);\n })\n .catch((err) => {\n console.log(err);\n return res.sendStatus(400);\n });\n});\n\nrouter.get(\"/project/:id/:userId\", (req, res) => {\n ProjectTeamMember.find({\n projectId: req.params.id,\n userId: req.params.userId,\n })\n .populate(\"userId\")\n .then((teamMember) => {\n if (!teamMember.length) {\n return res.sendStatus(400);\n } else {\n return res.status(200).send(teamMember);\n }\n })\n .catch((err) => {\n console.log(err);\n return res.sendStatus(400);\n });\n});\n\nrouter.get(\"/projectowner/:id\", (req, res) => {\n const id = req.params.id;\n\n ProjectTeamMember.findOne({ userId: id })\n .populate(\"userId\")\n .populate(\"projectId\")\n .then((teamMember) => {\n teamMember.vrmsProjectAdmin === true\n ? res.status(200).send(teamMember)\n : res.status(200).send(false);\n })\n .catch((err) => {\n res.status(400).send(err);\n });\n});\n\nrouter.post(\"/\", (req, res) => {\n ProjectTeamMember.create(req.body)\n .then((teamMember) => {\n return res.status(201).send(teamMember);\n })\n .catch((err) => {\n console.log(err);\n return res.sendStatus(400);\n });\n});\n\nrouter.patch(\"/:id\", (req, res) => {\n ProjectTeamMember.findByIdAndUpdate(req.params.id, req.body)\n .then((edit) => res.json(edit))\n .catch((err) =>\n res.sendStatus(400));\n // };\n});\n\nmodule.exports = router;\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/routers/projects.router.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/routers/projects.router.test.js", + "messages": [ + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 2, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 2, + "endColumn": 5 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 5, + "column": 26, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 5, + "endColumn": 30 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 6, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 6, + "endColumn": 5 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 25, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 25, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'afterEach' is not defined.", + "line": 27, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 27, + "endColumn": 12 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 28, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 28, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 31, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 31, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 76, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 76, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 86, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 86, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 87, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 87, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 88, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 88, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 94, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 94, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 107, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 107, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 108, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 108, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 109, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 109, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 110, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 110, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 112, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 112, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 113, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 113, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 120, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 120, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 143, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 143, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 153, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 153, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 154, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 154, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 155, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 155, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 156, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 156, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 160, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 160, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 161, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 161, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 162, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 162, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 163, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 163, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 165, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 165, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 166, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 166, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 173, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 173, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 218, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 218, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 228, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 228, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 229, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 229, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 230, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 230, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 259, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 259, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 269, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 269, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 270, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 270, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 271, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 271, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 272, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 272, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 276, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 276, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 277, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 277, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 278, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 278, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 279, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 279, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 281, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 281, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 282, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 282, + "endColumn": 13 + } + ], + "suppressedMessages": [], + "errorCount": 46, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "// Mock for Project controller\njest.mock('../controllers/project.controller');\n\n// Mock AuthUtil.verifyCookie middleware\nconst mockVerifyCookie = jest.fn((req, res, next) => next());\njest.mock('../middleware/auth.middleware', () => ({\n verifyCookie: mockVerifyCookie,\n}));\n\n// Import Projects router and controller\nconst ProjectController = require('../controllers/project.controller');\nconst projectsRouter = require('./projects.router');\nconst express = require('express');\nconst supertest = require('supertest');\n\n// Set up testapp for testing Projects router\nconst testapp = express();\n// Allows for body parsing of JSON data\ntestapp.use(express.json());\n// Allows for body parsing of HTML data\ntestapp.use(express.urlencoded({ extended: false }));\ntestapp.use('/api/projects/', projectsRouter);\nconst request = supertest(testapp);\n\ndescribe('Unit testing for Projects router', () => {\n // Clear all mocks after each test\n afterEach(() => {\n jest.clearAllMocks();\n });\n\n describe('READ', () => {\n // Mock list of projects\n const mockProjects = [\n {\n id: '1',\n name: 'mockProject1',\n description: 'first testing',\n githubIdentifier: 'gitHubTest1',\n projectStatus: 'Active',\n location: 'South LA',\n createdDate: Date.now(),\n completedDate: Date.now(),\n githubUrl: 'https://github.com/mockProject1',\n slackUrl: 'https://slack.com/mockProject1',\n googleDriveUrl: 'https://drive.google.com/mockProject1',\n googleDriveId: '1',\n hflaWebsiteUrl: 'mockHFLAurl',\n videoConferenceLink: 'mockVideoLink',\n lookingDescription: 'n/a',\n recruitingCategories: ['n/a'],\n partners: ['n/a'],\n managedByUsers: ['n/a'],\n },\n {\n id: '2',\n name: 'mockProject2',\n description: 'second testing',\n githubIdentifier: 'gitHubTest2',\n projectStatus: 'Inactive',\n location: 'Bay Area',\n createdDate: Date.now(),\n completedDate: Date.now(),\n githubUrl: 'https://github.com/mockProject2',\n slackUrl: 'https://slack.com/mockProject2',\n googleDriveUrl: 'https://drive.google.com/mockProject2',\n googleDriveId: '2',\n hflaWebsiteUrl: 'mockHFLAurl2',\n videoConferenceLink: 'mockVideoLink2',\n lookingDescription: 'n/a',\n recruitingCategories: ['n/a'],\n partners: ['n/a'],\n managedByUsers: ['n/a'],\n },\n ];\n\n it('should return a list of projects based on query with GET /api/projects/', async (done) => {\n // Mock ProjectController.project_list method when this route is called\n ProjectController.project_list.mockImplementationOnce((req, res) => {\n res.status(200).send(mockProjects);\n });\n\n // Mock GET API call\n const response = await request.get('/api/projects');\n\n // Tests\n expect(ProjectController.project_list).toHaveBeenCalled();\n expect(response.status).toBe(200);\n expect(response.body).toEqual(mockProjects);\n\n // Marks completion of tests\n done();\n });\n\n it('should return a single project with GET /api/projects/:ProjectId', async (done) => {\n const mockProject = mockProjects[0];\n const ProjectId = mockProject.id;\n\n // Mock ProjectController.project_list method when this route is called\n ProjectController.project_by_id.mockImplementationOnce((req, res) => {\n res.status(200).send(mockProject);\n });\n\n // Mock GET API call\n const response = await request.get(`/api/projects/${ProjectId}`);\n\n // Tests\n expect(ProjectController.project_by_id).toHaveBeenCalledWith(\n expect.objectContaining({ params: { ProjectId } }),\n expect.anything(), // Mock response\n expect.anything(), // Mock next\n );\n expect(response.status).toBe(200);\n expect(response.body).toEqual(mockProject);\n\n // Marks completion of tests\n done();\n });\n });\n\n describe('CREATE', () => {\n // Mock new project\n const newProject = {\n id: '3',\n name: 'mockProject3',\n description: 'first testing',\n githubIdentifier: 'gitHubTest3',\n projectStatus: 'Active',\n location: 'LA',\n createdDate: Date.now(),\n completedDate: Date.now(),\n githubUrl: 'https://github.com/mockProject3',\n slackUrl: 'https://slack.com/mockProject3',\n googleDriveUrl: 'https://drive.google.com/mockProject3',\n googleDriveId: '3',\n hflaWebsiteUrl: 'mockHFLAurl',\n videoConferenceLink: 'mockVideoLink',\n lookingDescription: 'n/a',\n recruitingCategories: ['n/a'],\n partners: ['n/a'],\n managedByUsers: ['n/a'],\n };\n\n it('should create a new project with POST /api/projects', async (done) => {\n // Mock ProjectController.create method when this route is called\n ProjectController.create.mockImplementationOnce((req, res) => {\n res.status(201).send(newProject);\n });\n\n // Mock API POST req\n const response = await request.post('/api/projects').send(newProject);\n\n // Middlware assertions\n expect(mockVerifyCookie).toHaveBeenCalledWith(\n expect.any(Object),\n expect.any(Object),\n expect.any(Function),\n );\n\n // Tests\n expect(ProjectController.create).toHaveBeenCalledWith(\n expect.objectContaining({ body: newProject }), // Check if newProject in body is parsed \n expect.anything(), // Mock response\n expect.anything(), // Mock next\n );\n expect(response.status).toBe(201);\n expect(response.body).toEqual(newProject);\n\n // Marks completion of tests\n done();\n });\n });\n\n describe('UPDATE', () => {\n // Mock filtered projects\n const filteredProjects = [\n {\n id: '1',\n name: 'Filtered Project 1',\n description: 'Filtered description 1',\n projectStatus: 'Active',\n githubIdentifier: 'gitHubTest1',\n location: 'South LA',\n createdDate: Date.now(),\n completedDate: Date.now(),\n githubUrl: 'https://github.com/mockProject1',\n slackUrl: 'https://slack.com/mockProject1',\n googleDriveUrl: 'https://drive.google.com/mockProject1',\n googleDriveId: '1',\n hflaWebsiteUrl: 'mockHFLAurl',\n videoConferenceLink: 'mockVideoLink',\n lookingDescription: 'n/a',\n recruitingCategories: ['n/a'],\n partners: ['n/a'],\n managedByUsers: ['n/a'],\n },\n {\n id: '2',\n name: 'Filtered Project 2',\n description: 'Filtered description 2',\n projectStatus: 'Inactive',\n githubIdentifier: 'gitHubTest1',\n location: 'South LA',\n createdDate: Date.now(),\n completedDate: Date.now(),\n githubUrl: 'https://github.com/mockProject1',\n slackUrl: 'https://slack.com/mockProject1',\n googleDriveUrl: 'https://drive.google.com/mockProject1',\n googleDriveId: '1',\n hflaWebsiteUrl: 'mockHFLAurl',\n videoConferenceLink: 'mockVideoLink',\n lookingDescription: 'n/a',\n recruitingCategories: ['n/a'],\n partners: ['n/a'],\n managedByUsers: ['n/a'],\n },\n ];\n\n it('should return a filed list of projects for PMs with PUT /api/projects', async (done) => {\n // Mock ProjectController.pm_filtered_projects method when this route is called\n ProjectController.pm_filtered_projects.mockImplementationOnce((req, res) => {\n res.status(200).send(filteredProjects);\n });\n\n // Mock PUT API call\n const response = await request.put('/api/projects');\n\n // Tests\n expect(ProjectController.pm_filtered_projects).toHaveBeenCalled();\n expect(response.status).toBe(200);\n expect(response.body).toEqual(filteredProjects);\n\n // Marks completion of tests\n done();\n });\n\n const updatedProject = {\n id: '1',\n name: 'updated project1',\n description: 'updated testing',\n githubIdentifier: 'gitHubTest3',\n projectStatus: 'Active',\n location: 'New York',\n createdDate: Date.now(),\n completedDate: Date.now(),\n githubUrl: 'https://github.com/updateProject',\n slackUrl: 'https://slack.com/updateProject',\n googleDriveUrl: 'https://drive.google.com/updateProject',\n googleDriveId: '2',\n hflaWebsiteUrl: 'updatedURL',\n videoConferenceLink: 'updatedURL',\n lookingDescription: 'n/a',\n recruitingCategories: ['n/a'],\n partners: ['n/a'],\n managedByUsers: ['n/a'],\n };\n\n const ProjectId = updatedProject.id;\n\n it('should return an updated project with PUT /api/projects/:ProjectId', async (done) => {\n // Mock ProjectController.update method when this route is called\n ProjectController.update.mockImplementationOnce((req, res) => {\n res.status(200).send(updatedProject);\n });\n\n // Mock PUT API call\n const response = await request.put(`/api/projects/${ProjectId}`).send(updatedProject);\n\n // Middlware assertions\n expect(mockVerifyCookie).toHaveBeenCalledWith(\n expect.any(Object),\n expect.any(Object),\n expect.any(Function),\n );\n\n // Tests\n expect(ProjectController.update).toHaveBeenCalledWith(\n expect.objectContaining({ params: { ProjectId }}), // Check if ProjectId is parsed from params\n expect.anything(), // Mock response\n expect.anything(), // Mock next\n );\n expect(response.status).toBe(200);\n expect(response.body).toEqual(updatedProject);\n\n // Marks completion of tests\n done();\n });\n });\n});\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/routers/questions.router.js", + "messages": [ + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'question' is defined but never used.", + "line": 26, + "column": 15, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 26, + "endColumn": 23 + } + ], + "suppressedMessages": [], + "errorCount": 1, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "const express = require('express');\nconst router = express.Router();\n\nconst { Question } = require('../models/question.model');\n\n\n// GET /api/questions/\nrouter.get('/', (req, res) => {\n // const { query } = req;\n \n Question\n .find()\n .then(questions => {\n return res.status(200).send(questions);\n })\n .catch(err => {\n console.log(err);\n return res.sendStatus(400);\n });\n});\n\nrouter.post('/', (req, res) => {\n\n Question\n .create(req.body)\n .then(question => {\n return res.sendStatus(201);\n })\n .catch(err => {\n console.log(err);\n return res.sendStatus(400);\n });\n});\n\nrouter.get('/:id', (req, res) => {\n\n Question\n .findById(req.params.id)\n .then(event => {\n return res.status(200).send(event);\n })\n .catch(err => {\n console.log(err);\n return res.sendStatus(400);\n });\n});\n\nmodule.exports = router;\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/routers/questions.router.test.js", + "messages": [ + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 2, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 2, + "endColumn": 5 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 17, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 17, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'afterEach' is not defined.", + "line": 19, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 19, + "endColumn": 12 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 20, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 20, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 23, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 23, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 50, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 50, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 58, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 58, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 59, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 59, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 60, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 60, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 66, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 66, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 72, + "column": 29, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 72, + "endColumn": 33 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 78, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 78, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 79, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 79, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 80, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 80, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 88, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 88, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 98, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 98, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 99, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 99, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 100, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 100, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 106, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 106, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 115, + "column": 29, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 115, + "endColumn": 33 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 121, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 121, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 122, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 122, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 123, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 123, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 132, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 132, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 133, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 133, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 154, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 154, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 155, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 155, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 161, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 161, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 167, + "column": 29, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 167, + "endColumn": 33 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 173, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 173, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 174, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 174, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 175, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 175, + "endColumn": 13 + } + ], + "suppressedMessages": [], + "errorCount": 32, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "// Mock and import Question model, import question router\njest.mock('../models/question.model');\nconst { Question } = require('../models');\nconst questionsRouter = require('./questions.router');\n\n// Create a test app with Express\nconst express = require('express');\nconst supertest = require('supertest');\nconst testapp = express();\n// Allow for body parsing of JSON data\ntestapp.use(express.json());\n// Allow for body parsing of HTML data\ntestapp.use(express.urlencoded({ extended: false }));\ntestapp.use('/api/questions/', questionsRouter);\nconst request = supertest(testapp);\n\ndescribe('Unit tests for questions router', () => {\n // Clear all mocks after each test\n afterEach(() => {\n jest.clearAllMocks();\n });\n\n describe('READ', () => {\n // Mock question data\n const mockQuestions = [\n {\n id: 1,\n questionText: 'What is your favorite color?',\n htmlName: 'favoriteColor',\n answers: {\n answerOneText: 'Red',\n answerTwoText: 'Blue',\n answerThreeText: 'Green',\n answerFourText: 'Yellow',\n },\n },\n {\n id: 2,\n questionText: 'What is your favorite food?',\n htmlName: 'favoriteFood',\n answers: {\n answerOneText: 'Pizza',\n answerTwoText: 'Cheeseburger',\n answerThreeText: 'Sushi',\n answerFourText: 'Chicken',\n },\n },\n ];\n\n it('should return all questions with GET /api/questions', async (done) => {\n // Mock the Question.find() method\n Question.find.mockResolvedValue(mockQuestions);\n\n // Mock the request to the API\n const response = await request.get('/api/questions');\n\n // Tests\n expect(Question.find).toHaveBeenCalled();\n expect(response.status).toBe(200);\n expect(response.body).toEqual(mockQuestions);\n\n // Marks completion of tests\n done();\n });\n\n it('should return 400 status code when there is an error with GET /api/questions', async (done) => {\n // Mock the error thrown when find method is called\n const error = new Error('Database error');\n Question.find.mockRejectedValue(error);\n\n // Mock console log function\n const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation(() => {});\n\n // Mock the request to the API\n const response = await request.get('/api/questions');\n\n // Tests\n expect(Question.find).toHaveBeenCalled();\n expect(consoleLogSpy).toHaveBeenCalledWith(error);\n expect(response.status).toBe(400);\n\n // Clean up and restores original console log function\n consoleLogSpy.mockRestore();\n // Marks completion of tests\n done();\n });\n\n it('should return a specific question with GET /api/questions/:id', async (done) => {\n // Mock the Question.findById() method\n const mockQuestion = mockQuestions[0];\n const { id } = mockQuestion;\n Question.findById.mockResolvedValue(mockQuestion);\n\n // Mock the request to the API\n const response = await request.get(`/api/questions/${id}`);\n\n // Tests\n expect(Question.findById).toHaveBeenCalledWith(`${id}`);\n expect(response.status).toBe(200);\n expect(response.body).toEqual(mockQuestion);\n\n // Marks completion of tests\n done();\n });\n\n it('should return 400 status code when there is an error with GET /api/questions/:id', async (done) => {\n // Mock user id\n const id = mockQuestions[0].id;\n\n // Mock the error when findById method is called\n const error = new Error('Database error');\n Question.findById.mockRejectedValue(error);\n\n // Mock console log function\n const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation(() => {});\n\n // Mock the request to the API\n const response = await request.get(`/api/questions/${id}`);\n\n // Tests\n expect(Question.findById).toHaveBeenCalledWith(`${id}`);\n expect(consoleLogSpy).toHaveBeenCalledWith(error);\n expect(response.status).toBe(400);\n\n // Clean up and restores original console log function\n consoleLogSpy.mockRestore();\n // Marks completion of tests\n done();\n });\n });\n\n describe('CREATE', () => {\n it('should create a new question with POST /api/questions/', async (done) => {\n // Mock the Question.create() method\n const newQuestion = {\n id: 3,\n questionText: 'What is your favorite animal?',\n htmlName: 'favoriteAnimal',\n answers: {\n answerOneText: 'Dog',\n answerTwoText: 'Cat',\n answerThreeText: 'Bird',\n answerFourText: 'Fish',\n },\n };\n\n // Mock Question.create method\n Question.create.mockResolvedValue(newQuestion);\n\n // Mock the request to the API\n const response = await request.post('/api/questions/').send(newQuestion);\n\n // Tests\n expect(Question.create).toHaveBeenCalledWith(newQuestion);\n expect(response.status).toBe(201);\n\n // Marks completion of tests\n done();\n });\n\n it('should return 400 status code when there is an error with POST /api/questions', async (done) => {\n // Mock the error thrown when create method is called\n const error = new Error('Database error');\n Question.create.mockRejectedValue(error);\n\n // Mock console log function\n const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation(() => {});\n\n // Mock the request to the API\n const response = await request.post('/api/questions');\n\n // Tests\n expect(Question.create).toHaveBeenCalled();\n expect(consoleLogSpy).toHaveBeenCalledWith(error);\n expect(response.status).toBe(400);\n\n // Clean up and restores original console log function\n consoleLogSpy.mockRestore();\n // Marks completion of tests\n done();\n });\n });\n});\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/routers/recurringEvents.router.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/routers/recurringEvents.router.test.js", + "messages": [ + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 2, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 2, + "endColumn": 5 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 3, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 3, + "endColumn": 5 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 4, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 4, + "endColumn": 5 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 5, + "column": 17, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 5, + "endColumn": 21 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 7, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 7, + "endColumn": 5 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 29, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 29, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'afterEach' is not defined.", + "line": 57, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 57, + "endColumn": 12 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 57, + "column": 19, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 57, + "endColumn": 23 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 59, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 59, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 60, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 60, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 63, + "column": 17, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 63, + "endColumn": 21 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 64, + "column": 21, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 64, + "endColumn": 25 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 71, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 71, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 72, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 72, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 73, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 73, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 74, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 74, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 75, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 75, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 78, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 78, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 90, + "column": 29, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 90, + "endColumn": 33 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 95, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 95, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 96, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 96, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 102, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 102, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 105, + "column": 19, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 105, + "endColumn": 23 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 111, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 111, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 112, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 112, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 113, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 113, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 116, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 116, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 126, + "column": 29, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 126, + "endColumn": 33 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 131, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 131, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 132, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 132, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 133, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 133, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 139, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 139, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 150, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 150, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 151, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 151, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 152, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 152, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 155, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 155, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 163, + "column": 29, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 163, + "endColumn": 33 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 168, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 168, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 169, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 169, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 170, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 170, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 177, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 177, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 191, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 191, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 199, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 199, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 200, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 200, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 201, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 201, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 202, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 202, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 204, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 204, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 205, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 205, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 209, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 209, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 210, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 210, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 232, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 232, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 233, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 233, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 234, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 234, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 235, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 235, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 237, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 237, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 238, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 238, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 242, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 242, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 243, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 243, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 255, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 255, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 256, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 256, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 257, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 257, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 258, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 258, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 260, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 260, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 261, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 261, + "endColumn": 13 + } + ], + "suppressedMessages": [], + "errorCount": 64, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "// Mock model, controller, middleware, and cors\njest.mock('../models/recurringEvent.model');\njest.mock('../controllers/recurringEvent.controller');\njest.mock('../middleware/auth.middleware', () => ({\n verifyCookie: jest.fn((req, res, next) => next()),\n}));\njest.mock('cors', () => () => (req, res, next) => {\n res.header('Access-Control-Allow-Origin', '*');\n res.header('Access-Control-Allow-Methods', 'GET,POST,PUT,DELETE,OPTIONS');\n res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');\n next();\n});\n\nconst { RecurringEvent } = require('../models/recurringEvent.model');\nconst { RecurringEventController } = require('../controllers/');\n\n// Import Recurring Events Router after setting up mocks\nconst recurringEventsRouter = require('./recurringEvents.router');\nconst express = require('express');\nconst testapp = express();\n// Allow for body parsing of JSON data\ntestapp.use(express.json());\n// Allow for body parsing of HTML data\ntestapp.use(express.urlencoded({ extended: false }));\ntestapp.use('/api/recurringevents', recurringEventsRouter);\nconst supertest = require('supertest');\nconst request = supertest(testapp);\n\ndescribe('Unit tests for RecurringEvents router', () => {\n // Create mock recurring events\n const mockEvents = [\n {\n id: 1,\n name: 'mockEvent1',\n location: {\n city: 'city1',\n state: 'state1',\n country: 'country1',\n },\n project: 'project1',\n videoConferenceLink: 'zoom-link1',\n },\n {\n id: 2,\n name: 'mockEvent2',\n location: {\n city: 'city1',\n state: 'state1',\n country: 'country1',\n },\n project: 'project2',\n videoConferenceLink: 'zoom-link2',\n },\n ];\n\n // Clear all mocks after each test\n afterEach(() => jest.clearAllMocks());\n\n describe('READ', () => {\n it('should return a list of events with GET /api/recurringevents/', async () => {\n // Mock find method with chaining of select and populate methods\n RecurringEvent.find.mockReturnValue({\n select: jest.fn().mockReturnValue({\n populate: jest.fn().mockResolvedValue(mockEvents),\n }),\n });\n\n const response = await request.get('/api/recurringevents/');\n\n // Tests\n expect(RecurringEvent.find().select).toHaveBeenCalledWith('-videoConferenceLink');\n expect(RecurringEvent.find().select().populate).toHaveBeenCalledWith('project');\n expect(response.headers['access-control-allow-origin']).toBe('*');\n expect(response.status).toBe(200);\n expect(response.body).toEqual(mockEvents);\n });\n\n it('should return status code 400 when there is an error with GET /api/recurringevents/', async () => {\n // Mock the test error\n const error = new Error('test error');\n\n // Mock db methods\n RecurringEvent.find.mockImplementationOnce(() => ({\n select: () => ({\n populate: () => Promise.reject(error),\n }),\n }));\n\n // Creates a spy on console log function to track any calls during test\n const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation(() => {});\n\n const response = await request.get('/api/recurringevents/');\n\n // Tests\n expect(consoleLogSpy).toHaveBeenCalledWith(error);\n expect(response.status).toBe(400);\n\n // Clear console log mock and restore its original function\n consoleLogSpy.mockRestore();\n });\n\n it('should return a list of events with GET /api/recurringevents/internal', async () => {\n // Mock Mongoose method\n RecurringEvent.find.mockReturnValue({\n populate: jest.fn().mockResolvedValue(mockEvents),\n });\n\n const response = await request.get('/api/recurringevents/internal');\n\n // Tests\n expect(RecurringEvent.find().populate).toHaveBeenCalledWith('project');\n expect(response.status).toBe(200);\n expect(response.body).toEqual(mockEvents);\n });\n\n it('should return status code 400 when there is an error with GET /api/recurringevents/internal', async () => {\n // Mock the test error\n const error = new Error('test error');\n\n // Mock error in calling find method\n RecurringEvent.find.mockImplementationOnce(() => ({\n populate: () => Promise.reject(error),\n }));\n\n // Creates a spy on console log function to track any calls during test\n const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation(() => {});\n\n const response = await request.get('/api/recurringevents/internal');\n\n // Tests\n expect(RecurringEvent.find).toHaveBeenCalled();\n expect(consoleLogSpy).toHaveBeenCalledWith(error);\n expect(response.status).toBe(400);\n\n // Clear console log mock and restore its original function\n consoleLogSpy.mockRestore();\n });\n\n it('should return a single event by id with GET /api/recurringevents/:id', async () => {\n // Mock event\n const mockEvent = mockEvents[0];\n const { id } = mockEvent;\n\n // Mock findById method\n RecurringEvent.findById.mockResolvedValue(mockEvent);\n\n const response = await request.get(`/api/recurringevents/${id}`);\n\n // Tests\n expect(RecurringEvent.findById).toHaveBeenCalledWith(`${id}`);\n expect(response.status).toBe(200);\n expect(response.body).toEqual(mockEvent);\n });\n\n it('should return status code 400 when there is an error with GET /api/recurringevents/:id', async () => {\n // Mock the test error\n const error = new Error('test error');\n\n // Mock findById method to return a rejected Promise to trigger catch block\n RecurringEvent.findById.mockRejectedValue(error);\n\n // Creates a spy on console log function to track any calls during test\n const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation(() => {});\n\n const response = await request.get('/api/recurringevents/123');\n\n // Tests\n expect(RecurringEvent.findById).toHaveBeenCalled();\n expect(consoleLogSpy).toHaveBeenCalledWith(error);\n expect(response.status).toBe(400);\n\n // Clear console log mock and restore its original function\n consoleLogSpy.mockRestore();\n });\n });\n\n describe('CREATE', () => {\n // Mock new event\n const newEvent = {\n id: 3,\n name: 'mockEvent3',\n location: {\n city: 'city3',\n state: 'state3',\n country: 'country3',\n },\n project: 'project3',\n videoConferenceLink: 'zoom-link3',\n };\n\n it('should add a new event with POST /api/recurringevents/', async () => {\n RecurringEventController.create.mockImplementationOnce((req, res) => {\n res.status(200).send(newEvent);\n });\n\n const response = await request.post('/api/recurringevents/').send(newEvent);\n\n // Tests\n expect(RecurringEventController.create).toHaveBeenCalledWith(\n expect.objectContaining({ body: newEvent }), // Checks if newEvent was passed\n expect.anything(), // Mock the response object\n expect.anything(), // Mock the next object\n );\n expect(response.status).toBe(200);\n expect(response.body).toEqual(newEvent);\n });\n });\n\n describe('UPDATE', () => {\n it('should update a specific event by id with PATCH /api/recurringevents/:id', async () => {\n // Update to event#1\n const updatedEvent = {\n id: 1,\n name: 'updatedEvent1',\n location: {\n city: 'update city1',\n state: 'update state1',\n country: 'update country1',\n },\n project: 'update project1',\n videoConferenceLink: 'new zoom-link1',\n };\n const { id } = updatedEvent;\n\n RecurringEventController.update.mockImplementationOnce((req, res) => {\n return res.status(200).send(updatedEvent);\n });\n\n const response = await request.patch(`/api/recurringevents/${id}`).send(updatedEvent);\n\n // Tests\n expect(RecurringEventController.update).toHaveBeenCalledWith(\n expect.objectContaining({ body: updatedEvent }), // Checks if newEvent was passed\n expect.anything(), // Mock the response object\n expect.anything(), // Mock the next object\n );\n expect(response.status).toBe(200);\n expect(response.body).toEqual(updatedEvent);\n });\n });\n\n describe('DESTROY', () => {\n it('should delete a specific event by id with DELETE /api/recurringevents/:id', async () => {\n // Mock event to be deleted\n const deleteEvent = mockEvents[0];\n const { id } = deleteEvent;\n\n RecurringEventController.destroy.mockImplementationOnce((req, res) => {\n return res.status(200).send(deleteEvent);\n });\n\n const response = await request.delete(`/api/recurringevents/${id}`);\n\n // Tests\n expect(RecurringEventController.destroy).toHaveBeenCalledWith(\n expect.objectContaining({ params: { RecurringEventId: String(id) } }), // Check for parsing of RecurringEventId\n expect.anything(), // Mock response\n expect.anything(), // Mock next\n );\n expect(response.status).toBe(200);\n expect(response.body).toEqual(deleteEvent);\n });\n });\n});\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/routers/slack.router.js", + "messages": [ + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'cron' is assigned a value but never used.", + "line": 5, + "column": 7, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 5, + "endColumn": 11 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'req' is defined but never used.", + "line": 32, + "column": 24, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 32, + "endColumn": 27 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'res' is defined but never used.", + "line": 32, + "column": 29, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 32, + "endColumn": 32 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'req' is defined but never used.", + "line": 39, + "column": 34, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 39, + "endColumn": 37 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'res' is defined but never used.", + "line": 39, + "column": 39, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 39, + "endColumn": 42 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'findConversation' is defined but never used.", + "line": 43, + "column": 16, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 43, + "endColumn": 32 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'conversationId' is not defined.", + "line": 51, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 51, + "endColumn": 23 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'conversationId' is not defined.", + "line": 53, + "column": 49, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 53, + "endColumn": 63 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'id' is defined but never used.", + "line": 62, + "column": 31, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 62, + "endColumn": 33 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'text' is defined but never used.", + "line": 62, + "column": 35, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 62, + "endColumn": 39 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'findProject' is defined but never used.", + "line": 102, + "column": 16, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 102, + "endColumn": 27 + } + ], + "suppressedMessages": [], + "errorCount": 11, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "const express = require(\"express\");\n\nconst router = express.Router();\nconst { App } = require(\"@slack/bolt\");\nconst cron = require(\"node-cron\");\nconst { Event } = require('../models/event.model');\nconst { Project } = require('../models/project.model');\n\n// https://api.slack.com/web\n\nlet app = null;\n\nif (process.env.NODE_ENV !== 'test') {\n app = new App({\n token: process.env.SLACK_BOT_TOKEN,\n signingSecret: process.env.SLACK_SIGNING_SECRET,\n });\n}\n\n// Checks DB every monday (1) for slack messages to schedule this week\n// cron.schedule(\"* * * * 1\", () => {});\n\n// TODO: Refactor this server out of the router. This server instance is breaking the tests.\nif (process.env.NODE_ENV !== \"test\") {\n (async () => {\n await app.start(4050);\n console.log(\"Connected to Slack\");\n })();\n}\n\n// Finds Id number of channel\nrouter.get(\"/findId\", (req, res) => {\n publishMessage();\n findEvent();\n // findProject();\n});\n\n// uses Id number to send message to said channel\nrouter.post(\"/postMeeting/:id\", (req, res) => {\n publishMessage1();\n});\n\nasync function findConversation(name) {\n try {\n const result = await app.client.conversations.list({\n token: process.env.SLACK_BOT_TOKEN,\n });\n\n for (let channel of result.channels) {\n if (channel.name === name) {\n conversationId = channel.id;\n\n console.log(`Found conversation ID: ${ conversationId}`);\n break;\n }\n }\n } catch (error) {\n console.error(error);\n }\n}\n\nasync function publishMessage(id, text) {\n try {\n const result = await app.client.chat.postMessage({\n token: process.env.SLACK_BOT_TOKEN,\n channel: process.env.SLACK_CHANNEL_ID,\n text: \"Slack Message Publish\",\n });\n\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n}\n\nasync function publishMessage1(id, text) {\n try {\n const result = await app.client.chat.postMessage({\n token: process.env.SLACK_BOT_TOKEN,\n channel: id,\n text: text,\n });\n\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n}\n\nasync function findEvent(req, res) {\n Event.find({})\n .then((events) => {\n console.log(\"EVENTS\", events);\n return res.status(200).send(events);\n })\n .catch((err) => {\n console.log(err);\n return res.sendStatus(400)\n });\n}\n\nasync function findProject(req, res) {\n Project.find({})\n .then((project) => {\n project.forEach((cur) => {\n console.log(\"PROJECT\", cur.name);\n });\n return res.status(200).send(project);\n })\n .catch((err) => {\n console.log(err);\n return res.sendStatus(400);\n });\n}\nmodule.exports = router;\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/routers/success.router.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/routers/users.router.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/routers/users.router.test.js", + "messages": [ + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 2, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 2, + "endColumn": 5 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 17, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 17, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'afterEach' is not defined.", + "line": 31, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 31, + "endColumn": 14 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 32, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 32, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 35, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 35, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 36, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 36, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 50, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 50, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 51, + "column": 17, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 51, + "endColumn": 23 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 52, + "column": 17, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 52, + "endColumn": 23 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 53, + "column": 17, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 53, + "endColumn": 23 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 55, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 55, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 56, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 56, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 62, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 62, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 63, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 63, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 76, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 76, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 77, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 77, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 78, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 78, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 83, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 83, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 96, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 96, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 97, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 97, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 98, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 98, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 103, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 103, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 116, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 116, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 117, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 117, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 118, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 118, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 123, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 123, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 136, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 136, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 137, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 137, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 138, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 138, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 143, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 143, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 156, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 156, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 157, + "column": 17, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 157, + "endColumn": 23 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 158, + "column": 17, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 158, + "endColumn": 23 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 159, + "column": 17, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 159, + "endColumn": 23 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 161, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 161, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 162, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 162, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 168, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 168, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 169, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 169, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 183, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 183, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 184, + "column": 17, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 184, + "endColumn": 23 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 185, + "column": 17, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 185, + "endColumn": 23 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 186, + "column": 17, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 186, + "endColumn": 23 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 188, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 188, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 189, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 189, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 195, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 195, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 196, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 196, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 209, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 209, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 210, + "column": 17, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 210, + "endColumn": 23 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 211, + "column": 17, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 211, + "endColumn": 23 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 212, + "column": 17, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 212, + "endColumn": 23 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 214, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 214, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 215, + "column": 13, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 215, + "endColumn": 19 + } + ], + "suppressedMessages": [], + "errorCount": 52, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "// Setup mocks for UserController\njest.mock('../controllers/user.controller');\nconst { UserController } = require('../controllers');\n\n// Must import usersRouter after setting up mocks for UserController\nconst usersRouter = require('./users.router');\nconst express = require('express');\nconst supertest = require('supertest');\n\n// Setup testapp with just usersRouter which calls mocked UserController\nconst testapp = express();\ntestapp.use(express.json());\ntestapp.use(express.urlencoded({ extended: false }));\ntestapp.use('/api/users', usersRouter);\nconst request = supertest(testapp);\n\ndescribe('Unit Tests for userRouter', () => {\n // Mocked user data\n const mockUser = {\n name: {\n firstName: 'test',\n lastName: 'user',\n },\n email: 'newtest@test.com',\n };\n const mockId = '12345';\n const mockUpdatedEmail = {\n email: 'newtest@test.com',\n };\n\n afterEach(() => {\n jest.clearAllMocks();\n });\n\n describe('CREATE', () => {\n it('should create a User through the UserController', async (done) => {\n //Setup\n //Mock the UserController function that this route calls with expected results\n UserController.create.mockImplementationOnce(\n (req, res) => { return res.status(201).send(mockUser) }\n );\n \n //Functionality\n //Post mockUser to CREATE API Endpoint\n const response = await request\n .post('/api/users/')\n .send(mockUser);\n\n //Test\n expect(UserController.create).toHaveBeenCalledWith(\n expect.objectContaining({body: mockUser}),\n expect.anything(), // Mock the response object\n expect.anything() // Mock the next function\n );\n expect(response.status).toBe(201);\n expect(response.body).toEqual(mockUser);\n\n done();\n });\n });\n \n describe('READ', () => {\n it('should get a list of Users with with GET to /api/users/ through UserController', async (done) => {\n //Setup\n //Mock the UserController function that this route calls with expected results\n UserController.user_list.mockImplementationOnce(\n (req, res) => { return res.status(200).send([mockUser]) }\n );\n \n //Functionality\n //Get list of all users from READ API Endpoint\n const response = await request\n .get('/api/users/');\n\n //Test\n expect(UserController.user_list).toHaveBeenCalled();\n expect(response.status).toBe(200);\n expect(response.body[0]).toEqual(mockUser);\n\n done();\n });\n\n it('should get a specific User by param with GET to /api/users?email= through UserController', async (done) => {\n //Setup\n //Mock the UserController function that this route calls with expected results\n UserController.user_list.mockImplementationOnce(\n (req, res) => { return res.status(200).send([mockUser]) }\n );\n \n //Functionality\n //Get a user with a specific email using a query param to READ API Endpoint\n const response = await request\n .get('/api/users?email=newtest@test.com');\n\n //Test\n expect(UserController.user_list).toHaveBeenCalled();\n expect(response.status).toBe(200);\n expect(response.body[0]).toEqual(mockUser);\n\n done();\n });\n \n it('should get a list of Users with accessLevel of admin or superadmin with GET to /api/users/admins through UserController', async (done) => {\n //Setup\n //Mock the UserController function that this route calls with expected results\n UserController.admin_list.mockImplementationOnce(\n (req, res) => { return res.status(200).send([mockUser]) }\n );\n \n //Functionality\n //Get a list of admins and superadmins from READ API Endpoint for admins\n const response = await request\n .get('/api/users/admins');\n\n //Test\n expect(UserController.admin_list).toHaveBeenCalled();\n expect(response.status).toBe(200);\n expect(response.body[0]).toEqual(mockUser);\n\n done();\n });\n \n it('should get a list of Users with the ability to manage projects with GET to /api/users/projectManagers through UserController', async (done) => {\n //Setup\n //Mock the UserController function that this route calls with expected results\n UserController.projectLead_list.mockImplementationOnce(\n (req, res) => { return res.status(200).send([mockUser]) }\n );\n \n //Functionality\n //Get a list of project leads and admins from READ API Endpoint for project leads\n const response = await request\n .get('/api/users/projectManagers');\n\n //Test\n expect(UserController.projectLead_list).toHaveBeenCalled();\n expect(response.status).toBe(200);\n expect(response.body[0]).toEqual(mockUser);\n\n done();\n });\n \n it('should get a specific User by UserId with GET to /api/users/:UserId through UserController', async (done) => {\n //Setup\n //Mock the UserController function that this route calls with expected results\n UserController.user_by_id.mockImplementationOnce(\n (req, res) => { return res.status(200).send(mockUser) }\n );\n \n //Functionality\n //Get a specific user from READ API Endpoint for specific UUIDs\n const response = await request\n .get(`/api/users/${mockId}`);\n\n //Test\n expect(UserController.user_by_id).toHaveBeenCalledWith(\n expect.objectContaining({params: {UserId: mockId}}),\n expect.anything(), // Mock the response object\n expect.anything() // Mock the next function\n );\n expect(response.status).toBe(200);\n expect(response.body).toEqual(mockUser);\n\n done();\n });\n });\n \n describe('UPDATE', () => {\n it('should update a User with PATCH to /api/users/:UserId through UserController', async (done) => {\n //Setup\n //Mock the UserController function that this route calls with expected results\n UserController.update.mockImplementationOnce(\n (req, res) => { return res.status(200).send(mockUser) }\n );\n \n //Functionality\n //Patch a user with a specific id by sending new user data to UPDATE API Endpoint\n const response = await request\n .patch(`/api/users/${mockId}`)\n .send(mockUpdatedEmail);\n\n //Test\n expect(UserController.update).toHaveBeenCalledWith(\n expect.objectContaining({params: {UserId: mockId}}),\n expect.anything(), // Mock the response object\n expect.anything() // Mock the next function\n );\n expect(response.status).toBe(200);\n expect(response.body).toEqual(mockUser);\n\n done();\n });\n });\n \n describe('DELETE', () => {\n it('should delete a specific user by Id with DELETE /api/users/:UserId through UserController', async (done) => {\n //Setup\n //Mock the UserController function that this route calls with expected results\n UserController.delete.mockImplementationOnce(\n (req, res) => { return res.status(200).send(mockUser) }\n );\n \n //Delete user with a specific id via a request to DELETE API Endpoint\n const response = await request\n .delete(`/api/users/${mockId}`)\n .send(mockUpdatedEmail);\n\n //Test\n expect(UserController.delete).toHaveBeenCalledWith(\n expect.objectContaining({params: {UserId: mockId}}),\n expect.anything(), // Mock the response object\n expect.anything() // Mock the next function\n );\n expect(response.status).toBe(200);\n expect(response.body).toEqual(mockUser);\n\n done();\n });\n });\n});", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/server.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/setup-test.js", + "messages": [ + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'removeAllCollections' is defined but never used.", + "line": 8, + "column": 16, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 8, + "endColumn": 36 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'beforeAll' is not defined.", + "line": 38, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 38, + "endColumn": 14 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'afterAll' is not defined.", + "line": 55, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 55, + "endColumn": 13 + } + ], + "suppressedMessages": [], + "errorCount": 3, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "// test-setup.js\nconst mongoose = require(\"mongoose\");\nmongoose.set(\"useCreateIndex\", true);\nmongoose.promise = global.Promise;\n\nconst { MongoMemoryServer } = require(\"mongodb-memory-server\");\n\nasync function removeAllCollections() {\n const mongooseCollections = mongoose.connection.collections;\n const collections = Object.keys(mongooseCollections);\n for (const collectionName of collections) {\n const collection = mongoose.connection.collections[collectionName];\n collection.deleteMany();\n }\n}\n\nasync function dropAllCollections() {\n const collections = Object.keys(mongoose.connection.collections);\n for (const collectionName of collections) {\n const collection = mongoose.connection.collections[collectionName];\n try {\n await collection.drop();\n } catch (error) {\n // Sometimes this error happens, but you can safely ignore it\n if (error.message === \"ns not found\") return;\n // This error occurs when you use it.todo. You can\n // safely ignore this error too\n if (error.message.includes(\"a background operation is currently running\"))\n return;\n console.log(error.message);\n }\n }\n}\nlet mongoServer;\nmodule.exports = {\n setupIntegrationDB(databaseName) {\n // Connect to Mongoose\n beforeAll(async () => {\n mongoServer = new MongoMemoryServer({\n instance: { dbName: databaseName },\n });\n const mongoUri = await mongoServer.getUri();\n const opts = {\n useNewUrlParser: true,\n useFindAndModify: false,\n useCreateIndex: true,\n useUnifiedTopology: true,\n };\n await mongoose.connect(mongoUri, opts, (err) => {\n if (err) console.error(err);\n });\n });\n\n // Disconnect Mongoose\n afterAll(async () => {\n await dropAllCollections();\n await mongoose.connection.close();\n await mongoServer.stop();\n });\n },\n};\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/test/old-tests/auth.router.test.js", + "messages": [ + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 13, + "column": 22, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 13, + "endColumn": 26 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 14, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 14, + "endColumn": 5 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'beforeEach' is not defined.", + "line": 18, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 18, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 28, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 28, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 29, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 29, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 39, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 39, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 46, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 46, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 47, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 47, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 48, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 48, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 52, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 52, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 54, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 54, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 55, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 55, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 59, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 59, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 72, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 72, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 76, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 76, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 77, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 77, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 90, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 90, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 93, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 93, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 99, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 99, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 121, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 121, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 126, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 126, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 127, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 127, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 146, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 146, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 150, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 150, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 151, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 151, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 172, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 172, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 175, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 175, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 193, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 193, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 196, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 196, + "endColumn": 11 + } + ], + "suppressedMessages": [], + "errorCount": 29, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "const supertest = require('supertest');\nconst app = require('../app');\nconst request = supertest(app);\n\nconst { setupDB } = require('../setup-test');\nsetupDB('api-auth');\n\nconst { CONFIG_AUTH } = require('../config/');\nconst { User } = require('../models');\n\n\n// Create mock for EmailController\nconst sendMailMock = jest.fn()\njest.mock('../controllers/email.controller');\nconst mockEmailController = require('../controllers/email.controller');\nmockEmailController.sendLoginLink.mockReturnValue({ sendMail: sendMailMock });\n\nbeforeEach(() => {\n sendMailMock.mockClear();\n mockEmailController.sendLoginLink.mockClear();\n});\n\nconst headers = {};\nheaders['x-customrequired-header'] = CONFIG_AUTH.CUSTOM_REQUEST_HEADER;\nheaders.Accept = 'application/json';\n\n// API Tests\ndescribe('CREATE User', () => {\n test('Create user with POST to /users', async () => {\n // Test Data\n const submittedData = {\n name: { firstName: 'test_first', lastName: 'test_last' },\n email: 'test@test.com',\n };\n\n // Add a user using the API.\n const res = await request.post('/api/users').send(submittedData).set(headers);\n\n expect(res.status).toBe(201);\n\n // Retrieve and compare the the User values using the DB.\n const databaseUserQuery = await User.find();\n\n const databaseUser = databaseUserQuery[0];\n\n expect(databaseUserQuery.length).toBeGreaterThanOrEqual(1);\n expect(databaseUser.name.firstName).toBe(submittedData.name.firstName);\n expect(databaseUser.name.lastName).toBe(submittedData.name.lastName);\n\n // Retrieve and compare the User values using the API.\n const response = await request.get('/api/users').set(headers);\n expect(response.statusCode).toBe(200);\n const APIData = response.body[0];\n expect(APIData.name.firstName).toBe(submittedData.name.firstName);\n expect(APIData.name.lastName).toBe(submittedData.name.lastName);\n\n });\n\n test('Create user with POST to /auth/signup', async () => {\n // setupDBRoles();\n // Test Data\n const goodUserData = {\n name: { firstName: 'testname', lastName: 'testlast' },\n email: 'test@test.com',\n };\n\n const res = await request\n .post('/api/auth/signup')\n .send(goodUserData)\n .set(headers);\n\n expect(res.status).toBe(201);\n });\n});\n\ndescribe('SIGNUP Validation', () => {\n test('Invalid data to /api/auth/signup returns 403', async () => {\n // Test Data\n const badUserData = {\n firstName: 'test_first',\n lastName: 'test_last',\n email: 'test@test.com',\n };\n\n const res = await request\n .post('/api/auth/signup')\n .send(badUserData)\n .set(headers);\n\n expect(res.status).toBe(403);\n const errorMessage = JSON.parse(res.text);\n\n expect(errorMessage.errors).toEqual([\n { msg: 'Invalid value', param: 'name.firstName', location: 'body' },\n { msg: 'Invalid value', param: 'name.lastName', location: 'body' },\n ]);\n });\n\n test('Existing user returns 400', async () => {\n // Test Data\n const userOneWithSameEmail = {\n name: { firstName: 'one', lastName: 'two' },\n email: 'test@test.com',\n };\n\n const userTwoWithSameEmail = {\n name: { firstName: 'three', lastName: 'four' },\n email: 'test@test.com',\n };\n\n await request\n .post('/api/auth/signup')\n .send(userOneWithSameEmail)\n .set(headers);\n\n const res2 = await request\n .post('/api/auth/signup')\n .send(userTwoWithSameEmail)\n .set(headers);\n\n expect(res2.status).toBe(400);\n });\n\n});\n\ndescribe('SIGNIN User', () => {\n test('User can signin and returns 200', async () => {\n // Create user in DB\n const goodUserData = {\n name: {\n firstName: 'Free',\n lastName: 'Mason',\n },\n email: 'test@test.com',\n accessLevel: 'admin',\n };\n await User.create(goodUserData);\n\n // POST to the DB with that same data.\n const res = await request\n .post('/api/auth/signin')\n .send(goodUserData)\n .set(headers)\n .set('Origin', 'localhost');\n\n expect(res.status).toBe(200);\n });\n});\n\ndescribe('SIGNIN Validation', () => {\n test('Non admin user returns 401', async () => {\n // Test Data\n\n // Create user in DB\n const notValidPermission = {\n name: {\n firstName: 'Free',\n lastName: 'Mason',\n },\n email: 'test@test.com',\n accessLevel: 'user',\n };\n await User.create(notValidPermission);\n\n // POST to the DB with that same data.\n const res = await request\n .post('/api/auth/signin')\n .send(notValidPermission)\n .set(headers)\n .set('Origin', 'localhost');\n\n expect(res.status).toBe(401);\n });\n\n test('A non-valid email return 403', async () => {\n // Create user in DB\n const notValidEmailPayload = {\n name: {\n firstName: 'Free',\n lastName: 'Mason',\n },\n email: 'test',\n accessLevel: 'admin',\n };\n await User.create(notValidEmailPayload);\n\n // POST to the DB with that same data.\n const res = await request\n .post('/api/auth/signin')\n .send(notValidEmailPayload)\n .set(headers);\n\n expect(res.status).toBe(403);\n const errorMessage = JSON.parse(res.text);\n\n expect(errorMessage.errors).toEqual([\n {\n value: 'test',\n msg: 'Invalid email',\n param: 'email',\n location: 'body',\n },\n ]);\n });\n})\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/test/old-tests/events.router.test.js", + "messages": [ + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 17, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 17, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 18, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 18, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 29, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 29, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 34, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 34, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 35, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 35, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 40, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 40, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 41, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 41, + "endColumn": 7 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'res' is assigned a value but never used.", + "line": 49, + "column": 11, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 49, + "endColumn": 14 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 54, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 54, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 55, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 55, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 59, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 59, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 61, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 61, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 64, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 64, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 96, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 96, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 98, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 98, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 104, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 104, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 105, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 105, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 116, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 116, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 127, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 127, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 133, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 133, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 134, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 134, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 145, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 145, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 149, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 149, + "endColumn": 11 + } + ], + "suppressedMessages": [], + "errorCount": 23, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "const supertest = require(\"supertest\");\nconst app = require(\"../app\");\nconst CONFIG = require('../config/auth.config');\n\nconst request = supertest(app);\n\nconst { setupDB } = require(\"../setup-test\");\nsetupDB(\"api-events\");\n\nconst { Event } = require('../models');\n\nconst headers = {};\nheaders['x-customrequired-header'] = CONFIG.CUSTOM_REQUEST_HEADER;\nheaders.Accept = 'application/json';\n\n// API Tests\ndescribe('CREATE', () => {\n test('Create Event', async (done) => {\n // Test Data\n const submittedData = {\n name: 'eventName',\n };\n\n // Submit an event\n const res = await request\n .post('/api/events/')\n .set(headers)\n .send(submittedData);\n expect(res.status).toBe(201);\n\n // Retrieve that event\n const databaseEventQuery = await Event.find();\n const databaseEvent = databaseEventQuery[0];\n expect(databaseEventQuery.length).toBeGreaterThanOrEqual(1);\n expect(databaseEvent.name).toBe(submittedData.name);\n done();\n });\n});\n\ndescribe('READ', () => {\n test('GET Events list', async (done) => {\n // Test Data\n const submittedData = {\n createdDate: '2020-05-20T21:16:44.498Z',\n checkinReady: true,\n };\n \n // Add an event with a project using the API.\n const res = await request.post(\"/api/events\").send(submittedData).set(headers);\n\n // Retrieve and compare the the Event values using the DB.\n const databaseEventQuery = await Event.find();\n const databaseEvent = databaseEventQuery[0];\n expect(databaseEventQuery.length).toBeGreaterThanOrEqual(1);\n expect(databaseEvent.createdDate).toStrictEqual(new Date(submittedData.createdDate));\n\n // Retrieve and compare the the values using the API.\n const response = await request.get('/api/events/').set(headers);\n expect(response.statusCode).toBe(200);\n const APIData = response.body[0];\n expect(APIData.createdDate).toBe(submittedData.createdDate);\n done();\n });\n test('GET Event by ID', async (done) => {\n // Test Data\n const submittedData = {\n name: 'eventName',\n location: {\n // should we include address here?\n city: 'Los Angeles',\n state: 'California',\n country: 'USA',\n },\n hacknight: 'Online', // DTLA, Westside, South LA, Online\n eventType: 'Workshop', // Project Meeting, Orientation, Workshop\n description: 'A workshop to do stuff',\n date: 1594023390039,\n startTime: 1594023390039, // start date and time of the event\n endTime: 1594023390039, // end date and time of the event\n hours: 2, // length of the event in hours\n createdDate: 1594023390039, // date/time event was created\n updatedDate: 1594023390039, // date/time event was last updated\n checkInReady: false, // is the event open for check-ins?\n owner: {\n ownerId: 33, // id of user who created event\n },\n };\n\n // Create Event by DB\n const dbCreatedevent = await Event.create(submittedData);\n const dbCreatedeventId = dbCreatedevent.id;\n const dbCreatedEventIdURL = `/api/events/${dbCreatedeventId}`;\n\n // Retrieve and compare the the values using the API.\n const response = await request.get(dbCreatedEventIdURL).set(headers);\n expect(response.statusCode).toBe(200);\n const apiRetrievedEvent = await response.body;\n expect(apiRetrievedEvent._id).toBe(dbCreatedeventId);\n\n done();\n });\n});\n\ndescribe('UPDATE', () => {\n test('Update Event by ID with PATCH', async (done) => {\n // Test Data\n const submittedData = {\n name: 'originalEventName',\n };\n\n // Submit an event\n const res = await request\n .post('/api/events/')\n .set(headers)\n .send(submittedData);\n expect(res.status).toBe(201);\n\n const updatedDataPayload = {\n name: 'updateEventName',\n };\n\n // Update the event\n const res2 = await request\n .patch(`/api/events/${res.body._id}`)\n .set(headers)\n .send(updatedDataPayload);\n expect(res2.status).toBe(200);\n\n done();\n });\n});\n\ndescribe('DELETE', () => {\n test('Delete Event by ID with DELETE', async (done) => {\n // Test Data\n const submittedData = {\n name: 'eventName',\n };\n\n // Submit an event\n const res = await request\n .post('/api/events/')\n .set(headers)\n .send(submittedData);\n expect(res.status).toBe(201);\n\n // Delete the event\n const res2 = await request.delete(`/api/events/${res.body._id}/`).set(headers);\n expect(res2.status).toBe(200);\n\n done();\n });\n});\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/test/old-tests/projects.router.test.js", + "messages": [ + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'Project' is assigned a value but never used.", + "line": 11, + "column": 9, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 11, + "endColumn": 16 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 22, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 22, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'beforeAll' is not defined.", + "line": 23, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 23, + "endColumn": 12 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 41, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 41, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 52, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 52, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 56, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 56, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 68, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 68, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 73, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 73, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 74, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 74, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 86, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 86, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 90, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 90, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 93, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 93, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 98, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 98, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'beforeAll' is not defined.", + "line": 99, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 99, + "endColumn": 12 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 117, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 117, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 129, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 129, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 140, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 140, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 145, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 145, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 148, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 148, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 160, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 160, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 172, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 172, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 178, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 178, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 181, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 181, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 186, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 186, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'beforeAll' is not defined.", + "line": 187, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 187, + "endColumn": 12 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 205, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 205, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 217, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 217, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 222, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 222, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 225, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 225, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 237, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 237, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 243, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 243, + "endColumn": 11 + } + ], + "suppressedMessages": [], + "errorCount": 31, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "const supertest = require('supertest');\nconst app = require('../app');\nconst request = supertest(app);\nconst jwt = require('jsonwebtoken');\nconst { CONFIG_AUTH } = require('../config');\n\n\nconst { setupDB } = require('../setup-test');\nsetupDB('api-projects');\n\nconst { Project, User } = require('../models');\nconst CONFIG = require('../config/auth.config');\n\nconst headers = {};\nheaders['x-customrequired-header'] = CONFIG.CUSTOM_REQUEST_HEADER;\nheaders.Accept = 'application/json';\nheaders.authorization = 'Bearer sometoken';\n\nlet token;\n\n\ndescribe('CREATE', () => {\n beforeAll( async () => {\n const submittedData = {\n name: {\n firstName: 'test',\n lastName: 'user',\n },\n email: 'newtest@test.com',\n };\n const user = await User.create(submittedData);\n const auth_origin = 'TEST';\n token = jwt.sign(\n { id: user.id, role: user.accessLevel, auth_origin },\n CONFIG_AUTH.SECRET,\n {\n expiresIn: `${CONFIG_AUTH.TOKEN_EXPIRATION_SEC}s`,\n },\n );\n })\n test('Create a Project with POST to /api/projects/ without token', async (done) => {\n // Test Data\n const submittedData = {\n name: 'projectName',\n };\n\n // Submit a project\n const res = await request\n .post('/api/projects/')\n .set(headers)\n .send(submittedData);\n expect(res.status).toBe(401);\n done();\n });\n\n test('Create a Project with POST to /api/projects/', async (done) => {\n // Test Data\n const submittedData = {\n name: 'projectName',\n };\n\n // Submit a project\n const res = await request\n .post('/api/projects/')\n .set(headers)\n .set('Cookie', [`token=${token}`] )\n .send(submittedData);\n expect(res.status).toBe(201);\n done();\n });\n});\n\ndescribe('READ', () => {\n test('Get all projects with GET to /api/projects/', async (done) => {\n // Test Data\n const submittedData = {\n name: 'projectName',\n };\n\n // Submit a project\n const res = await request\n .post('/api/projects/')\n .set(headers)\n .set('Cookie', [`token=${token}`])\n .send(submittedData);\n expect(res.status).toBe(201);\n\n // Get all projects\n const res2 = await request.get('/api/projects/').set(headers);\n expect(res2.status).toBe(200);\n\n const APIData = res2.body[0];\n expect(APIData.name).toBe(submittedData.name);\n done();\n });;\n});\n\ndescribe('UPDATE', () => {\n beforeAll(async () => {\n const submittedData = {\n name: {\n firstName: 'test',\n lastName: 'user',\n },\n email: 'newtest@test.com',\n };\n const user = await User.create(submittedData);\n const auth_origin = 'TEST';\n token = jwt.sign(\n { id: user.id, role: user.accessLevel, auth_origin },\n CONFIG_AUTH.SECRET,\n {\n expiresIn: `${CONFIG_AUTH.TOKEN_EXPIRATION_SEC}s`,\n },\n );\n })\n test('Update a project with PATCH to /api/projects/:id without a token', async (done) => {\n // Test Data\n const submittedData = {\n name: 'projectName',\n };\n\n // Submit a project\n const res = await request\n .post('/api/projects/')\n .set(headers)\n .set('Cookie', [`token=${token}`])\n .send(submittedData);\n expect(res.status).toBe(201);\n\n const updatedDataPayload = {\n name: 'updatedProjectName',\n };\n\n // Update project\n const res2 = await request\n .put(`/api/projects/${res.body._id}`)\n .set(headers)\n .send(updatedDataPayload);\n expect(res2.status).toBe(401);\n\n // Get project\n const res3 = await request.get(`/api/projects/${res.body._id}`)\n .set(headers);\n expect(res3.status).toBe(200);\n done();\n });\n test('Update a project with PATCH to /api/projects/:id with a token', async (done) => {\n // Test Data\n const submittedData = {\n name: 'projectName',\n };\n\n // Submit a project\n const res = await request\n .post('/api/projects/')\n .set(headers)\n .set('Cookie', [`token=${token}`])\n .send(submittedData);\n expect(res.status).toBe(201);\n\n const updatedDataPayload = {\n name: 'updatedProjectName',\n };\n\n // Update project\n const res2 = await request\n .put(`/api/projects/${res.body._id}`)\n .set(headers)\n .set('Cookie', [`token=${token}`])\n .send(updatedDataPayload);\n expect(res2.status).toBe(200)\n\n // Get project\n const res3 = await request.get(`/api/projects/${res.body._id}`)\n .set(headers)\n .set('Cookie', [`token=${token}`])\n expect(res3.status).toBe(200);\n\n const APIData = res3.body;\n expect(APIData.name).toBe(updatedDataPayload.name);\n done();\n });\n});\n\ndescribe('DELETE', () => {\n beforeAll(async () => {\n const submittedData = {\n name: {\n firstName: 'test',\n lastName: 'user',\n },\n email: 'newtest@test.com',\n };\n const user = await User.create(submittedData);\n const auth_origin = 'TEST';\n token = jwt.sign(\n { id: user.id, role: user.accessLevel, auth_origin },\n CONFIG_AUTH.SECRET,\n {\n expiresIn: `${CONFIG_AUTH.TOKEN_EXPIRATION_SEC}s`,\n },\n );\n })\n test('Delete a project with POST to /api/projects/:id without a token', async (done) => {\n // Test Data\n const submittedData = {\n name: 'projectName',\n };\n\n // Submit a project\n const res = await request\n .post('/api/projects/')\n .set(headers)\n .set('Cookie', [`token=${token}`])\n .send(submittedData);\n expect(res.status).toBe(201);\n\n // Delete project\n const res2 = await request.patch(`/api/projects/${res.body._id}`)\n .set(headers);\n expect(res2.status).toBe(401);\n done();\n});\n test('Delete a project with POST to /api/projects/:id with a token', async (done) => {\n // Test Data\n const submittedData = {\n name: 'projectName',\n };\n\n // Submit a project\n const res = await request\n .post('/api/projects/')\n .set(headers)\n .set('Cookie', [`token=${token}`])\n .send(submittedData);\n expect(res.status).toBe(201);\n\n // Delete project\n const res2 = await request.patch(`/api/projects/${res.body._id}`)\n .set(headers)\n .set('Cookie', [`token=${token}`])\n expect(res2.status).toBe(200);\n done();\n});\n});\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/test/old-tests/users.router.test.js", + "messages": [ + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 9, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 9, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 10, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 10, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 26, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 26, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 32, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 32, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 33, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 33, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 49, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 49, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 53, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 53, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 56, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 56, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 60, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 60, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 76, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 76, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 82, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 82, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 85, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 85, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 90, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 90, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 106, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 106, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 112, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 112, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 115, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 115, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 116, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 116, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 122, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 122, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 123, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 123, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 139, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 139, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 151, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 151, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 159, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 159, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 162, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 162, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 163, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 163, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 169, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 169, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 170, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 170, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 186, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 186, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 192, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 192, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 195, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 195, + "endColumn": 11 + } + ], + "suppressedMessages": [], + "errorCount": 29, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "const supertest = require('supertest');\nconst app = require('../app');\nconst request = supertest(app);\n\nconst { setupDB } = require('../setup-test');\nsetupDB('api-users');\n\nconst backendHeaders = process.env.CUSTOM_REQUEST_HEADER;\ndescribe('CREATE', () => {\n test('Create a User with POST to /api/users/', async (done) => {\n // Test Data\n const submittedData = {\n name: {\n firstName: 'test',\n lastName: 'user',\n },\n email: 'newtest@test.com',\n };\n\n // Submit a User\n const res = await request\n .post('/api/users/')\n .set('Accept', 'application/json')\n .set('x-customrequired-header', backendHeaders)\n .send(submittedData);\n expect(res.status).toBe(201);\n\n done();\n });\n});\n\ndescribe('READ', () => {\n test('Get a list of Users with with GET to /api/users/', async (done) => {\n // Test Data\n const submittedData = {\n name: {\n firstName: 'test',\n lastName: 'user',\n },\n email: 'newtest@test.com',\n };\n\n // Submit a User\n const res = await request\n .post('/api/users/')\n .set('Accept', 'application/json')\n .set('x-customrequired-header', backendHeaders)\n .send(submittedData);\n expect(res.status).toBe(201);\n\n // Get all Users\n const res2 = await request.get('/api/users/').set('x-customrequired-header', backendHeaders);\n expect(res2.status).toBe(200);\n\n const APIData = res2.body[0];\n expect(APIData.name).toMatchObject(submittedData.name);\n\n done();\n });\n test('Get a specific User by param with GET to /api/users?email=', async (done) => {\n // Test Data\n const submittedData = {\n name: {\n firstName: 'test',\n lastName: 'user',\n },\n email: 'newtest@test.com',\n };\n\n // Submit a User\n const res = await request\n .post('/api/users/')\n .set('Accept', 'application/json')\n .set('x-customrequired-header', backendHeaders)\n .send(submittedData);\n expect(res.status).toBe(201);\n\n // Get all Users\n const res2 = await request\n .get('/api/users?email=newtest@test.com')\n .set('x-customrequired-header', backendHeaders);\n expect(res2.status).toBe(200);\n\n const APIData = res2.body[0];\n expect(APIData.name).toMatchObject(submittedData.name);\n\n done();\n });\n\n test('Get a specific User by UserId with GET to /api/users/:UserId', async (done) => {\n // Test Data\n const submittedData = {\n name: {\n firstName: 'test',\n lastName: 'user',\n },\n email: 'newtest@test.com',\n };\n\n // Submit a User\n const res = await request\n .post('/api/users/')\n .set('Accept', 'application/json')\n .set('x-customrequired-header', backendHeaders)\n .send(submittedData);\n expect(res.status).toBe(201);\n\n // Get User by UserId\n const res2 = await request\n .get(`/api/users/${res.body._id}`)\n .set('x-customrequired-header', backendHeaders);\n expect(res2.status).toBe(200);\n\n const APIData = res2.body;\n expect(APIData.email).toBe(submittedData.email);\n expect(APIData.name).toMatchObject(submittedData.name);\n\n done();\n });\n});\n\ndescribe('UPDATE', () => {\n test('Update a User with PATCH to /api/users/:UserId', async (done) => {\n // Test Data\n const submittedData = {\n name: {\n firstName: 'test',\n lastName: 'user',\n },\n email: 'newtest@test.com',\n };\n\n // Submit a User\n const res = await request\n .post('/api/users/')\n .set('Accept', 'application/json')\n .set('x-customrequired-header', backendHeaders)\n .send(submittedData);\n expect(res.status).toBe(201);\n\n const updatedEmail = {\n email: 'newtest@test.com',\n };\n\n // Update User\n const resUpdate = await request\n .patch(`/api/users/${res.body._id}`)\n .set('Accept', 'application/json')\n .set('x-customrequired-header', backendHeaders)\n .send(updatedEmail);\n expect(resUpdate.status).toBe(200);\n // TODO: The updated User call is not returning a repsonse. Uncomment below line and\n // run to see.\n // expect(resUpdate.name).toMatchObject(submittedData.name);\n\n const res2 = await request\n .get(`/api/users/${res.body._id}`)\n .set('x-customrequired-header', backendHeaders);\n expect(res2.status).toBe(200);\n\n const APIData = res2.body;\n expect(APIData.email).toBe(updatedEmail.email);\n expect(APIData.name).toMatchObject(submittedData.name);\n\n done();\n });\n});\n\ndescribe('DELETE', () => {\n test('Delete a specific user by Id with DELETE /api/users/:UserId', async (done) => {\n // Test Data\n const submittedData = {\n name: {\n firstName: 'test',\n lastName: 'user',\n },\n email: 'newtest@test.com',\n };\n\n // Submit a User\n const res = await request\n .post('/api/users/')\n .set('Accept', 'application/json')\n .set('x-customrequired-header', backendHeaders)\n .send(submittedData);\n expect(res.status).toBe(201);\n\n // Delete User\n const res2 = await request\n .delete(`/api/users/${res.body._id}`)\n .set('x-customrequired-header', backendHeaders);\n expect(res2.status).toBe(200);\n\n const APIData = res2.body;\n expect(APIData.name).toMatchObject(submittedData.name);\n\n done();\n });\n});\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/test/user.integration.test.js", + "messages": [ + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 19, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 19, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 20, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 20, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 27, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 27, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 28, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 28, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 35, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 35, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 42, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 42, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 43, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 43, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 49, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 49, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 50, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 50, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 53, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 53, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 56, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 56, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 60, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 60, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 65, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 65, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 68, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 68, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 73, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 73, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 78, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 78, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 81, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 81, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 82, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 82, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 88, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 88, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 89, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 89, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 100, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 100, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 101, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 101, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 106, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 106, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 109, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 109, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 110, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 110, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 116, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 116, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'test' is not defined.", + "line": 117, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 117, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 122, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 122, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 125, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 125, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 131, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 131, + "endColumn": 11 + } + ], + "suppressedMessages": [], + "errorCount": 30, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "const supertest = require('supertest');\nconst app = require('../app');\nconst request = supertest(app);\n\nconst { setupIntegrationDB } = require('../setup-test');\nsetupIntegrationDB('api-users');\n\nconst backendHeaders = process.env.CUSTOM_REQUEST_HEADER;\n\nconst submittedData = {\n name: {\n firstName: 'test',\n lastName: 'user',\n },\n email: 'newtest@test.com',\n};\nvar createdUserId = '';\n\ndescribe('CREATE', () => {\n test('Create a User with POST to /api/users/', async (done) => {\n // Submit a User\n const res = await request\n .post('/api/users/')\n .set('Accept', 'application/json')\n .set('x-customrequired-header', backendHeaders)\n .send(submittedData);\n expect(res.status).toBe(201);\n expect(res.body.name).toMatchObject(submittedData.name);\n\n createdUserId = res.body._id;\n\n done();\n });\n\n test('Fail when creating a User with duplicate email', async (done) => {\n // Submit a User\n const res = await request\n .post('/api/users/')\n .set('Accept', 'application/json')\n .set('x-customrequired-header', backendHeaders)\n .send(submittedData);\n expect(res.status).toBe(409);\n expect(res.body).toMatchObject({error: { code: 11000, driver: true, name: 'MongoError', index: 0 }, message: 'User already exists'});\n\n done();\n });\n});\n\ndescribe('READ', () => {\n test('Get a list of Users with with GET to /api/users/', async (done) => {\n // Get all Users\n const res = await request.get('/api/users/').set('x-customrequired-header', backendHeaders);\n expect(res.status).toBe(200);\n\n const APIData = res.body[0];\n expect(APIData.name).toMatchObject(submittedData.name);\n\n done();\n });\n test('Get a specific User by param with GET to /api/users?email=', async (done) => {\n // Get User by query of email\n const res = await request\n .get('/api/users?email=newtest@test.com')\n .set('x-customrequired-header', backendHeaders);\n expect(res.status).toBe(200);\n\n const APIData = res.body[0];\n expect(APIData.name).toMatchObject(submittedData.name);\n\n done();\n });\n\n test('Get a specific User by UserId with GET to /api/users/:UserId', async (done) => {\n // Get User by UserId\n const res = await request\n .get(`/api/users/${createdUserId}`)\n .set('x-customrequired-header', backendHeaders);\n expect(res.status).toBe(200);\n\n const APIData = res.body;\n expect(APIData.email).toBe(submittedData.email);\n expect(APIData.name).toMatchObject(submittedData.name);\n\n done();\n });\n});\n\ndescribe('UPDATE', () => {\n test('Update a User with PATCH to /api/users/:UserId', async (done) => {\n const updatedEmail = {\n email: 'newtest2@test.com',\n };\n\n // Update User\n const resUpdate = await request\n .patch(`/api/users/${createdUserId}`)\n .set('Accept', 'application/json')\n .set('x-customrequired-header', backendHeaders)\n .send(updatedEmail);\n expect(resUpdate.status).toBe(200);\n expect(resUpdate.body.name).toMatchObject(submittedData.name);\n\n const res2 = await request\n .get(`/api/users/${createdUserId}`)\n .set('x-customrequired-header', backendHeaders);\n expect(res2.status).toBe(200);\n\n const APIData = res2.body;\n expect(APIData.email).toBe(updatedEmail.email);\n expect(APIData.name).toMatchObject(submittedData.name);\n\n done();\n });\n});\n\ndescribe('DELETE', () => {\n test('Delete a specific user by Id with DELETE /api/users/:UserId', async (done) => {\n // Delete User\n const res = await request\n .delete(`/api/users/${createdUserId}`)\n .set('x-customrequired-header', backendHeaders);\n expect(res.status).toBe(200);\n\n const APIData = res.body;\n expect(APIData.name).toMatchObject(submittedData.name);\n\n // Check to see that deleted User is gone\n const res2 = await request\n .get(`/api/users/${createdUserId}`)\n .set('x-customrequired-header', backendHeaders);\n expect(res2.body).toEqual({});\n\n\n done();\n });\n});\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/validators/index.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/validators/user.api.validator.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/workers/closeCheckins.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/workers/createRecurringEvents.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/workers/createRecurringEvents.test.js", + "messages": [ + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 10, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 10, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 16, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 16, + "endColumn": 5 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 17, + "column": 22, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 17, + "endColumn": 26 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 23, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 23, + "endColumn": 5 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 23, + "column": 31, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 23, + "endColumn": 35 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 26, + "column": 1, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 26, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 34, + "column": 11, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 34, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'beforeEach' is not defined.", + "line": 37, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 37, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 50, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 50, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'afterEach' is not defined.", + "line": 53, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 53, + "endColumn": 12 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 54, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 54, + "endColumn": 9 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 58, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 58, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 59, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 59, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 62, + "column": 15, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 62, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 67, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 67, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 70, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 70, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 73, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 73, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 78, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 78, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 79, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 79, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 83, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 83, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 84, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 84, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 90, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 90, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 93, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 93, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 99, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 99, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 102, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 102, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 108, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 108, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 111, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 111, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 117, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 117, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 120, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 120, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 126, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 126, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 130, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 130, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 131, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 131, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 134, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 134, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 137, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 137, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 140, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 140, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 144, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 144, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 145, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 145, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 147, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 147, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 150, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 150, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 152, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 152, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 156, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 156, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 157, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 157, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 160, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 160, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 161, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 161, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 162, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 162, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 165, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 165, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 178, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 178, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 179, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 179, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 189, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 189, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 191, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 191, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 199, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 199, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 212, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 212, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 213, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 213, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 222, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 222, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 224, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 224, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 232, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 232, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 245, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 245, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 246, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 246, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 256, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 256, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 258, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 258, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 266, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 266, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 278, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 278, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 279, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 279, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 289, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 289, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 291, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 291, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 300, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 300, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 301, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 301, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 305, + "column": 15, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 305, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 311, + "column": 15, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 311, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 318, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 318, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 320, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 320, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 322, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 322, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 326, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 326, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 328, + "column": 9, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 328, + "endColumn": 15 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 333, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 333, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 334, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 334, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 338, + "column": 15, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 338, + "endColumn": 19 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 343, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 343, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 351, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 351, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 354, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 354, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 359, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 359, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'describe' is not defined.", + "line": 363, + "column": 3, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 363, + "endColumn": 11 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'it' is not defined.", + "line": 364, + "column": 5, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 364, + "endColumn": 7 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'jest' is not defined.", + "line": 365, + "column": 27, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 365, + "endColumn": 31 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 371, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 371, + "endColumn": 13 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'expect' is not defined.", + "line": 371, + "column": 64, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 371, + "endColumn": 70 + } + ], + "suppressedMessages": [], + "errorCount": 86, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "const {\n fetchData,\n adjustToLosAngelesTime,\n isSameUTCDate,\n doesEventExist,\n createEvent,\n filterAndCreateEvents,\n runTask,\n scheduleTask,\n} = jest.requireActual('./createRecurringEvents');\nconst { generateEventData } = require('./lib/generateEventData');\n\nconst MockDate = require('mockdate');\nconst cron = require('node-cron');\n\njest.mock('./lib/generateEventData', () => ({\n generateEventData: jest.fn((event) => ({\n ...event,\n generated: true,\n })),\n}));\n\njest.mock('node-fetch', () => jest.fn());\nconst fetch = require('node-fetch');\n\ndescribe('createRecurringEvents Module Tests', () => {\n const mockURL = 'http://localhost:3000';\n const mockHeader = 'mock-header';\n let mockEvents;\n let mockRecurringEvents;\n\n fetch.mockResolvedValue({\n ok: true,\n json: jest.fn().mockResolvedValue(mockEvents),\n });\n\n beforeEach(() => {\n MockDate.set('2023-11-02T00:00:00Z');\n\n mockEvents = [\n { name: 'Event 1', date: '2023-11-02T19:00:00Z' },\n { name: 'Event 2', date: '2023-11-02T07:00:00Z' },\n ];\n mockRecurringEvents = [\n { name: 'Event 1', date: '2023-11-02T19:00:00Z' },\n { name: 'Event 2', date: '2023-11-02T07:00:00Z' },\n { name: 'Event 3', date: '2023-11-03T07:00:00Z' }, // Does not match today\n ];\n\n jest.clearAllMocks();\n });\n\n afterEach(() => {\n jest.clearAllMocks();\n MockDate.reset();\n });\n\n describe('fetchData', () => {\n it('should fetch data from the API endpoint', async () => {\n fetch.mockResolvedValueOnce({\n ok: true,\n json: jest.fn().mockResolvedValue(mockEvents),\n });\n\n const result = await fetchData('/api/events/', mockURL, mockHeader, fetch);\n\n expect(fetch).toHaveBeenCalledWith(`${mockURL}/api/events/`, {\n headers: { 'x-customrequired-header': mockHeader },\n });\n expect(result).toEqual(mockEvents);\n });\n\n it('should handle API fetch failures', async () => {\n fetch.mockRejectedValueOnce(new Error('Network error'));\n\n const result = await fetchData('/api/events/', mockURL, mockHeader, fetch);\n\n expect(fetch).toHaveBeenCalledTimes(1);\n expect(result).toEqual([]);\n });\n });\n\n describe('adjustToLosAngelesTime', () => {\n it('should correctly adjust timestamps before DST starts (PST -8)', () => {\n const utcTimestamp = new Date('2024-03-10T07:00:00Z'); // 7 AM UTC\n const expectedLocal = new Date('2024-03-09T23:00:00Z'); // 11 PM PST (-8)\n\n const result = adjustToLosAngelesTime(utcTimestamp);\n\n expect(result.toISOString()).toBe(expectedLocal.toISOString());\n });\n\n it('should correctly adjust timestamps after DST starts (PDT -7)', () => {\n const utcTimestamp = new Date('2024-03-11T07:00:00Z'); // 7 AM UTC (after DST)\n const expectedLocal = new Date('2024-03-11T00:00:00Z'); // 12 AM PDT (-7)\n\n const result = adjustToLosAngelesTime(utcTimestamp);\n\n expect(result.toISOString()).toBe(expectedLocal.toISOString());\n });\n\n it('should correctly adjust timestamps after DST ends (PST -8)', () => {\n const utcTimestamp = new Date('2024-11-10T08:00:00Z'); // 8 AM UTC\n const expectedLocal = new Date('2024-11-10T00:00:00Z'); // 12 AM PST (-8)\n\n const result = adjustToLosAngelesTime(utcTimestamp);\n\n expect(result.toISOString()).toBe(expectedLocal.toISOString());\n });\n\n it('should correctly adjust timestamps when DST ends (PST -8)', () => {\n const utcTimestamp = new Date('2024-11-03T09:00:00Z'); // 9 AM UTC\n const expectedLocal = new Date('2024-11-03T01:00:00Z'); // 1 AM PST (UTC-8)\n\n const result = adjustToLosAngelesTime(utcTimestamp);\n\n expect(result.toISOString()).toBe(expectedLocal.toISOString());\n });\n\n it('should correctly handle the repeated hour when DST ends (PST -8)', () => {\n const utcTimestamp = new Date('2024-11-03T08:30:00Z'); // 8:30 AM UTC\n const expectedLocal = new Date('2024-11-03T01:30:00Z'); // 1:30 AM PST (during repeat hour)\n\n const result = adjustToLosAngelesTime(utcTimestamp);\n\n expect(result.toISOString()).toBe(expectedLocal.toISOString());\n });\n });\n\n describe('isSameUTCDate', () => {\n it('should return true for the same UTC day', () => {\n const date1 = new Date('2023-11-02T19:00:00Z');\n const date2 = new Date('2023-11-02T10:00:00Z');\n expect(isSameUTCDate(date1, date2)).toBe(true);\n });\n\n it('should return false for different UTC days', () => {\n const date1 = new Date('2023-11-02T19:00:00Z');\n const date2 = new Date('2023-11-03T10:00:00Z');\n expect(isSameUTCDate(date1, date2)).toBe(false);\n });\n });\n\n describe('doesEventExist', () => {\n it('should return true if an event exists on the same UTC day', () => {\n const today = new Date('2023-11-02T00:00:00Z');\n expect(doesEventExist('Event 1', today, mockEvents)).toBe(true);\n });\n\n it('should return false if no event exists on the same UTC day', () => {\n const today = new Date('2023-11-03T00:00:00Z');\n expect(doesEventExist('Event 1', today, mockEvents)).toBe(false);\n });\n });\n\n describe('filterAndCreateEvents', () => {\n it('should not create events already present for today', async () => {\n await filterAndCreateEvents(mockEvents, mockRecurringEvents, mockURL, mockHeader, fetch);\n\n expect(generateEventData).not.toHaveBeenCalledWith(mockRecurringEvents[0]); // Recurring Event 1\n expect(generateEventData).not.toHaveBeenCalledWith(mockRecurringEvents[1]); // Recurring Event 2\n expect(fetch).not.toHaveBeenCalled();\n });\n\n it('should correctly adjust an event before DST ends (UTC-7 -> UTC-8)', async () => {\n MockDate.set('2023-11-04T23:00:00Z'); // Before DST ends\n\n const preDstEvent = [\n {\n name: 'Pre-DST Event',\n date: '2023-11-04T08:00:00Z', // 8 AM UTC (1 AM PDT)\n startTime: '2023-11-04T08:00:00Z',\n // hours: 1,\n },\n ];\n await filterAndCreateEvents([], preDstEvent, mockURL, mockHeader, fetch);\n\n expect(generateEventData).toHaveBeenCalledWith(\n expect.objectContaining({ name: 'Pre-DST Event' }),\n );\n\n const expectedEvent = {\n name: 'Pre-DST Event',\n date: new Date('2023-11-04T01:00:00Z').toISOString(), // Should match 1 AM PDT\n startTime: new Date('2023-11-04T01:00:00Z').toISOString(),\n generated: true,\n };\n\n expect(fetch).toHaveBeenCalledWith(\n `${mockURL}/api/events/`,\n expect.objectContaining({\n body: JSON.stringify(expectedEvent),\n }),\n );\n\n MockDate.reset();\n });\n\n it('should correctly adjust an event during DST ending (PDT -> PST shift)', async () => {\n MockDate.set('2023-11-05T02:00:00Z'); // The moment of DST shift\n\n const dstTransitionEvent = [\n {\n name: 'DST Shift Event',\n date: '2023-11-05T09:00:00Z',\n startTime: '2023-11-05T09:00:00Z',\n },\n ];\n\n await filterAndCreateEvents([], dstTransitionEvent, mockURL, mockHeader, fetch);\n\n expect(generateEventData).toHaveBeenCalledWith(\n expect.objectContaining({ name: 'DST Shift Event' }),\n );\n const expectedEvent = {\n name: 'DST Shift Event',\n date: new Date('2023-11-05T01:00:00Z').toISOString(),\n startTime: new Date('2023-11-05T01:00:00Z').toISOString(),\n generated: true,\n };\n\n expect(fetch).toHaveBeenCalledWith(\n `${mockURL}/api/events/`,\n expect.objectContaining({\n body: JSON.stringify(expectedEvent),\n }),\n );\n\n MockDate.reset();\n });\n\n it('should correctly adjust an event before DST starts (UTC-8 -> UTC-7)', async () => {\n MockDate.set('2024-03-10T09:00:00Z'); // 1 AM PST before the shift\n\n const preDstStartEvent = [\n {\n name: 'Pre-DST Start Event',\n date: '2024-03-10T09:00:00Z', // 1 AM PST in UTC-8\n startTime: '2024-03-10T09:00:00Z',\n },\n ];\n\n await filterAndCreateEvents([], preDstStartEvent, mockURL, mockHeader, fetch);\n\n expect(generateEventData).toHaveBeenCalledWith(\n expect.objectContaining({ name: 'Pre-DST Start Event' }),\n );\n\n const expectedEvent = {\n name: 'Pre-DST Start Event',\n date: new Date('2024-03-10T01:00:00Z').toISOString(), // Should match 1 AM PST\n startTime: new Date('2024-03-10T01:00:00Z').toISOString(),\n generated: true,\n };\n\n expect(fetch).toHaveBeenCalledWith(\n `${mockURL}/api/events/`,\n expect.objectContaining({\n body: JSON.stringify(expectedEvent),\n }),\n );\n\n MockDate.reset();\n });\n\n it('should correctly adjust an event during DST start (PST -> PDT shift)', async () => {\n MockDate.set('2024-03-10T10:00:00Z');\n\n const dstStartTransitionEvent = [\n {\n name: 'DST Start Event',\n date: '2024-03-10T10:00:00Z', // 2 AM PST in UTC-8\n startTime: '2024-03-10T10:00:00Z',\n },\n ];\n await filterAndCreateEvents([], dstStartTransitionEvent, mockURL, mockHeader, fetch);\n\n expect(generateEventData).toHaveBeenCalledWith(\n expect.objectContaining({ name: 'DST Start Event' }),\n );\n\n const expectedEvent = {\n name: 'DST Start Event',\n date: new Date('2024-03-10T03:00:00Z').toISOString(), // Should match 3 AM PDT\n startTime: new Date('2024-03-10T03:00:00Z').toISOString(),\n generated: true,\n };\n\n expect(fetch).toHaveBeenCalledWith(\n `${mockURL}/api/events/`,\n expect.objectContaining({\n body: JSON.stringify(expectedEvent),\n }),\n );\n\n MockDate.reset();\n });\n });\n\n describe('runTask', () => {\n it('should fetch data but not create events if all exist', async () => {\n // First API call response (events)\n fetch.mockResolvedValueOnce({\n ok: true,\n json: jest.fn().mockResolvedValue(mockEvents),\n });\n\n // Second API call response (recurring events)\n fetch.mockResolvedValueOnce({\n ok: true,\n json: jest.fn().mockResolvedValue(mockRecurringEvents),\n });\n\n await runTask(fetch, mockURL, mockHeader);\n\n console.log('Actual fetch calls:', fetch.mock.calls);\n // Expect only 2 fetch calls (no event creation needed)\n expect(fetch).toHaveBeenCalledTimes(2);\n\n expect(fetch).toHaveBeenCalledWith(\n `${mockURL}/api/recurringevents/`,\n expect.objectContaining({ headers: { 'x-customrequired-header': mockHeader } }),\n );\n\n // Ensure no call to createEvent\n expect(fetch).not.toHaveBeenCalledWith(\n `${mockURL}/api/events/`,\n expect.objectContaining({ method: 'POST' }),\n );\n });\n });\n\n describe('createEvent', () => {\n it('should create a new event via POST request', async () => {\n const mockEvent = { name: 'Event 1', date: '2023-11-02T19:00:00Z' };\n fetch.mockResolvedValueOnce({\n ok: true,\n json: jest.fn().mockResolvedValue({ id: 1, ...mockEvent }),\n });\n\n const result = await createEvent(mockEvent, mockURL, mockHeader, fetch);\n\n expect(fetch).toHaveBeenCalledWith(`${mockURL}/api/events/`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'x-customrequired-header': mockHeader,\n },\n body: JSON.stringify(mockEvent),\n });\n expect(result).toEqual({ id: 1, ...mockEvent });\n });\n\n it('should return null if event creation fails', async () => {\n fetch.mockRejectedValueOnce(new Error('Network error'));\n\n const result = await createEvent(null, mockURL, mockHeader, fetch);\n\n expect(result).toBeNull();\n });\n });\n\n describe('scheduleTask', () => {\n it('should schedule the runTask function', () => {\n const scheduleSpy = jest.spyOn(cron, 'schedule').mockImplementation((_, callback) => {\n callback();\n });\n\n scheduleTask(cron, fetch, mockURL, mockHeader);\n\n expect(scheduleSpy).toHaveBeenCalledWith('*/30 * * * *', expect.any(Function));\n\n scheduleSpy.mockRestore();\n });\n });\n});\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/workers/lib/generateEventData.js", + "messages": [ + { + "ruleId": "no-prototype-builtins", + "severity": 2, + "message": "Do not access Object.prototype method 'hasOwnProperty' from target object.", + "line": 33, + "column": 18, + "nodeType": "CallExpression", + "messageId": "prototypeBuildIn", + "endLine": 33, + "endColumn": 32, + "suggestions": [ + { + "messageId": "callObjectPrototype", + "data": { + "prop": "hasOwnProperty" + }, + "fix": { + "range": [1443, 1467], + "text": "Object.prototype.hasOwnProperty.call(eventObj, " + }, + "desc": "Call Object.prototype.hasOwnProperty explicitly." + } + ] + } + ], + "suppressedMessages": [], + "errorCount": 1, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "function generateEventData(eventObj, TODAY_DATE = new Date()) {\n /**\n * Generates event data based on the provided event object and date.\n * In the cron job this function normally runs in, it is expected that eventObj.date is the same as TODAY_DATE.\n */\n const eventDate = new Date(eventObj.startTime);\n // Create new event\n const hours = eventDate.getHours();\n const minutes = eventDate.getMinutes();\n const seconds = eventDate.getSeconds();\n const milliseconds = eventDate.getMilliseconds();\n\n const yearToday = TODAY_DATE.getFullYear();\n const monthToday = TODAY_DATE.getMonth();\n const dateToday = TODAY_DATE.getDate();\n\n const newEventDate = new Date(yearToday, monthToday, dateToday, hours, minutes, seconds, milliseconds);\n\n const newEndTime = new Date(yearToday, monthToday, dateToday, hours + eventObj.hours, minutes, seconds, milliseconds)\n\n const eventToCreate = {\n name: eventObj.name && eventObj.name,\n hacknight: eventObj.hacknight && eventObj.hacknight,\n eventType: eventObj.eventType && eventObj.eventType,\n description: eventObj.eventDescription && eventObj.eventDescription,\n project: eventObj.project && eventObj.project,\n date: eventObj.date && newEventDate,\n startTime: eventObj.startTime && newEventDate,\n endTime: eventObj.endTime && newEndTime,\n hours: eventObj.hours && eventObj.hours\n }\n \n if (eventObj.hasOwnProperty(\"location\")) {\n eventToCreate.location = {\n city: eventObj.location.city ? eventObj.location.city : 'REMOTE',\n state: eventObj.location.state ? eventObj.location.state : 'REMOTE',\n country: eventObj.location.country ? eventObj.location.country : 'REMOTE'\n };\n }\n\n return eventToCreate\n};\n\nmodule.exports = { generateEventData };", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/workers/openCheckins.js", + "messages": [ + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'response' is assigned a value but never used.", + "line": 51, + "column": 31, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 51, + "endColumn": 39 + } + ], + "suppressedMessages": [], + "errorCount": 1, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "module.exports = (cron, fetch) => {\n\n // Check to see if any events are about to start,\n // and if so, open their respective check-ins\n\n const url = process.env.NODE_ENV === 'prod' ? 'https://www.vrms.io' : `http://localhost:${process.env.BACKEND_PORT}`;\n const headerToSend = process.env.CUSTOM_REQUEST_HEADER;\n\n async function fetchEvents() {\n try {\n const res = await fetch(`${url}/api/events`, {\n headers: {\n \"x-customrequired-header\": headerToSend\n }\n });\n const resJson = await res.json();\n\n return resJson;\n } catch(error) {\n console.log(error);\n };\n };\n\n async function sortAndFilterEvents(currentTime, thirtyMinutes) {\n const events = await fetchEvents();\n\n // Filter events if event date is after now but before thirty minutes from now\n if (events && events.length > 0) {\n const sortedEvents = events.filter(event => {\n return (event.date >= currentTime) && (event.date <= thirtyMinutes) && (event.checkInReady === false);\n })\n // console.log('Sorted events: ', sortedEvents);\n return sortedEvents;\n };\n };\n\n async function openCheckins(events) {\n if(events && events.length > 0) {\n events.forEach(event => {\n // console.log('Opening event: ', event);\n\n fetch(`${url}/api/events/${event._id}`, {\n method: \"PATCH\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-customrequired-header\": headerToSend\n },\n body: JSON.stringify({ checkInReady: true })\n })\n .then(res => {\n const response = res;\n })\n .catch(err => {\n console.log(err);\n });\n });\n };\n };\n\n async function runTask() {\n console.log(\"Opening check-ins\");\n\n // Get current time and set to date variable\n const currentTimeISO = new Date().toISOString();\n\n // Calculate thirty minutes from now\n const thirtyMinutesFromNow = new Date().getTime() + 1800000;\n const thirtyMinutesISO = new Date(thirtyMinutesFromNow).toISOString();\n\n const eventsToOpen = await sortAndFilterEvents(currentTimeISO, thirtyMinutesISO);\n await openCheckins(eventsToOpen);\n\n console.log(\"Check-ins opened\");\n };\n\n const scheduledTask = cron.schedule('*/30 * * * *', () => {\n runTask();\n });\n\n return scheduledTask;\n};", + "usedDeprecatedRules": [] + }, + { + "filePath": "/backend/workers/slackbot.js", + "messages": [ + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'fetchEvents' is assigned a value but never used.", + "line": 10, + "column": 9, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 10, + "endColumn": 20 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'resJson' is not defined.", + "line": 17, + "column": 7, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 17, + "endColumn": 14 + }, + { + "ruleId": "no-undef", + "severity": 2, + "message": "'resJson' is not defined.", + "line": 21, + "column": 28, + "nodeType": "Identifier", + "messageId": "undef", + "endLine": 21, + "endColumn": 35 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'now' is assigned a value but never used.", + "line": 39, + "column": 15, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 39, + "endColumn": 18 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'urlToSend' is assigned a value but never used.", + "line": 61, + "column": 15, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 61, + "endColumn": 24 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'sendSlackMessage' is defined but never used.", + "line": 72, + "column": 18, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 72, + "endColumn": 34 + } + ], + "suppressedMessages": [], + "errorCount": 6, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "module.exports = (fetch) => {\n\n console.log('Hello from SlackBot');\n const token = process.env.SLACK_TOKEN;\n\n const headerToSend = process.env.CUSTOM_REQUEST_HEADER;\n\n let EVENTS;\n\n const fetchEvents = async () => {\n try {\n const res = await fetch(`http://localhost:${process.env.BACKEND_PORT}/api/events`, {\n headers: {\n 'x-customrequired-header': headerToSend,\n },\n });\n resJson = await res.json();\n\n const today = new Date();\n\n const todaysEvents = resJson.filter((event) => {\n const eventDate = new Date(event.date);\n console.log('Event date: ', eventDate);\n const year = eventDate.getFullYear();\n const month = eventDate.getMonth();\n const date = eventDate.getDate();\n\n const yearToday = today.getFullYear();\n const monthToday = today.getMonth();\n const dateToday = today.getDate();\n\n console.log('Event: ', year, month, date);\n console.log('Today: ', yearToday, monthToday, dateToday);\n\n return year === yearToday && month === monthToday && date === dateToday;\n });\n\n EVENTS = todaysEvents.filter((event) => {\n const now = new Date();\n\n // 10 Minutes til event startTime\n // If event.date -\n return event.date;\n });\n\n console.log(EVENTS);\n } catch (error) {\n console.log(error);\n }\n\n const BASE_URL = 'https://slack.com/api/chat.postMessage';\n const channel = 'C013H2HN0VC';\n\n if (EVENTS && EVENTS.length > 0) {\n EVENTS.forEach(async (event) => {\n const team = event.project.name;\n const linkNew = 'http://localhost:3000/checkIn/newUser?eventId=' + event._id;\n const linkReturning = 'http://localhost:3000/checkIn/returningUser?eventId=' + event._id;\n const messageToSend = `&text=Hey ${team} team! Here are the links to check-in for your meeting tonight: \\n\\nNew User: ${linkNew} \\nReturning User: ${linkReturning} \\n\\nHave fun tonight!`;\n\n const urlToSend = `${BASE_URL}?token=${token}&channel=${channel}${messageToSend}&unfurl_media=false&username=VRMS Bot`;\n\n if (team.length > 0) {\n console.log('Send slack message');\n } else {\n console.log(\"Didn't do anything with \" + (event && event));\n }\n });\n }\n };\n\n async function sendSlackMessage(url) {\n console.log('Sending...');\n\n await fetch(url, {\n method: 'post',\n })\n .then((res) => {\n const response = res.json();\n return response;\n })\n .then((res) => {\n console.log(res);\n })\n .catch((err) => {\n console.log(err);\n });\n\n console.log('Done sending');\n }\n\n setTimeout(async () => {}, 5000);\n};\n", + "usedDeprecatedRules": [] + }, + { + "filePath": "/client/postcss.config.js", + "messages": [], + "suppressedMessages": [], + "errorCount": 0, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "usedDeprecatedRules": [] + }, + { + "filePath": "/client/src/App.jsx", + "messages": [ + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'React' is defined but never used.", + "line": 1, + "column": 8, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 1, + "endColumn": 13 + }, + { + "ruleId": "no-unused-vars", + "severity": 2, + "message": "'UserPermissionSearch' is defined but never used.", + "line": 30, + "column": 8, + "nodeType": "Identifier", + "messageId": "unusedVar", + "endLine": 30, + "endColumn": 28 + } + ], + "suppressedMessages": [], + "errorCount": 2, + "fatalErrorCount": 0, + "warningCount": 0, + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "source": "import React from 'react';\nimport { AuthProvider } from './context/authContext';\nimport { Route, Redirect, Switch } from 'react-router-dom';\n\nimport Home from './pages/Home';\nimport Navbar from './components/Navbar';\nimport Footer from './components/Footer';\nimport AdminDashboard from './components/admin/dashboard';\nimport UserDashboard from './pages/UserDashboard';\nimport UserProfile from './pages/UserProfile';\nimport Event from './pages/Event';\nimport NewUser from './pages/NewUser';\nimport ReturningUser from './pages/ReturningUser';\nimport Auth from './components/auth/Auth';\nimport CheckInForm from './pages/CheckInForm';\nimport Success from './pages/Success';\nimport HandleAuth from './components/auth/HandleAuth';\nimport EmailSent from './pages/EmailSent';\nimport Events from './pages/Events';\nimport ProjectLeaderDashboard from './pages/ProjectLeaderDashboard';\nimport Users from './pages/Users';\nimport UserAdmin from './pages/UserAdmin';\nimport ProjectList from './pages/ProjectList';\nimport ManageProjects from './pages/ManageProjects';\nimport addProject from './components/manageProjects/addProject';\nimport HealthCheck from './pages/HealthCheck';\nimport SecretPassword from './pages/SecretPassword';\nimport UserWelcome from './pages/UserWelcome';\n// Added User Permission Search component\nimport UserPermissionSearch from './pages/UserPermissionSearch';\nimport UserPermission from './pages/UserPermission';\n\nimport { Box, ThemeProvider } from '@mui/material';\nimport theme from './theme';\n\nimport './App.scss';\n\n/* \n withAuth Hook\n Wraps component with withAuth hook to manage automatic redirect to login page if user is not logged in\n An example (inside routes object):\n { path: '/endpoint', name: 'endpoint', Component: withAuth(ComponentName) },\n Return if user is not logged in\n Return if user is logged in\n*/\nimport withAuth from './hooks/withAuth';\n\nconst routes = [\n { path: '/', name: 'home', Component: Home },\n { path: '/admin', name: 'admindashboard', Component: withAuth(AdminDashboard) },\n { path: '/user', name: 'userdashboard', Component: UserDashboard },\n { path: '/profile', name: 'profile', Component: UserProfile },\n { path: '/event/:id', name: 'event', Component: Event },\n { path: '/new', name: 'new', Component: NewUser },\n { path: '/returning', name: 'returning', Component: ReturningUser },\n { path: '/login', name: 'login', Component: Auth },\n { path: '/checkIn/:userType', name: 'checkIn', Component: CheckInForm },\n { path: '/newProfile', name: 'newProfile', Component: CheckInForm },\n { path: '/success', name: 'success', Component: Success },\n { path: '/handleauth', name: 'handleauth', Component: HandleAuth },\n { path: '/emailsent', name: 'emailsent', Component: EmailSent },\n { path: '/events', name: 'events', Component: withAuth(Events) },\n { path: '/useradmin', name: 'useradmin', Component: withAuth(UserAdmin) },\n { path: '/projects', name: 'projects', Component: withAuth(ProjectList) },\n { path: '/projects/create', name: 'projectform', Component: withAuth(addProject) },\n { path: '/users', name: 'users', Component: Users },\n { path: '/users/user-search', name: 'useradmin', Component: withAuth(UserAdmin) },\n {\n path: '/users/permission-search',\n name: 'useradmin',\n Component: UserPermission,\n },\n {\n path: '/projects/:projectId',\n name: 'project',\n Component: withAuth(ManageProjects),\n },\n {\n path: '/projectleader',\n name: 'pldashboard',\n Component: ProjectLeaderDashboard,\n },\n { path: '/healthcheck', name: 'healthcheck', Component: HealthCheck },\n {\n path: '/secretpassword',\n name: 'secretpassword',\n Component: SecretPassword,\n },\n { path: '/welcome', name: 'welcome', Component: UserWelcome },\n];\n\nconst App = () => {\n return (\n \n \n \n \n \n \n \n {routes.map(({ path, Component }) => (\n \n ))}\n \n \n \n