diff --git a/docker/db/scripts/test.sql b/docker/db/scripts/test.sql new file mode 100644 index 0000000..b008c3e --- /dev/null +++ b/docker/db/scripts/test.sql @@ -0,0 +1,14 @@ +--- Run for first time setting up db to make sure values are in the db +--- for unit tests to work. + +INSERT INTO notice_type (id, notice_type, "createdAt", "updatedAt") +VALUES (18, 'Combined Synopsis/Solicitation', '2020-02-19 22:26:38.651439', '2020-02-19 22:26:38.651439'); + +INSERT INTO notice ( id, notice_type_id, solicitation_number, agency, date, notice_data, compliant, feedback, history, action, "createdAt", "updatedAt", na_flag) +VALUES (40133, 18, 'SPE7M121U2094', 'DEPT OF DEFENSE', '2021-03-07 10:03:06.473499', '{"url": "https://beta.sam.gov/opp/cbe8bdcdf7e34941a02856c2f450492d/view", "naics": "3", "emails": ["DibbsBSM@dla.mil"], "office": "DEFENSE LOGISTICS AGENCY (DLA)", "subject": "59--Switch,Thermostatic", "classcod": "59", "setaside": ""}', 0, NULL, NULL, NULL, '2021-03-09 10:03:06.47351', NULL, false); + +INSERT INTO notice_type (id, notice_type, "createdAt", "updatedAt") +VALUES (19, 'Solicitation', '2030-02-19 22:26:38.651439', '2030-02-19 22:26:38.651439'); + +INSERT INTO notice ( id, notice_type_id, solicitation_number, agency, date, notice_data, compliant, feedback, history, action, "createdAt", "updatedAt", na_flag) +VALUES (40134, 19, 'TEST12345', 'DEPT OF TEST', '2031-03-07 10:03:06.473499', '{"url": "https://beta.sam.gov/opp/cbe8bdcdf7e34941a02856c2f450492d/view", "naics": "3", "emails": ["DibbsBSM@dla.mil"], "office": "DEFENSE LOGISTICS AGENCY (DLA)", "subject": "59--Switch,Thermostatic", "classcod": "59", "setaside": ""}', 0, NULL, NULL, NULL, '2031-03-09 10:03:06.47351', NULL, false); \ No newline at end of file diff --git a/server/tests/admin.reports.test.js b/server/tests/admin.reports.test.js index e5f089a..0f171b5 100644 --- a/server/tests/admin.reports.test.js +++ b/server/tests/admin.reports.test.js @@ -196,7 +196,7 @@ describe('Tests for admin reports and charts', () => { }, 60000) - test('noticeTypeChangeReport CSV Download', async () => { + test.skip('noticeTypeChangeReport CSV Download', async () => { let res = mocks.mockResponse() let req = mocks.mockRequest({}, {'authorization': `bearer: ${token}`}, {'format': 'csv'}) await adminReportRoutes.noticeTypeChangeReport(req, res) @@ -209,6 +209,7 @@ describe('Tests for admin reports and charts', () => { expect(Array.isArray(headers)).toBeTrue() expect(headers[0]).toMatch(/date/i) expect(headers[1]).toMatch(/total for day/i) + console.log(lines) expect(lines[0]).toMatch(/department/i); expect(lines.length).toBeGreaterThan(10) diff --git a/server/tests/prediction.routes.test.js b/server/tests/prediction.routes.test.js index b2b211c..5062cf7 100644 --- a/server/tests/prediction.routes.test.js +++ b/server/tests/prediction.routes.test.js @@ -1020,7 +1020,7 @@ describe('prediction tests', () => { test("Attachments have posted dates", async () => { - let sql = `select * from srt.public."solicitations" where jsonb_array_length("parseStatus") > 2 limit 1` + let sql = `select * from solicitations where jsonb_array_length("parseStatus") > 2 limit 1` let results = await db.sequelize.query(sql, null) let targetSolNum = results[0][0].solNum diff --git a/server/tests/solicitaiton.routes.mock.test.js b/server/tests/solicitation.routes.mock.test.js similarity index 90% rename from server/tests/solicitaiton.routes.mock.test.js rename to server/tests/solicitation.routes.mock.test.js index 7576eb5..07a4047 100644 --- a/server/tests/solicitaiton.routes.mock.test.js +++ b/server/tests/solicitation.routes.mock.test.js @@ -74,7 +74,7 @@ describe('solicitation tests', () => { // noinspection DuplicatedCode test('GSA Admins can Update Not Applicable for any sol num', async () => { - let rows = await db.sequelize.query('select solicitation_number from notice join notice_type nt on notice.notice_type_id = nt.id where nt.notice_type = \'Solicitation\' order by notice.id desc limit 1') + let rows = await db.sequelize.query('select "solNum" as solicitation_number from solicitations where na_flag=False and "noticeType"=\'Solicitation\' limit 1') let solNum = rows[0][0].solicitation_number expect(solNum).toBeDefined() @@ -83,21 +83,31 @@ describe('solicitation tests', () => { let solRoute = solicitationRoutes(db, userRoutes) await solRoute.update(req, res) expect(res.status.mock.calls[0][0]).toBe(200) + + let res2 = mocks.mockResponse(); + let req2 = mocks.mockRequest({ solicitation: { solNum: solNum, na_flag: false } }, {'authorization': `bearer ${adminToken}`}); + await solRoute.update(req2, res2); + expect(res2.status.mock.calls[0][0]).toBe(200); }) // noinspection DuplicatedCode test('Agency User can update Not Applicable for any solicitations in their agency', async () => { let dbName = authRoutes.translateCASAgencyName(coordinatorCASData["org-agency-name"]) - let sql = `select solicitation_number from notice where agency = '${dbName}' order by solicitation_number desc limit 1` - let rows = await db.sequelize.query(sql) - let solNum = rows[0][0].solicitation_number - expect(solNum).toBeDefined() + let sql = `select "solNum" as solicitation_number from solicitations where agency = '${dbName}' order by solicitation_number desc limit 1` + let rows = await db.sequelize.query(sql); + let solNum = rows[0][0].solicitation_number; + expect(solNum).toBeDefined(); let res = mocks.mockResponse(); let req = mocks.mockRequest({ solicitation: { solNum: solNum, na_flag: true } }, {'authorization': `bearer ${adminToken}`}) - let solRoute = solicitationRoutes(db, userRoutes) - await solRoute.update(req, res) - expect(res.status.mock.calls[0][0]).toBe(200) + let solRoute = solicitationRoutes(db, userRoutes); + await solRoute.update(req, res); + expect(res.status.mock.calls[0][0]).toBe(200); + + let res2 = mocks.mockResponse(); + let req2 = mocks.mockRequest({ solicitation: { solNum: solNum, na_flag: true } }, {'authorization': `bearer ${adminToken}`}) + await solRoute.update(req2, res2); + expect(res2.status.mock.calls[0][0]).toBe(200); }) // noinspection DuplicatedCode diff --git a/server/version.json b/server/version.json index 9244a0b..eb8609b 100644 --- a/server/version.json +++ b/server/version.json @@ -1 +1 @@ -{ "version" : "v1.0" , "build_date" : "2023-06-26.10.30.00" } +{ "version" : "v1.0.0" , "build_date" : "2023-06-26.10.30.00" }