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

Fix confirmation email personalization bug - IVC CHAMPVA forms #20382

Merged
merged 1 commit into from
Jan 21, 2025

Conversation

michaelclement
Copy link
Contributor

@michaelclement michaelclement commented Jan 21, 2025

Summary

Due to a change introduced in this PR, the date_submitted property was not being passed in the VA Notify personalization block for IVC CHAMPVA form confirmation emails. This caused the emails to not trigger.

This PR adds the date_submitted property into the form data object so that VA Notify successfully triggers an email job.

To verify

  1. Open an Argo staging terminal for vets-api web and run bundle exec rails c
  2. Paste in the updated send_email method, the get_forms_by_uuid dependency method, and the helper script:
def send_email(form_uuid, form)
    return if form.email_sent
  
    form_data =
      {
        email: form.email,
        first_name: form.first_name,
        last_name: form.last_name,
        form_number: form.form_number,
        file_count: fetch_forms_by_uuid(form_uuid).where('file_name LIKE ?', '%supporting_doc%').count,
        pega_status: form.pega_status,
        created_at: form.created_at.strftime('%B %d, %Y'),
        date_submitted: form.created_at.strftime('%B %d, %Y'),
        form_uuid: form.form_uuid
      }
  
    ActiveRecord::Base.transaction do
      if IvcChampva::Email.new(form_data).send_email
        fetch_forms_by_uuid(form_uuid).update_all(email_sent: true) # rubocop:disable Rails/SkipsModelValidations
      else
        raise ActiveRecord::Rollback, 'Failed to send confirmation email'
      end
    end
  end
  
def fetch_forms_by_uuid(form_uuid)
  @fetch_forms_by_uuid ||= IvcChampvaForm.where(form_uuid:)
end

# Grab a test 10-10d form submission, set a custom email, and call `send_email`
record = IvcChampvaForm.where(id: 269)[0]
puts "ENTER EMAIL ADDRESS TO TEST SENDING:"
record.email_sent = false
record.email = gets.chomp
record.save
send_email(record.form_uuid, record)
  1. Enter the email you want to receive the test message at and press enter/return.
  2. Verify the email made it to your inbox.
  • Feature is not behind a toggle.
  • To reproduce the original bug, fill out this form in staging and note the lack of a confirmation email.
  • The solution to this issue is to include all of the required personalization values to VA Notify.
  • TEAM: IVC CHAMPVA

Related issue(s)

  • Link to ticket created in va.gov-team repo OR screenshot of Jira ticket if your team uses Jira
  • Link to previous change of the code/bug (if applicable)
  • Link to epic if not included in ticket

Testing done

  • New code is covered by unit tests
  • Describe what the old behavior was prior to the change
  • Describe the steps required to verify your changes are working as expected. Exclusively stating 'Specs run' is NOT acceptable as appropriate testing
  • If this work is behind a flipper:
    • Tests need to be written for both the flipper on and flipper off scenarios. Docs.
    • What is the testing plan for rolling out the feature?

Screenshots

Note: Optional

What areas of the site does it impact?

(Describe what parts of the site are impacted andifcode touched other areas)

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
Contributor

@stevelong00 stevelong00 left a comment

Choose a reason for hiding this comment

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

LGTM!

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