Skip to content

Commit

Permalink
Merge pull request #1017 from alphagov/add-tests-for-email-survey-form
Browse files Browse the repository at this point in the history
Add tests for feedback form fields
  • Loading branch information
bilbof authored Aug 2, 2019
2 parents 7d80295 + 48cce1d commit 9c4570b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
useful summary for people upgrading their application, not a replication
of the commit log.

## Unreleased

* Add tests for email feedback form (PR #1017)

## 17.20.0

* Add full width option to select component (PR #1012)
Expand Down
8 changes: 8 additions & 0 deletions spec/components/feedback_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ def component_name
assert_select ".gem-c-feedback.gem-c-feedback--margin-top", false
end

it "has required email survey signup form fields" do
render_component({})

assert_select ".gem-c-feedback #survey-wrapper [name='email_survey_signup[email_address]']"
assert_select ".gem-c-feedback #survey-wrapper [name='email_survey_signup[survey_source]']"
assert_select ".gem-c-feedback #survey-wrapper [name='email_survey_signup[survey_id]']"
end

describe "ASCII characters" do
let(:ascii_url) { 'http://www.test.com/test?áscii=%EE%90%80'.force_encoding('ASCII-8BIT') }
let(:utf8_url) { ascii_url.encode }
Expand Down
4 changes: 3 additions & 1 deletion spec/javascripts/components/feedback-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('Feedback component', function () {
'<div class="column-two-thirds">' +
'<div class="gem-c-feedback__error-summary js-hidden js-errors" tabindex="-1"></div>' +
'<input name="email_survey_signup[survey_source]" type="hidden" value="a_source">' +
'<input name="email_survey_signup[survey_id]" type="hidden" value="an_id">' +

'<h2 class="gem-c-feedback__form-heading">Help us improve GOV.UK</h2>' +
'<p class="gem-c-feedback__form-paragraph">To help us improve GOV.UK, we\'d like to know more about your visit today. We\'ll send you a link to a feedback form. It will take only 2 minutes to fill in. Don\'t worry we won\'t send you spam or share your email address with anyone.</p>' +
Expand Down Expand Up @@ -487,7 +488,8 @@ describe('Feedback component', function () {
expect(request.data()).toEqual({
'email_survey_signup[email_address]': ['[email protected]'],
'email_survey_signup[ga_client_id]': ['111111111.1111111111'],
'email_survey_signup[survey_source]': ['a_source']
'email_survey_signup[survey_source]': ['a_source'],
'email_survey_signup[survey_id]': ['an_id']
})
})

Expand Down

0 comments on commit 9c4570b

Please sign in to comment.