Skip to content

Commit fc2f4b9

Browse files
committed
Ensure email domain validation shows by default on page load within references form when referee email is invalid due to the domain being public
1 parent aa36c81 commit fc2f4b9

File tree

6 files changed

+39
-2
lines changed

6 files changed

+39
-2
lines changed

app/controllers/teacher_interface/other_england_work_histories_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ def edit_contact
242242
contact_job: work_history.contact_job,
243243
contact_email: work_history.contact_email,
244244
)
245+
246+
@form.validate if @work_history.invalid_email_domain_for_contact?
245247
end
246248

247249
def update_contact

app/controllers/teacher_interface/work_histories_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ def edit_contact
211211
contact_job: work_history.contact_job,
212212
contact_email: work_history.contact_email,
213213
)
214+
215+
@form.validate if @work_history.invalid_email_domain_for_contact?
214216
end
215217

216218
def update_contact

spec/support/autoload/page_objects/teacher_interface/edit_other_england_work_history_contact.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class EditOtherEnglandWorkHistoryContact < SitePrism::Page
1212
"#teacher-interface-work-history-contact-form-contact-job-field"
1313
element :email_input,
1414
"#teacher-interface-work-history-contact-form-contact-email-field"
15+
element :email_input_with_error,
16+
"#teacher-interface-work-history-contact-form-contact-email-field-error"
1517

1618
element :continue_button, ".govuk-button:not(.govuk-button--secondary)"
1719
element :save_and_come_back_later_button,

spec/support/autoload/page_objects/teacher_interface/edit_work_history_contact.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class EditWorkHistoryContact < SitePrism::Page
1212
"#teacher-interface-work-history-contact-form-contact-job-field"
1313
element :email_input,
1414
"#teacher-interface-work-history-contact-form-contact-email-field"
15+
element :email_input_with_error,
16+
"#teacher-interface-work-history-contact-form-contact-email-field-error"
1517

1618
element :continue_button, ".govuk-button:not(.govuk-button--secondary)"
1719
element :save_and_come_back_later_button,

spec/system/teacher_interface/other_england_work_history_spec.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@
118118

119119
when_i_click_the_other_england_work_history_task
120120
then_i_see_the(:teacher_edit_other_england_work_history_contact_page)
121+
and_i_see_error_message_for_email_address_using_public_domain
121122

122-
when_i_fill_in_the_contact_information
123+
when_i_update_the_contact_email_with_error
123124
then_i_see_the(:teacher_check_other_england_work_history_page)
124125

125126
when_i_click_continue
@@ -256,6 +257,15 @@ def when_i_fill_in_the_contact_information
256257
.click
257258
end
258259

260+
def when_i_update_the_contact_email_with_error
261+
teacher_edit_other_england_work_history_contact_page.form.email_input_with_error.fill_in with:
262+
"contact@example.com"
263+
teacher_edit_other_england_work_history_contact_page
264+
.form
265+
.continue_button
266+
.click
267+
end
268+
259269
def and_i_see_the_other_england_work_history_information(name:)
260270
summary_list_rows = teacher_check_work_history_page.summary_list.rows
261271

@@ -355,6 +365,12 @@ def when_i_delete_work_history
355365
teacher_delete_other_england_work_history_page.form.continue_button.click
356366
end
357367

368+
def and_i_see_error_message_for_email_address_using_public_domain
369+
expect(teacher_edit_work_history_contact_page).to have_content(
370+
"Enter an official email address that uses the institution’s domain",
371+
)
372+
end
373+
358374
def teacher
359375
@teacher ||= create(:teacher)
360376
end

spec/system/teacher_interface/work_history_spec.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@
139139

140140
when_i_click_the_work_history_task
141141
then_i_see_the(:teacher_edit_work_history_contact_page)
142+
and_i_see_error_message_for_email_address_using_public_domain
142143

143-
when_i_fill_in_the_contact_information
144+
when_i_update_the_contact_email_with_error
144145
then_i_see_the(:teacher_check_work_history_page)
145146

146147
when_i_click_continue
@@ -347,6 +348,12 @@ def when_i_fill_in_the_contact_information
347348
teacher_edit_work_history_contact_page.form.continue_button.click
348349
end
349350

351+
def when_i_update_the_contact_email_with_error
352+
teacher_edit_work_history_contact_page.form.email_input_with_error.fill_in with:
353+
"contact@example.com"
354+
teacher_edit_work_history_contact_page.form.continue_button.click
355+
end
356+
350357
def and_i_see_the_work_history_information
351358
summary_list_rows = teacher_check_work_history_page.summary_list.rows
352359

@@ -583,6 +590,12 @@ def and_i_see_one_work_history
583590
expect(teacher_check_work_histories_page.summary_cards.count).to eq(1)
584591
end
585592

593+
def and_i_see_error_message_for_email_address_using_public_domain
594+
expect(teacher_edit_work_history_contact_page).to have_content(
595+
"Enter an official email address that uses the institution’s domain",
596+
)
597+
end
598+
586599
def teacher
587600
@teacher ||= create(:teacher)
588601
end

0 commit comments

Comments
 (0)