From 08b4be9f876ad60d162067f2292e032931187a1b Mon Sep 17 00:00:00 2001 From: Eric Lipe Date: Thu, 24 Aug 2023 12:30:32 -0600 Subject: [PATCH 01/14] - small grammar fix --- tdrs-backend/tdpservice/data_files/validators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tdrs-backend/tdpservice/data_files/validators.py b/tdrs-backend/tdpservice/data_files/validators.py index 2f78231cb..a4d0f0bc8 100644 --- a/tdrs-backend/tdpservice/data_files/validators.py +++ b/tdrs-backend/tdpservice/data_files/validators.py @@ -22,7 +22,7 @@ def _get_unsupported_msg(_type, value, supported_options): """Construct a message to convey an unsupported operation.""" return ( - f'Unsupported {_type}: {value}, supported {pluralize(_type)} ' + f'Unsupported {_type}: supported {pluralize(_type)} ' f'are: {supported_options}' ) From 9fd06304490b3b6735345ece4ba54c88a3138ae4 Mon Sep 17 00:00:00 2001 From: Eric Lipe Date: Mon, 28 Aug 2023 09:48:34 -0600 Subject: [PATCH 02/14] - Fix lint suggestions --- tdrs-frontend/src/actions/requestAccess.js | 1 - tdrs-frontend/src/components/Paginator/Paginator.test.js | 2 +- tdrs-frontend/src/components/SiteMap/SiteMap.test.js | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/tdrs-frontend/src/actions/requestAccess.js b/tdrs-frontend/src/actions/requestAccess.js index 668420c65..50c1f0ce5 100644 --- a/tdrs-frontend/src/actions/requestAccess.js +++ b/tdrs-frontend/src/actions/requestAccess.js @@ -1,6 +1,5 @@ import { SET_AUTH } from './auth' import axios from 'axios' -import axiosInstance from '../axios-instance' import { logErrorToServer } from '../utils/eventLogger' export const PATCH_REQUEST_ACCESS = 'PATCH_REQUEST_ACCESS' diff --git a/tdrs-frontend/src/components/Paginator/Paginator.test.js b/tdrs-frontend/src/components/Paginator/Paginator.test.js index 5eb868856..06390986d 100644 --- a/tdrs-frontend/src/components/Paginator/Paginator.test.js +++ b/tdrs-frontend/src/components/Paginator/Paginator.test.js @@ -1,5 +1,5 @@ import React from 'react' -import { render, fireEvent, waitFor, screen } from '@testing-library/react' +import { render, fireEvent, screen } from '@testing-library/react' import Paginator from './Paginator' describe('Paginator', () => { diff --git a/tdrs-frontend/src/components/SiteMap/SiteMap.test.js b/tdrs-frontend/src/components/SiteMap/SiteMap.test.js index 2b435064d..236c653fe 100644 --- a/tdrs-frontend/src/components/SiteMap/SiteMap.test.js +++ b/tdrs-frontend/src/components/SiteMap/SiteMap.test.js @@ -1,7 +1,6 @@ import React from 'react' import { render } from '@testing-library/react' import SiteMap from './SiteMap' -import { mount } from 'enzyme' import thunk from 'redux-thunk' import { Provider } from 'react-redux' import configureStore from 'redux-mock-store' From 29a94635c5f90aaab9414a0fca7700fb189bf630 Mon Sep 17 00:00:00 2001 From: Eric Lipe Date: Mon, 28 Aug 2023 13:33:16 -0600 Subject: [PATCH 03/14] - updated message --- tdrs-frontend/src/actions/reports.js | 2 +- tdrs-frontend/src/actions/reports.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tdrs-frontend/src/actions/reports.js b/tdrs-frontend/src/actions/reports.js index fa5e4a480..344a7158c 100644 --- a/tdrs-frontend/src/actions/reports.js +++ b/tdrs-frontend/src/actions/reports.js @@ -254,7 +254,7 @@ export const submit = setLocalAlertState({ active: true, type: 'error', - message: error.message, + message: ''.concat(error.message, ': ', error.response?.data?.file[0]), }) ) } diff --git a/tdrs-frontend/src/actions/reports.test.js b/tdrs-frontend/src/actions/reports.test.js index 54bde8d6c..40593f3bb 100644 --- a/tdrs-frontend/src/actions/reports.test.js +++ b/tdrs-frontend/src/actions/reports.test.js @@ -201,7 +201,7 @@ describe('actions/reports', () => { expect(axios.post).toHaveBeenCalledTimes(1) expect(setLocalAlertState).toHaveBeenCalledWith({ active: true, - message: undefined, + message: 'undefined: undefined', type: 'error', }) }) From 66b87f453db4e2a6df6cc95dcd2b70aa6df09b4a Mon Sep 17 00:00:00 2001 From: Eric Lipe Date: Mon, 28 Aug 2023 15:25:31 -0600 Subject: [PATCH 04/14] - Fixed lint errors --- tdrs-frontend/src/actions/reports.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tdrs-frontend/src/actions/reports.js b/tdrs-frontend/src/actions/reports.js index 344a7158c..117b2752a 100644 --- a/tdrs-frontend/src/actions/reports.js +++ b/tdrs-frontend/src/actions/reports.js @@ -254,7 +254,11 @@ export const submit = setLocalAlertState({ active: true, type: 'error', - message: ''.concat(error.message, ': ', error.response?.data?.file[0]), + message: ''.concat( + error.message, + ': ', + error.response?.data?.file[0] + ), }) ) } From 6ead8b4e88455930f8fa5970117fea9916e89d32 Mon Sep 17 00:00:00 2001 From: Eric Lipe Date: Thu, 31 Aug 2023 10:52:03 -0600 Subject: [PATCH 05/14] - Added correct extension to datafiles without one --- ...ack => ADS.E2J.NDM1.TS53_fake.rollback.txt} | 0 .../{small_bad_ssp_s1 => small_bad_ssp_s1.txt} | 0 ...small_bad_tanf_s1 => small_bad_tanf_s1.txt} | 0 ...all_correct_file => small_correct_file.txt} | 0 .../tdpservice/parsers/test/test_parse.py | 18 +++++++++--------- .../search_indexes/test/test_model_mapping.py | 4 ++-- .../cypress/e2e/integration/file_upload.js | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) rename tdrs-backend/tdpservice/parsers/test/data/{ADS.E2J.NDM1.TS53_fake.rollback => ADS.E2J.NDM1.TS53_fake.rollback.txt} (100%) rename tdrs-backend/tdpservice/parsers/test/data/{small_bad_ssp_s1 => small_bad_ssp_s1.txt} (100%) rename tdrs-backend/tdpservice/parsers/test/data/{small_bad_tanf_s1 => small_bad_tanf_s1.txt} (100%) rename tdrs-backend/tdpservice/parsers/test/data/{small_correct_file => small_correct_file.txt} (100%) diff --git a/tdrs-backend/tdpservice/parsers/test/data/ADS.E2J.NDM1.TS53_fake.rollback b/tdrs-backend/tdpservice/parsers/test/data/ADS.E2J.NDM1.TS53_fake.rollback.txt similarity index 100% rename from tdrs-backend/tdpservice/parsers/test/data/ADS.E2J.NDM1.TS53_fake.rollback rename to tdrs-backend/tdpservice/parsers/test/data/ADS.E2J.NDM1.TS53_fake.rollback.txt diff --git a/tdrs-backend/tdpservice/parsers/test/data/small_bad_ssp_s1 b/tdrs-backend/tdpservice/parsers/test/data/small_bad_ssp_s1.txt similarity index 100% rename from tdrs-backend/tdpservice/parsers/test/data/small_bad_ssp_s1 rename to tdrs-backend/tdpservice/parsers/test/data/small_bad_ssp_s1.txt diff --git a/tdrs-backend/tdpservice/parsers/test/data/small_bad_tanf_s1 b/tdrs-backend/tdpservice/parsers/test/data/small_bad_tanf_s1.txt similarity index 100% rename from tdrs-backend/tdpservice/parsers/test/data/small_bad_tanf_s1 rename to tdrs-backend/tdpservice/parsers/test/data/small_bad_tanf_s1.txt diff --git a/tdrs-backend/tdpservice/parsers/test/data/small_correct_file b/tdrs-backend/tdpservice/parsers/test/data/small_correct_file.txt similarity index 100% rename from tdrs-backend/tdpservice/parsers/test/data/small_correct_file rename to tdrs-backend/tdpservice/parsers/test/data/small_correct_file.txt diff --git a/tdrs-backend/tdpservice/parsers/test/test_parse.py b/tdrs-backend/tdpservice/parsers/test/test_parse.py index 4a538ae8a..4ee5b07c6 100644 --- a/tdrs-backend/tdpservice/parsers/test/test_parse.py +++ b/tdrs-backend/tdpservice/parsers/test/test_parse.py @@ -15,13 +15,13 @@ @pytest.fixture def test_datafile(stt_user, stt): - """Fixture for small_correct_file.""" - return create_test_datafile('small_correct_file', stt_user, stt) + """Fixture for small_correct_file.txt.""" + return create_test_datafile('small_correct_file.txt', stt_user, stt) @pytest.mark.django_db() def test_parse_small_correct_file(test_datafile): - """Test parsing of small_correct_file.""" + """Test parsing of small_correct_file.txt.""" errors = parse.parse_datafile(test_datafile) errors = ParserError.objects.filter(file=test_datafile) assert errors.count() == 0 @@ -44,7 +44,7 @@ def test_parse_small_correct_file(test_datafile): @pytest.mark.django_db() def test_parse_section_mismatch(test_datafile): - """Test parsing of small_correct_file where the DataFile section doesn't match the rawfile section.""" + """Test parsing of small_correct_file.txt where the DataFile section doesn't match the rawfile section.""" test_datafile.section = 'Closed Case Data' test_datafile.save() @@ -67,7 +67,7 @@ def test_parse_section_mismatch(test_datafile): @pytest.mark.django_db() def test_parse_wrong_program_type(test_datafile): - """Test parsing of small_correct_file where the DataFile program type doesn't match the rawfile.""" + """Test parsing of small_correct_file.txt where the DataFile program type doesn't match the rawfile.""" test_datafile.section = 'SSP Active Case Data' test_datafile.save() @@ -457,8 +457,8 @@ def test_parse_super_big_s1_file(super_big_s1_file): @pytest.fixture def super_big_s1_rollback_file(stt_user, stt): - """Fixture for ADS.E2J.NDM1.TS53_fake.rollback.""" - return create_test_datafile('ADS.E2J.NDM1.TS53_fake.rollback', stt_user, stt) + """Fixture for ADS.E2J.NDM1.TS53_fake.rollback.txt.""" + return create_test_datafile('ADS.E2J.NDM1.TS53_fake.rollback.txt', stt_user, stt) @pytest.mark.django_db() def test_parse_super_big_s1_file_with_rollback(super_big_s1_rollback_file): @@ -487,7 +487,7 @@ def test_parse_super_big_s1_file_with_rollback(super_big_s1_rollback_file): @pytest.fixture def bad_tanf_s1__row_missing_required_field(stt_user, stt): """Fixture for small_tanf_section1.""" - return create_test_datafile('small_bad_tanf_s1', stt_user, stt) + return create_test_datafile('small_bad_tanf_s1.txt', stt_user, stt) @pytest.mark.django_db() @@ -528,7 +528,7 @@ def test_parse_bad_tfs1_missing_required(bad_tanf_s1__row_missing_required_field @pytest.fixture def bad_ssp_s1__row_missing_required_field(stt_user, stt): """Fixture for ssp_section1_datafile.""" - return create_test_datafile('small_bad_ssp_s1', stt_user, stt, 'SSP Active Case Data') + return create_test_datafile('small_bad_ssp_s1.txt', stt_user, stt, 'SSP Active Case Data') @pytest.mark.django_db() diff --git a/tdrs-backend/tdpservice/search_indexes/test/test_model_mapping.py b/tdrs-backend/tdpservice/search_indexes/test/test_model_mapping.py index cd762eb56..e3bbb9cac 100644 --- a/tdrs-backend/tdpservice/search_indexes/test/test_model_mapping.py +++ b/tdrs-backend/tdpservice/search_indexes/test/test_model_mapping.py @@ -13,8 +13,8 @@ @pytest.fixture def test_datafile(stt_user, stt): - """Fixture for small_correct_file.""" - return create_test_datafile('small_correct_file', stt_user, stt) + """Fixture for small_correct_file.txt.""" + return create_test_datafile('small_correct_file.txt', stt_user, stt) @pytest.mark.django_db diff --git a/tdrs-frontend/cypress/e2e/integration/file_upload.js b/tdrs-frontend/cypress/e2e/integration/file_upload.js index a92b26d52..35cd400ab 100644 --- a/tdrs-frontend/cypress/e2e/integration/file_upload.js +++ b/tdrs-frontend/cypress/e2e/integration/file_upload.js @@ -5,7 +5,7 @@ Then('{string} can see Data Files page', (username) => { cy.visit('/data-files') cy.contains('Data Files').should('exist') }) - + Then('{string} can see search form', (username) => { cy.contains('Fiscal Year').should('exist') cy.contains('Quarter').should('exist') @@ -19,7 +19,7 @@ Then('{string} can browse upload file form', (username) => { When('{string} uploads a file', (username) => { cy.get('button').contains('Search').should('exist').click() - cy.get('#closed-case-data').selectFile('../tdrs-backend/tdpservice/parsers/test/data/small_correct_file',{ action: 'drag-drop' }) + cy.get('#closed-case-data').selectFile('../tdrs-backend/tdpservice/parsers/test/data/small_correct_file.txt',{ action: 'drag-drop' }) cy.get('button').contains('Submit Data Files').should('exist').click() }) From 153472a8fa3a3abd982a6c837b0f459e076e4128 Mon Sep 17 00:00:00 2001 From: Eric Lipe Date: Thu, 31 Aug 2023 13:26:33 -0600 Subject: [PATCH 06/14] - Adding cherry picks for file extension error handling --- tdrs-frontend/src/actions/reports.js | 1 + .../src/components/FileUpload/FileUpload.jsx | 23 +++++++++++++++++++ tdrs-frontend/src/reducers/reports.js | 6 +++++ 3 files changed, 30 insertions(+) diff --git a/tdrs-frontend/src/actions/reports.js b/tdrs-frontend/src/actions/reports.js index 117b2752a..8ecb8839e 100644 --- a/tdrs-frontend/src/actions/reports.js +++ b/tdrs-frontend/src/actions/reports.js @@ -11,6 +11,7 @@ export const SET_FILE = 'SET_FILE' export const CLEAR_FILE = 'CLEAR_FILE' export const CLEAR_FILE_LIST = 'CLEAR_FILE_LIST' export const SET_FILE_ERROR = 'SET_FILE_ERROR' +export const FILE_EXT_ERROR = 'FILE_EXT_ERROR' export const SET_FILE_SUBMITTED = 'SET_FILE_SUBMITTED' export const CLEAR_ERROR = 'CLEAR_ERROR' diff --git a/tdrs-frontend/src/components/FileUpload/FileUpload.jsx b/tdrs-frontend/src/components/FileUpload/FileUpload.jsx index 0deea1216..2c8fb2093 100644 --- a/tdrs-frontend/src/components/FileUpload/FileUpload.jsx +++ b/tdrs-frontend/src/components/FileUpload/FileUpload.jsx @@ -7,6 +7,7 @@ import { clearError, clearFile, SET_FILE_ERROR, + FILE_EXT_ERROR, upload, download, } from '../../actions/reports' @@ -17,6 +18,9 @@ import { handlePreview, getTargetClassName } from './utils' const INVALID_FILE_ERROR = 'We can’t process that file format. Please provide a plain text file.' +const INVALID_EXT_ERROR = + 'Invalid extension. Accepted file types are: .txt, .ms##, .ts##, or .ts###.' + function FileUpload({ section, setLocalAlertState }) { // e.g. 'Aggregate Case Data' => 'aggregate-case-data' // The set of uploaded files in our Redux state @@ -89,6 +93,25 @@ function FileUpload({ section, setLocalAlertState }) { filereader.onloadend = (evt) => { /* istanbul ignore next */ if (!evt.target.error) { + // Validate file extension before proceeding + const re = /(\.txt|\.ms\d{2}|\.ts\d{2,3})/i + const filename = file.name + const n = filename.lastIndexOf('.') + const ext = filename.substring(n) + if (!re.exec(ext)) { + // reject the file and create an error message + createFileInputErrorState(input, dropTarget) + + dispatch({ + type: FILE_EXT_ERROR, + payload: { + error: { message: INVALID_EXT_ERROR }, + section, + }, + }) + return + } + // Read in the file blob "headers: and create a hex string signature const uint = new Uint8Array(evt.target.result) const bytes = [] diff --git a/tdrs-frontend/src/reducers/reports.js b/tdrs-frontend/src/reducers/reports.js index fb8698889..ac16c6ac6 100644 --- a/tdrs-frontend/src/reducers/reports.js +++ b/tdrs-frontend/src/reducers/reports.js @@ -2,6 +2,7 @@ import { SET_FILE, CLEAR_FILE, SET_FILE_ERROR, + FILE_EXT_ERROR, CLEAR_ERROR, SET_SELECTED_YEAR, SET_SELECTED_STT, @@ -175,6 +176,11 @@ const reports = (state = initialState, action) => { const updatedFiles = getUpdatedFiles({ state, section, error }) return { ...state, submittedFiles: updatedFiles } } + case FILE_EXT_ERROR: { + const { error, section } = payload + const updatedFiles = getUpdatedFiles({ state, section, error }) + return { ...state, submittedFiles: updatedFiles } + } case CLEAR_ERROR: { const { section } = payload const file = getFile(state.submittedFiles, section) From e2b1551b8b5d879e32f4fb2f0da3a903668d1b26 Mon Sep 17 00:00:00 2001 From: Eric Lipe Date: Tue, 5 Sep 2023 11:22:12 -0600 Subject: [PATCH 07/14] - Updated regex --- tdrs-frontend/src/components/FileUpload/FileUpload.jsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tdrs-frontend/src/components/FileUpload/FileUpload.jsx b/tdrs-frontend/src/components/FileUpload/FileUpload.jsx index 2c8fb2093..35dc66cf1 100644 --- a/tdrs-frontend/src/components/FileUpload/FileUpload.jsx +++ b/tdrs-frontend/src/components/FileUpload/FileUpload.jsx @@ -94,11 +94,8 @@ function FileUpload({ section, setLocalAlertState }) { /* istanbul ignore next */ if (!evt.target.error) { // Validate file extension before proceeding - const re = /(\.txt|\.ms\d{2}|\.ts\d{2,3})/i - const filename = file.name - const n = filename.lastIndexOf('.') - const ext = filename.substring(n) - if (!re.exec(ext)) { + const re = /(\.txt|\.ms\d{2}|\.ts\d{2,3})$/i + if (!re.exec(file.name)) { // reject the file and create an error message createFileInputErrorState(input, dropTarget) From 1520097965172cd301edb5a9737c4a52b41536c0 Mon Sep 17 00:00:00 2001 From: Eric Lipe Date: Tue, 19 Sep 2023 15:33:48 -0600 Subject: [PATCH 08/14] - updating to keep file in dropbox in event of error to help user correct their mistake. --- tdrs-frontend/src/components/FileUpload/FileUpload.jsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/tdrs-frontend/src/components/FileUpload/FileUpload.jsx b/tdrs-frontend/src/components/FileUpload/FileUpload.jsx index 35dc66cf1..9df223cd4 100644 --- a/tdrs-frontend/src/components/FileUpload/FileUpload.jsx +++ b/tdrs-frontend/src/components/FileUpload/FileUpload.jsx @@ -96,9 +96,6 @@ function FileUpload({ section, setLocalAlertState }) { // Validate file extension before proceeding const re = /(\.txt|\.ms\d{2}|\.ts\d{2,3})$/i if (!re.exec(file.name)) { - // reject the file and create an error message - createFileInputErrorState(input, dropTarget) - dispatch({ type: FILE_EXT_ERROR, payload: { From c997c69acfbe122fe8ed947fe7f3770cdd180ab8 Mon Sep 17 00:00:00 2001 From: Eric Lipe Date: Wed, 27 Sep 2023 09:52:03 -0600 Subject: [PATCH 09/14] - Fix icon rendering incorrectly --- tdrs-frontend/src/components/FileUpload/FileUpload.jsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tdrs-frontend/src/components/FileUpload/FileUpload.jsx b/tdrs-frontend/src/components/FileUpload/FileUpload.jsx index 9df223cd4..a27c75e55 100644 --- a/tdrs-frontend/src/components/FileUpload/FileUpload.jsx +++ b/tdrs-frontend/src/components/FileUpload/FileUpload.jsx @@ -35,6 +35,10 @@ function FileUpload({ section, setLocalAlertState }) { (file) => file.section.includes(sectionName) && file.uuid ) + const hasPreview = files?.some( + (file) => file.section.includes(sectionName) && file.name + ) + const selectedFile = files?.find((file) => file.section.includes(sectionName)) const formattedSectionName = selectedFile?.section @@ -58,8 +62,10 @@ function FileUpload({ section, setLocalAlertState }) { setTimeout(trySettingPreview, 100) } } - if (hasFile) trySettingPreview() - }, [hasFile, fileName, targetClassName]) + if (hasPreview) { + trySettingPreview() + } + }, [hasPreview, fileName, targetClassName]) const downloadFile = ({ target }) => { dispatch(clearError({ section: sectionName })) From 6a056a878ae32ed8e1966dbf2c014b1b4d128a76 Mon Sep 17 00:00:00 2001 From: Jan Timpe Date: Fri, 29 Sep 2023 13:26:28 -0400 Subject: [PATCH 10/14] update test file extensions --- tdrs-backend/tdpservice/parsers/test/test_parse.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tdrs-backend/tdpservice/parsers/test/test_parse.py b/tdrs-backend/tdpservice/parsers/test/test_parse.py index 9c785f79f..a92cc4946 100644 --- a/tdrs-backend/tdpservice/parsers/test/test_parse.py +++ b/tdrs-backend/tdpservice/parsers/test/test_parse.py @@ -19,7 +19,7 @@ @pytest.fixture def test_datafile(stt_user, stt): """Fixture for small_correct_file.""" - return util.create_test_datafile('small_correct_file', stt_user, stt) + return util.create_test_datafile('small_correct_file.txt', stt_user, stt) @pytest.fixture def dfs(): @@ -597,7 +597,7 @@ def test_parse_super_big_s1_file_with_rollback(super_big_s1_rollback_file): @pytest.fixture def bad_tanf_s1__row_missing_required_field(stt_user, stt): """Fixture for small_tanf_section1.""" - return util.create_test_datafile('small_bad_tanf_s1', stt_user, stt) + return util.create_test_datafile('small_bad_tanf_s1.txt', stt_user, stt) @pytest.mark.django_db @@ -644,7 +644,7 @@ def test_parse_bad_tfs1_missing_required(bad_tanf_s1__row_missing_required_field @pytest.fixture def bad_ssp_s1__row_missing_required_field(stt_user, stt): """Fixture for ssp_section1_datafile.""" - return util.create_test_datafile('small_bad_ssp_s1', stt_user, stt, 'SSP Active Case Data') + return util.create_test_datafile('small_bad_ssp_s1.txt', stt_user, stt, 'SSP Active Case Data') @pytest.mark.django_db() From b4b351272214383c65657495c4a92285061c5225 Mon Sep 17 00:00:00 2001 From: Eric Lipe Date: Tue, 3 Oct 2023 11:01:48 -0600 Subject: [PATCH 11/14] - making timeout longer --- tdrs-frontend/src/components/UploadReport/UploadReport.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tdrs-frontend/src/components/UploadReport/UploadReport.test.js b/tdrs-frontend/src/components/UploadReport/UploadReport.test.js index 5a307c313..825f81dcd 100644 --- a/tdrs-frontend/src/components/UploadReport/UploadReport.test.js +++ b/tdrs-frontend/src/components/UploadReport/UploadReport.test.js @@ -158,7 +158,7 @@ describe('UploadReport', () => { expect(headings.length).toBeTruthy() done() - }, 100) + }, 1000) }) it('should render a div with class "usa-form-group--error" if there is an error', () => { From 46acf0a3da9d272e1d0cd560b256fd75c3b8ef85 Mon Sep 17 00:00:00 2001 From: Eric Lipe Date: Tue, 3 Oct 2023 11:32:00 -0600 Subject: [PATCH 12/14] - Resolved issue causing test failure - resetting timeout --- tdrs-frontend/src/components/FileUpload/FileUpload.jsx | 2 +- tdrs-frontend/src/components/UploadReport/UploadReport.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tdrs-frontend/src/components/FileUpload/FileUpload.jsx b/tdrs-frontend/src/components/FileUpload/FileUpload.jsx index a27c75e55..b3fbc074f 100644 --- a/tdrs-frontend/src/components/FileUpload/FileUpload.jsx +++ b/tdrs-frontend/src/components/FileUpload/FileUpload.jsx @@ -62,7 +62,7 @@ function FileUpload({ section, setLocalAlertState }) { setTimeout(trySettingPreview, 100) } } - if (hasPreview) { + if (hasPreview || hasFile) { trySettingPreview() } }, [hasPreview, fileName, targetClassName]) diff --git a/tdrs-frontend/src/components/UploadReport/UploadReport.test.js b/tdrs-frontend/src/components/UploadReport/UploadReport.test.js index 825f81dcd..5a307c313 100644 --- a/tdrs-frontend/src/components/UploadReport/UploadReport.test.js +++ b/tdrs-frontend/src/components/UploadReport/UploadReport.test.js @@ -158,7 +158,7 @@ describe('UploadReport', () => { expect(headings.length).toBeTruthy() done() - }, 1000) + }, 100) }) it('should render a div with class "usa-form-group--error" if there is an error', () => { From 55bdc1cd7a598d26f4e4801c97568b4c04094620 Mon Sep 17 00:00:00 2001 From: Eric Lipe Date: Tue, 3 Oct 2023 14:12:15 -0600 Subject: [PATCH 13/14] - passing param --- tdrs-frontend/src/components/FileUpload/FileUpload.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tdrs-frontend/src/components/FileUpload/FileUpload.jsx b/tdrs-frontend/src/components/FileUpload/FileUpload.jsx index b3fbc074f..d8a21476b 100644 --- a/tdrs-frontend/src/components/FileUpload/FileUpload.jsx +++ b/tdrs-frontend/src/components/FileUpload/FileUpload.jsx @@ -65,7 +65,7 @@ function FileUpload({ section, setLocalAlertState }) { if (hasPreview || hasFile) { trySettingPreview() } - }, [hasPreview, fileName, targetClassName]) + }, [hasPreview, hasFile, fileName, targetClassName]) const downloadFile = ({ target }) => { dispatch(clearError({ section: sectionName })) From 3d9d70de826292871fe1e62836492171fa7ff9ad Mon Sep 17 00:00:00 2001 From: Eric Lipe Date: Wed, 11 Oct 2023 12:28:55 -0600 Subject: [PATCH 14/14] - updated nginx conf --- tdrs-frontend/nginx/cloud.gov/buildpack.nginx.conf | 8 ++++---- tdrs-frontend/nginx/local/default.conf.template | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tdrs-frontend/nginx/cloud.gov/buildpack.nginx.conf b/tdrs-frontend/nginx/cloud.gov/buildpack.nginx.conf index 1ab4677bb..4ed6804f9 100644 --- a/tdrs-frontend/nginx/cloud.gov/buildpack.nginx.conf +++ b/tdrs-frontend/nginx/cloud.gov/buildpack.nginx.conf @@ -21,9 +21,9 @@ http { log_format compression '$remote_addr - $remote_user [$time_local] ' '"proxy_host and upstream_addr": $proxy_host $upstream_addr, ' ' "request": $request, ' - '"body_bytes_sent" : $body_bytes_sent, ' + '"body_bytes_sent" : $body_bytes_sent, ' '"request_body": $request_body, ' - '"http_x_forwarded_for": $http_x_forwarded_for, ' + '"http_x_forwarded_for": $http_x_forwarded_for, ' '"host": $host, ' ' "status": $status, ' '"proxy_add_x_forwarded_for": $proxy_add_x_forwarded_for, ' @@ -47,7 +47,7 @@ http { } client_max_body_size 100m; - + # Block all requests except ones listed in whitelist; disabled for local # First have to correct the source IP address using real_ip_header, otherwise # the IP address will be the internal IP address of the router @@ -63,7 +63,7 @@ http { set $CSP "default-src 'self';"; set $CSP "${CSP}script-src 'self';"; set $CSP "${CSP}script-src-elem 'self';"; - set $CSP "${CSP}script-src-attr 'self';"; + set $CSP "${CSP}script-src-attr 'self' 'unsafe-inline';"; set $CSP "${CSP}img-src 'self' data:;"; set $CSP "${CSP}font-src 'self';"; set $CSP "${CSP}connect-src 'self' ${CONNECT_SRC};"; diff --git a/tdrs-frontend/nginx/local/default.conf.template b/tdrs-frontend/nginx/local/default.conf.template index 2243c720b..c4d306340 100644 --- a/tdrs-frontend/nginx/local/default.conf.template +++ b/tdrs-frontend/nginx/local/default.conf.template @@ -82,7 +82,7 @@ http { set $CSP "${CSP}prefetch-src 'none';"; set $CSP "${CSP}form-action *;"; set $CSP "${CSP}script-src-elem 'self' http://localhost:* http://www.w3.org;"; - set $CSP "${CSP}script-src-attr 'self';"; + set $CSP "${CSP}script-src-attr 'self' 'unsafe-inline';"; set $CSP "${CSP}style-src-elem 'self' 'unsafe-inline';"; set $CSP "${CSP}style-src-attr 'self';"; set $CSP "${CSP}worker-src 'none';"; @@ -104,7 +104,7 @@ http { access_log /dev/stdout compression; #access_log stderr compression; - + # Content caching # saves cached fies in /tmp # cache zone name = tdp_cache @@ -126,7 +126,7 @@ http { set $CSP "default-src 'self';"; set $CSP "${CSP}script-src 'self';"; set $CSP "${CSP}script-src-elem 'self';"; - set $CSP "${CSP}script-src-attr 'self';"; + set $CSP "${CSP}script-src-attr 'self' 'unsafe-inline';"; set $CSP "${CSP}img-src 'self' data:;"; set $CSP "${CSP}font-src 'self';"; set $CSP "${CSP}manifest-src 'self';";