Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only dispatch upload when file load returns error = false #3495

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

mattcoleanderson
Copy link

@mattcoleanderson mattcoleanderson commented Feb 26, 2025

Summary of Changes

Pull request closes #3478

Recently loading of files was extracted into an async method. Doing so caused all files, regardless of validation to be uploaded. This change only dispatches and upload if the file loading doesn't return an error.

How to Test

List the steps to test the PR

cd tdrs-frontend && docker-compose up --build
cd tdrs-backend && docker-compose up --build
  1. Open http://localhost:3000/ and sign in.
  2. Add a disallowed file such as png
  3. Verify that a validation error is present

image

Deliverables

More details on how deliverables herein are assessed included here.

Deliverable 1: Accepted Features

Checklist of ACs:

  • When selecting a file, the extension should be checked against allowed extensions and show an error

Deliverable 2: Tested Code

  • Are all areas of code introduced in this PR meaningfully tested?
    • If this PR introduces backend code changes, are they meaningfully tested?
    • If this PR introduces frontend code changes, are they meaningfully tested?
  • Are code coverage minimums met?
    • Frontend coverage: [insert coverage %] (see CodeCov Report comment in PR)
    • Backend coverage: [insert coverage %] (see CodeCov Report comment in PR)

Deliverable 3: Properly Styled Code

  • Are backend code style checks passing on CircleCI?
  • Are frontend code style checks passing on CircleCI?
  • Are code maintainability principles being followed?

Deliverable 4: Accessible

  • Does this PR complete the epic?
  • Are links included to any other gov-approved PRs associated with epic?
  • Does PR include documentation for Raft's a11y review?
  • Did automated and manual testing with iamjolly and ttran-hub using Accessibility Insights reveal any errors introduced in this PR?

Deliverable 5: Deployed

  • Was the code successfully deployed via automated CircleCI process to development on Cloud.gov?

Deliverable 6: Documented

  • Does this PR provide background for why coding decisions were made?
  • If this PR introduces backend code, is that code easy to understand and sufficiently documented, both inline and overall?
  • If this PR introduces frontend code, is that code easy to understand and sufficiently documented, both inline and overall?
  • If this PR introduces dependencies, are their licenses documented?
  • Can reviewer explain and take ownership of these elements presented in this code review?

Deliverable 7: Secure

  • Does the OWASP Scan pass on CircleCI?
  • Do manual code review and manual testing detect any new security issues?
  • If new issues detected, is investigation and/or remediation plan documented?

Deliverable 8: User Research

Research product(s) clearly articulate(s):

  • the purpose of the research
  • methods used to conduct the research
  • who participated in the research
  • what was tested and how
  • impact of research on TDP
  • (if applicable) final design mockups produced for TDP development

@mattcoleanderson mattcoleanderson marked this pull request as ready for review February 26, 2025 17:02
Copy link

codecov bot commented Feb 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.65%. Comparing base (8ffdb0f) to head (2be4e0e).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #3495   +/-   ##
========================================
  Coverage    90.64%   90.65%           
========================================
  Files          310      310           
  Lines         8908     8910    +2     
  Branches       677      678    +1     
========================================
+ Hits          8075     8077    +2     
  Misses         704      704           
  Partials       129      129           
Flag Coverage Δ
dev-backend 90.44% <ø> (ø)
dev-frontend 92.08% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...-frontend/src/components/FileUpload/FileUpload.jsx 86.95% <100.00%> (+0.38%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8ffdb0f...2be4e0e. Read the comment docs.

@mattcoleanderson
Copy link
Author

mattcoleanderson commented Feb 26, 2025

@reitermb @victoriaatraft

In this ticket I discovered some buggy code that caused an invalid file to look like the following image. The dotted red line is the collapsed input for uploading a file:

image

The default look of an invalid file is the following:

image

However, the intent of the buggy code (after fixing it) was to look like the following as can be surmised from a comment added to the code ("Get rid of existing previews if they exist, and show instructions):

image

Given this, from a UX perspective which of the latter 2 images would be the best to display in the event that the user chooses an invalid file:

  • Show the name of the invalid file that was chosen by the user
  • Show the instructions for the file input

@mattcoleanderson mattcoleanderson self-assigned this Feb 26, 2025
@mattcoleanderson mattcoleanderson added bug frontend raft review This issue is ready for raft review labels Feb 26, 2025
@reitermb reitermb added the Deploy with CircleCI-a11y Deploy to https://tdp-frontend-a11y.app.cloud.gov through CircleCI label Feb 26, 2025
Copy link

@reitermb reitermb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good a11y wise (and in terms of behavior)
image

Copy link

@elipe17 elipe17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mattcoleanderson mattcoleanderson added QASP Review and removed raft review This issue is ready for raft review labels Feb 27, 2025
@mattcoleanderson mattcoleanderson requested review from ADPennington and removed request for ADPennington February 27, 2025 19:44
@lhuxraft lhuxraft added raft review This issue is ready for raft review and removed QASP Review labels Feb 28, 2025
Copy link

@raftmsohani raftmsohani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lhuxraft lhuxraft added QASP Review and removed raft review This issue is ready for raft review labels Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Deploy with CircleCI-a11y Deploy to https://tdp-frontend-a11y.app.cloud.gov through CircleCI frontend QASP Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix missing file extension validation on Data Files page
5 participants