From f2dcd77a541186293ed6dc15f9e88713da833918 Mon Sep 17 00:00:00 2001 From: Anthony Bushara Date: Thu, 6 Feb 2025 17:05:07 -0500 Subject: [PATCH] chore: increase coverage on template_nine api --- .../lib/excel_import/template_nine.test.ts | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/app/tests/backend/lib/excel_import/template_nine.test.ts b/app/tests/backend/lib/excel_import/template_nine.test.ts index a831a136ef..41b50a9750 100644 --- a/app/tests/backend/lib/excel_import/template_nine.test.ts +++ b/app/tests/backend/lib/excel_import/template_nine.test.ts @@ -342,4 +342,52 @@ describe('The Community Progress Report import', () => { expect(response.status).toBe(200); }); + + it('should reject if a guest tries to process applicant rfi endpoint', async () => { + mocked(getAuthRole).mockImplementation(() => { + return { + pgRole: 'ccbc_guest', + landingRoute: '/', + }; + }); + + const response = await request(app).post( + '/api/template-nine/rfi/applicant/1/CCBC-00001-1' + ); + + expect(response.status).toBe(404); + }); + + it('should return 400 if an applicant tries to process bad file', async () => { + mocked(getAuthRole).mockImplementation(() => { + return { + pgRole: 'ccbc_auth_user', + landingRoute: '/', + }; + }); + + const response = await request(app) + .post('/api/template-nine/rfi/applicant/1/CCBC-00001-1') + .set('Content-Type', 'application/json') + .set('Connection', 'keep-alive') + .field('data', JSON.stringify({ name: 'form' })) + .attach('template9', null); + + expect(response.status).toBe(400); + }); + + it('should return 400 if an applicant tries to hit endpoint with bad parameters', async () => { + mocked(getAuthRole).mockImplementation(() => { + return { + pgRole: 'ccbc_auth_user', + landingRoute: '/', + }; + }); + + const response = await request(app).post( + '/api/template-nine/rfi/applicant/null/rfi' + ); + + expect(response.status).toBe(400); + }); });