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

103296 update uploads controller unit tests #21139

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

brostk
Copy link
Contributor

@brostk brostk commented Mar 6, 2025

Note: Delete the description statements, complete each step. None are optional, but can be justified as to why they cannot be completed as written. Provide known gaps to testing that may raise the risk of merging to production.

Summary

  • This work is behind a feature toggle (flipper): NO
  • added an else condition, with corresponding unit tests, for invalid form IDs being passed to submit_supporting_documents
  • added tests to cover when the require_all_s3_success feature is enabled
  • added additional handle_uploads tests for other error conditions
  • added submit_supporting_documents tests for error conditions
  • rewrote get_attachment_ids_and_forms tests to test method functionality, not mocks
  • rewrote supporting_document_ids tests to test method functionality, not mocks
  • removed generate_attachment_ids test, since the method does not exist and only tested mock functionality

Related issue(s)

Testing done

  • New code is covered by unit tests
  • The new else condition on submit_supporting_documents is validated with new unit tests, which test both successful and failure cases
  • All unit tests are passing

Screenshots

Note: Optional

What areas of the site does it impact?

  • The uploads_controller change now throws an error when an invalid form ID is passed to the controller, when previously we were returning a 204 even though nothing was done on the server; arguably this should be an error condition because the form ID is not submitted in this case. This would occur when submitting IVC CHAMPVA forms to the backend with an invalid form ID, which should not occur due to the way the front end is coded.

Acceptance criteria

  • I fixed|updated|added unit tests and integration tests for each feature (if applicable).
  • No error nor warning in the console.
  • Events are being sent to the appropriate logging solution
  • Documentation has been updated (link to documentation)
  • No sensitive information (i.e. PII/credentials/internal URLs/etc.) is captured in logging, hardcoded, or specs
  • Feature/bug has a monitor built into Datadog (if applicable)
  • If app impacted requires authentication, did you login to a local build and verify all authenticated routes work as expected
  • I added a screenshot of the developed feature

Requested Feedback

(OPTIONAL)What should the reviewers know in addition to the above. Is there anything specific you wish the reviewer to assist with. Do you have any concerns with this PR, why?

Copy link

github-actions bot commented Mar 6, 2025

1 Warning
⚠️ This PR changes 314 LoC (not counting whitespace/newlines).

In order to ensure each PR receives the proper attention it deserves, we recommend not exceeding
200. Expect some delays getting reviews.

File Summary

Files

  • modules/ivc_champva/app/controllers/ivc_champva/v1/uploads_controller.rb (+5/-0)

  • modules/ivc_champva/spec/requests/ivc_champva/v1/forms/uploads_spec.rb (+231/-78)

    Note: We exclude files matching the following when considering PR size:

    *.csv, *.json, *.tsv, *.txt, *.md, Gemfile.lock, app/swagger, modules/mobile/docs, spec/fixtures/, spec/support/vcr_cassettes/, modules/mobile/spec/support/vcr_cassettes/, db/seeds, modules/vaos/app/docs, modules/meb_api/app/docs, modules/appeals_api/app/swagger/, *.bru, *.pdf
    

Big PRs are difficult to review, often become stale, and cause delays.

Generated by 🚫 Danger

@va-vfs-bot va-vfs-bot temporarily deployed to 103296-update-uploads-controller-unit-tests/main/main March 6, 2025 20:24 Inactive
@va-vfs-bot va-vfs-bot temporarily deployed to 103296-update-uploads-controller-unit-tests/main/main March 7, 2025 14:18 Inactive
@va-vfs-bot va-vfs-bot temporarily deployed to 103296-update-uploads-controller-unit-tests/main/main March 7, 2025 14:39 Inactive
@va-vfs-bot va-vfs-bot temporarily deployed to 103296-update-uploads-controller-unit-tests/main/main March 7, 2025 15:49 Inactive
brostk added 2 commits March 7, 2025 11:17
…com:department-of-veterans-affairs/vets-api into 103296-update-uploads-controller-unit-tests
@va-vfs-bot va-vfs-bot temporarily deployed to 103296-update-uploads-controller-unit-tests/main/main March 7, 2025 16:20 Inactive

statuses, error_message = controller.send(:handle_file_uploads, form_id, parsed_form_data)

# TODO: should this be nil, or 400/'Upload failed'?
Copy link
Contributor

@michaelclement michaelclement Mar 7, 2025

Choose a reason for hiding this comment

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

I suspect this is because the retry logic inside handle_file_uploads fails - that might cause [statuses, error_messages] to be undefined, which is probably the source of these undefined method 'uniq' for nil errors we see from time to time.

Not sure we need to do anything about this right now, but this is a good lead for a followup ticket to fix that bug.

Copy link
Contributor

Choose a reason for hiding this comment

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

(To answer the question, I believe it should be 400/'Upload failed')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. You're right - inside handle_file_uploads, we're returning [statuses, error_messages] without them necessarily having been initialized. 400/'Upload failed' would definitely be more appropriate.

@va-vfs-bot va-vfs-bot temporarily deployed to 103296-update-uploads-controller-unit-tests/main/main March 7, 2025 17:48 Inactive
Copy link
Contributor

@michaelclement michaelclement left a comment

Choose a reason for hiding this comment

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

Nice work!

@va-vfs-bot va-vfs-bot temporarily deployed to 103296-update-uploads-controller-unit-tests/main/main March 7, 2025 17:56 Inactive
@va-vfs-bot va-vfs-bot temporarily deployed to 103296-update-uploads-controller-unit-tests/main/main March 7, 2025 18:05 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants