Skip to content

Commit c5588c8

Browse files
committed
Revert "- Remove the uploaded files state as a condition for whether the submit button is enabled"
This reverts commit 4ebcfc3.
1 parent 4ebcfc3 commit c5588c8

File tree

9 files changed

+19
-54
lines changed

9 files changed

+19
-54
lines changed

tdrs-frontend/cypress/e2e/common-steps/data_files.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ export const uploadFile = (file_input, file_path, willError = false) => {
2424
'exist'
2525
)
2626
cy.get('.usa-alert__text').should('not.exist')
27+
cy.get('button')
28+
.contains('Submit')
29+
.should('not.be.disabled', { timeout: 5000 })
2730
}
2831
}
2932

@@ -198,7 +201,10 @@ export const uploadSectionFile = (
198201
'is-loading'
199202
)
200203
cy.get('.usa-alert__text').should('not.exist')
201-
cy.contains('button', 'Submit').click()
204+
cy.get('button')
205+
.contains('Submit')
206+
.should('not.be.disabled', { timeout: 5000 })
207+
cy.contains('button', 'Submit').should('be.enabled').click()
202208
cy.wait('@dataFileSubmit', { timeout: 60000 }).then(({ response }) => {
203209
const id = response?.body?.id
204210
if (!id) throw new Error('Missing data_file id in response')

tdrs-frontend/src/components/FileUploadForms/QuarterFileUploadForm.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ const QuarterFileUploadForm = ({ stt }) => {
113113
<Button
114114
className="card:margin-y-1"
115115
type="submit"
116-
disabled={isSubmitting}
116+
disabled={isSubmitting || uploadedFiles.length === 0}
117117
>
118118
{isSubmitting ? 'Submitting...' : 'Submit Data Files'}
119119
</Button>

tdrs-frontend/src/components/FileUploadForms/QuarterFileUploadForm.test.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,26 +139,18 @@ describe('QuarterFileUploadForm', () => {
139139
})
140140

141141
describe('Form Submission', () => {
142-
it('shows error alert when submitting with no uploaded files', async () => {
142+
it('does not allow submission with no uploaded files', async () => {
143143
const storeState = {
144144
...initialState,
145145
reports: {
146146
submittedFiles: [],
147147
},
148148
}
149149

150-
const { getByText, getByRole } = renderComponent(storeState)
150+
const { getByText } = renderComponent(storeState)
151151

152152
const submitButton = getByText('Submit Data Files')
153-
fireEvent.click(submitButton)
154-
155-
await waitFor(() => {
156-
const alert = getByRole('alert')
157-
expect(alert).toBeInTheDocument()
158-
expect(alert).toHaveTextContent(
159-
'No changes have been made to data files'
160-
)
161-
})
153+
expect(submitButton).not.toBeEnabled()
162154

163155
expect(mockExecuteSubmission).not.toHaveBeenCalled()
164156
})

tdrs-frontend/src/components/FileUploadForms/SectionFileUploadForm.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const SectionFileUploadForm = ({ stt }) => {
100100
<Button
101101
className="card:margin-y-1"
102102
type="submit"
103-
disabled={isSubmitting}
103+
disabled={isSubmitting || uploadedFiles.length === 0}
104104
>
105105
{isSubmitting ? 'Submitting...' : 'Submit Data Files'}
106106
</Button>

tdrs-frontend/src/components/FileUploadForms/SectionFileUploadForm.test.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,26 +176,18 @@ describe('SectionFileUploadForm', () => {
176176
})
177177

178178
describe('Form Submission', () => {
179-
it('shows error alert when submitting with no uploaded files', async () => {
179+
it('does not allow submission with no uploaded files', async () => {
180180
const storeState = {
181181
...initialState,
182182
reports: {
183183
submittedFiles: [],
184184
},
185185
}
186186

187-
const { getByText, getByRole } = renderComponent(storeState)
187+
const { getByText } = renderComponent(storeState)
188188

189189
const submitButton = getByText('Submit Data Files')
190-
fireEvent.click(submitButton)
191-
192-
await waitFor(() => {
193-
const alert = getByRole('alert')
194-
expect(alert).toBeInTheDocument()
195-
expect(alert).toHaveTextContent(
196-
'No changes have been made to data files'
197-
)
198-
})
190+
expect(submitButton).not.toBeEnabled()
199191

200192
expect(mockExecuteSubmission).not.toHaveBeenCalled()
201193
})

tdrs-frontend/src/components/Reports/FRAReports.jsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -271,15 +271,6 @@ const UploadForm = ({
271271
return
272272
}
273273

274-
if (!file || (file && file.id)) {
275-
setLocalAlertState({
276-
active: true,
277-
type: 'error',
278-
message: 'No changes have been made to data files',
279-
})
280-
return
281-
}
282-
283274
handleUpload({ file })
284275
}
285276

@@ -333,7 +324,7 @@ const UploadForm = ({
333324
<Button
334325
className="card:margin-y-1"
335326
type="submit"
336-
disabled={isSubmitting}
327+
disabled={isSubmitting || fraHasUploadedFile === false}
337328
>
338329
{isSubmitting ? 'Submitting...' : 'Submit Report'}
339330
</Button>

tdrs-frontend/src/components/Reports/FRAReports.test.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -504,13 +504,7 @@ describe('FRA Reports Page', () => {
504504
const { getByText } = await setup()
505505

506506
const submitButton = getByText('Submit Report', { selector: 'button' })
507-
fireEvent.click(submitButton)
508-
509-
await waitFor(() =>
510-
expect(
511-
getByText('No changes have been made to data files')
512-
).toBeInTheDocument()
513-
)
507+
expect(submitButton).not.toBeEnabled()
514508
})
515509

516510
it('Shows an error if a non-allowed file type is selected', async () => {

tdrs-frontend/src/components/Reports/Reports.test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,8 @@ describe('Reports', () => {
407407
await waitFor(() => expect(getByText('section2.txt')).toBeInTheDocument())
408408
await waitFor(() => expect(getByText('section3.txt')).toBeInTheDocument())
409409
await waitFor(() => expect(getByText('section4.txt')).toBeInTheDocument())
410-
await waitFor(() =>
411-
expect(store.dispatch).toHaveBeenCalledTimes(14)
412-
)
410+
await waitFor(() => expect(getByText('Submit Data Files')).toBeEnabled())
411+
expect(store.dispatch).toHaveBeenCalledTimes(14)
413412

414413
fireEvent.click(getByText('Submit Data Files'))
415414
await waitFor(() => getByRole('alert'))

tdrs-frontend/src/hooks/useFileUploadForm.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,6 @@ export const useFileUploadForm = ({
110110
const onSubmit = async (event) => {
111111
event.preventDefault()
112112

113-
if (uploadedFiles.length === 0) {
114-
setLocalAlertState({
115-
active: true,
116-
type: 'error',
117-
message: 'No changes have been made to data files',
118-
})
119-
return
120-
}
121-
122113
try {
123114
// Transform files if needed (e.g., for Program Audit)
124115
const filesToSubmit = transformFiles

0 commit comments

Comments
 (0)