diff --git a/README.md b/README.md index f8dc4a8..1c67b41 100644 --- a/README.md +++ b/README.md @@ -30,14 +30,12 @@ The tests expect an active group to exist called "End to end tests", which the t #### Starting forms-runner -Forms-runner needs to be started with: -- The Notify API key in order to send confirmation emails -- AWS credentials for the dev account in order to send submissions +Forms-runner needs to be started with AWS credentials for the dev account in order to send submissions. ```shell gds aws forms-dev-readonly --shell -ASSUME_DEV_IAM_ROLE=true SETTINGS__GOVUK_NOTIFY__API_KEY= ./bin/rails server +ASSUME_DEV_IAM_ROLE=true ./bin/rails server ``` see the [README for forms-runner](https://github.com/govuk-forms/forms-runner?tab=readme-ov-file#getting-aws-credentials) for more details @@ -51,9 +49,12 @@ SETTINGS__GOVUK_NOTIFY__API_KEY= ./bin/rails server #### Running the tests +The tests then need to be run with AWS credentials for the dev account in order to check for the confirmation email. You can run the tests against localhost using the following command: ```shell +gds aws forms-dev-readonly --shell + SETTINGS__GOVUK_NOTIFY__API_KEY= bundle exec rake ``` diff --git a/bin/load_env_vars.sh b/bin/load_env_vars.sh index 8542a9d..0739ffe 100644 --- a/bin/load_env_vars.sh +++ b/bin/load_env_vars.sh @@ -139,6 +139,7 @@ function set_e2e_env_vars() { export SETTINGS__GOVUK_NOTIFY__API_KEY="$(get_param /${environment}/automated-tests/e2e/notify/api-key)" export SETTINGS__SUBMISSION_STATUS_API__SECRET="$(get_param /${environment}/automated-tests/e2e/runner/submission_status_api_shared_secret)" export SETTINGS__FORMS_ENV="$environment" + export SETTINGS__CONFIRMATION_EMAIL="$(confirmation_email $environment)" export SETTINGS__GOVUK_ONE_LOGIN__USER_EMAIL="$(get_param /${environment}/automated-tests/e2e/one-login/user-email)" export SETTINGS__GOVUK_ONE_LOGIN__USER_PASSWORD="$(get_param /${environment}/automated-tests/e2e/one-login/user-password)" export SETTINGS__GOVUK_ONE_LOGIN__USER_OTP_SECRET_KEY="$(get_param /${environment}/automated-tests/e2e/one-login/user-otp-secret-key)" diff --git a/config/settings.yml b/config/settings.yml index b627cee..83618cd 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -34,3 +34,5 @@ govuk_one_login: submission_status_api: secret: + +confirmation_email: diff --git a/config/settings/development.yml b/config/settings/development.yml index 7df163f..3a98993 100644 --- a/config/settings/development.yml +++ b/config/settings/development.yml @@ -23,3 +23,5 @@ aws: govuk_one_login: user_email: copy-of-answers-emails-tests@dev.forms.service.gov.uk + +confirmation_email: confirmation-email-tests@dev.forms.service.gov.uk \ No newline at end of file diff --git a/spec/end_to_end/end_to_end_spec.rb b/spec/end_to_end/end_to_end_spec.rb index e12379f..19d8317 100644 --- a/spec/end_to_end/end_to_end_spec.rb +++ b/spec/end_to_end/end_to_end_spec.rb @@ -1,6 +1,7 @@ # rubocop:todo RSpec/NoExpectationExample feature "Full lifecycle of a form", type: :feature do let(:test_email_address) { "govuk-forms-automation-tests@digital.cabinet-office.gov.uk" } + let(:confirmation_email) { Settings.confirmation_email } let(:form_name) { "capybara test form #{Time.now.strftime('%Y-%m-%d %H:%M.%S')}" } let(:file_question_text) { "Upload a file" } @@ -80,7 +81,7 @@ # Testing confirmation email logger.info logger.info "Scenario: Form is completed by a member of the public, and they request a confirmation email" - form_is_filled_in_by_form_filler(live_form_link, confirmation_email: test_email_address) + form_is_filled_in_by_form_filler(live_form_link, confirmation_email: confirmation_email) unless skip_copy_of_answers? logger.info "Scenario: Form is completed by a member of the public, and they request a copy of their answers" diff --git a/spec/support/aws_helpers.rb b/spec/support/aws_helpers.rb index 802e241..36a63c4 100644 --- a/spec/support/aws_helpers.rb +++ b/spec/support/aws_helpers.rb @@ -29,6 +29,12 @@ def get_submission_from_s3(submission_reference, form_id) end end + def wait_for_confirmation_email(submission_reference) + prefix = "confirmation-emails/" + email_match_string = "Your form reference number is #{submission_reference}" + wait_for_ses_email_delivered_to_s3(prefix, email_match_string, submission_reference) + end + def wait_for_copy_of_answers_email(submission_reference) prefix = "copy-of-answers-emails/" email_match_string = "Your form reference number is #{submission_reference}" diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb index 636b812..9c7c3f5 100644 --- a/spec/support/feature_helpers.rb +++ b/spec/support/feature_helpers.rb @@ -455,7 +455,12 @@ def form_is_filled_in_by_form_filler(live_form_link, yes_branch: false, confirma logger.info "When I have filled out a form and requested a confirmation email" logger.info "Then I can see the confirmation in my email inbox" - wait_for_notification(confirmation_email_reference) + # TODO: remove this once forms-runner is sending confirmation emails with SES. + begin + wait_for_notification(confirmation_email_reference) + rescue NotifyException + wait_for_confirmation_email(submission_reference) + end end if copy_of_answers