Skip to content

Commit 30bf62a

Browse files
authored
Merge pull request #8 from DFE-Digital/test-ect-registration-wizard
Complete Register ECT dummy wizard flow, specs, and docs
2 parents cd6b27b + 96726fc commit 30bf62a

37 files changed

Lines changed: 1279 additions & 64 deletions

File tree

spec/dummy-app-wizard-specs/register_ect_wizard_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,13 @@
109109
wizard.state_store.write(
110110
trn: '9999999',
111111
date_of_birth: Date.new(2000, 1, 1),
112+
start_date: Date.new(2024, 9, 17),
113+
working_pattern: 'full_time',
112114
email: 'free@example.com',
113115
school_type: 'independent',
114116
training_programme: 'provider_led',
117+
appropriate_body_type: 'national',
118+
lead_provider_id: 'teach_first',
115119
details_correct: 'no',
116120
correct_full_name: 'Some full name',
117121
)
@@ -258,6 +262,8 @@
258262
wizard.state_store.write(
259263
trn: '9999999',
260264
date_of_birth: Date.new(2000, 1, 1),
265+
start_date: Date.new(2024, 9, 17),
266+
working_pattern: 'full_time',
261267
details_correct: 'yes',
262268
email: 'free@example.com',
263269
school_type: 'state',
@@ -353,10 +359,13 @@ def stub_eligible_path(wizard)
353359
wizard.state_store.write(
354360
trn: '9999999',
355361
date_of_birth: Date.new(2000, 1, 1),
362+
start_date: Date.new(2024, 9, 17),
363+
working_pattern: 'full_time',
356364
email: 'free@example.com',
357365
training_programme: 'school_led',
358366
details_correct: 'yes',
359367
school_type: 'independent',
368+
appropriate_body_type: 'national',
360369
)
361370
end
362371
end
Lines changed: 328 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,328 @@
1+
RSpec.feature 'Register ECT wizard', type: :feature do
2+
scenario 'happy path with provider-led training' do
3+
given_i_start_the_register_ect_wizard
4+
then_i_should_be_on_the_find_ect_step
5+
6+
when_i_complete_happy_path_to_check_answers
7+
and_i_see_the_check_answers_summary(
8+
'Name' => 'Pat ECT',
9+
'Teacher Reference Number (TRN)' => '1234567',
10+
'Email address' => 'ect@example.com',
11+
'School start date' => '17 September 2024',
12+
'Working pattern' => 'Full time',
13+
'Appropriate body' => 'Example Appropriate Body',
14+
'Training programme' => 'Provider led',
15+
'Lead provider' => 'Teach first',
16+
)
17+
and_i_confirm_details
18+
19+
then_i_should_be_on_the_confirmation_step
20+
and_i_see_the_confirmation_summary
21+
end
22+
23+
scenario 'change answers returns to check answers' do
24+
given_i_start_the_register_ect_wizard
25+
then_i_should_be_on_the_find_ect_step
26+
27+
when_i_complete_happy_path_to_check_answers
28+
29+
when_i_change_working_pattern_to('Part time')
30+
31+
then_i_should_be_on_the_check_answers_step
32+
and_i_see_the_check_answers_summary('Working pattern' => 'Part time')
33+
end
34+
35+
scenario 'change programme details returns to check answers' do
36+
given_i_start_the_register_ect_wizard
37+
then_i_should_be_on_the_find_ect_step
38+
39+
when_i_complete_happy_path_to_check_answers
40+
41+
when_i_change_training_programme_to('School-led')
42+
43+
then_i_should_be_on_the_check_answers_step
44+
and_i_see_the_check_answers_summary('Training programme' => 'School led')
45+
and_i_do_not_see_lead_provider_in_summary
46+
end
47+
48+
scenario 'change appropriate body returns to check answers for independent schools' do
49+
given_i_start_the_register_ect_wizard_for_independent_school
50+
then_i_should_be_on_the_find_ect_step
51+
52+
when_i_complete_happy_path_to_check_answers_for_independent_school
53+
54+
when_i_change_independent_appropriate_body_to('Independent Body Two')
55+
56+
then_i_should_be_on_the_check_answers_step
57+
and_i_see_the_check_answers_summary('Appropriate body' => 'Independent Body Two')
58+
end
59+
60+
scenario 'when TRN is not found' do
61+
given_i_start_the_register_ect_wizard
62+
then_i_should_be_on_the_find_ect_step
63+
64+
when_i_find_an_ect(trn: '0000000', day: '1', month: '11', year: '1980')
65+
then_i_should_be_on_the_trn_not_found_step
66+
when_i_try_again
67+
then_i_should_be_on_the_find_ect_step
68+
end
69+
70+
scenario 'skipping steps' do
71+
when_i_go_to_the_programme_type_step_directly
72+
then_i_see_a_404
73+
74+
when_i_go_to_the_check_answers_step_directly
75+
then_i_see_a_404
76+
77+
when_i_go_to_the_confirmation_step_directly
78+
then_i_see_a_404
79+
end
80+
81+
def given_i_start_the_register_ect_wizard
82+
visit root_path
83+
click_link_or_button 'Wizards'
84+
click_link_or_button 'Register ECT Wizard'
85+
end
86+
87+
def given_i_start_the_register_ect_wizard_for_independent_school
88+
visit register_ect_find_ect_path(school_type: 'independent')
89+
end
90+
91+
def then_i_should_be_on_the_find_ect_step
92+
expect(page).to have_current_path(register_ect_find_ect_path, ignore_query: true)
93+
expect(page).to have_content('Find an ECT')
94+
end
95+
96+
def when_i_find_an_ect(trn:, day:, month:, year:)
97+
fill_in 'Teacher reference number (TRN)', with: trn
98+
fill_in 'Day', with: day
99+
fill_in 'Month', with: month
100+
fill_in 'Year', with: year
101+
and_i_continue
102+
end
103+
104+
def then_i_should_be_on_the_review_ect_details_step
105+
expect(page).to have_current_path(register_ect_review_ect_details_path, ignore_query: true)
106+
expect(page).to have_content('Review ECT details')
107+
end
108+
109+
def when_i_complete_happy_path_to_check_answers
110+
when_i_find_an_ect(trn: '1234567', day: '1', month: '11', year: '1980')
111+
then_i_should_be_on_the_review_ect_details_step
112+
when_i_confirm_ect_details_and_enter_name('Pat ECT')
113+
and_i_continue
114+
115+
then_i_should_be_on_the_email_address_step
116+
when_i_enter_email('ect@example.com')
117+
and_i_continue
118+
119+
then_i_should_be_on_the_start_date_step
120+
when_i_enter_start_date(day: '17', month: '9', year: '2024')
121+
and_i_continue
122+
123+
then_i_should_be_on_the_working_pattern_step
124+
when_i_choose_working_pattern('Full time')
125+
and_i_continue
126+
127+
then_i_should_be_on_the_state_school_appropriate_body_step
128+
when_i_enter_appropriate_body_name('Example Appropriate Body')
129+
and_i_continue
130+
131+
then_i_should_be_on_the_programme_type_step
132+
when_i_choose_training_programme('Provider-led')
133+
and_i_continue
134+
135+
then_i_should_be_on_the_lead_provider_step
136+
when_i_choose_lead_provider('Teach First')
137+
and_i_continue
138+
139+
then_i_should_be_on_the_check_answers_step
140+
end
141+
142+
def when_i_complete_happy_path_to_check_answers_for_independent_school
143+
when_i_find_an_ect(trn: '1234567', day: '1', month: '11', year: '1980')
144+
then_i_should_be_on_the_review_ect_details_step
145+
when_i_confirm_ect_details_and_enter_name('Pat ECT')
146+
and_i_continue
147+
148+
then_i_should_be_on_the_email_address_step
149+
when_i_enter_email('ect@example.com')
150+
and_i_continue
151+
152+
then_i_should_be_on_the_start_date_step
153+
when_i_enter_start_date(day: '17', month: '9', year: '2024')
154+
and_i_continue
155+
156+
then_i_should_be_on_the_working_pattern_step
157+
when_i_choose_working_pattern('Full time')
158+
and_i_continue
159+
160+
then_i_should_be_on_the_independent_school_appropriate_body_step
161+
when_i_choose_independent_appropriate_body('Independent Body One')
162+
and_i_continue
163+
164+
then_i_should_be_on_the_programme_type_step
165+
when_i_choose_training_programme('Provider-led')
166+
and_i_continue
167+
168+
then_i_should_be_on_the_lead_provider_step
169+
when_i_choose_lead_provider('Teach First')
170+
and_i_continue
171+
172+
then_i_should_be_on_the_check_answers_step
173+
end
174+
175+
def when_i_change_working_pattern_to(value)
176+
find('.govuk-summary-list__row', text: 'Working pattern').click_link('Change')
177+
then_i_should_be_on_the_working_pattern_step
178+
when_i_choose_working_pattern(value)
179+
and_i_continue
180+
end
181+
182+
def when_i_change_training_programme_to(value)
183+
find('.govuk-summary-list__row', text: 'Training programme').click_link('Change')
184+
then_i_should_be_on_the_programme_type_step
185+
when_i_choose_training_programme(value)
186+
and_i_continue
187+
end
188+
189+
def when_i_change_independent_appropriate_body_to(name)
190+
find('.govuk-summary-list__row', text: 'Appropriate body').click_link('Change')
191+
then_i_should_be_on_the_independent_school_appropriate_body_step
192+
when_i_choose_independent_appropriate_body(name)
193+
and_i_continue
194+
end
195+
196+
def when_i_confirm_ect_details_and_enter_name(name)
197+
choose 'No, they changed their name or it\'s spelt wrong'
198+
fill_in 'Enter the correct full name', with: name
199+
end
200+
201+
def then_i_should_be_on_the_email_address_step
202+
expect(page).to have_current_path(register_ect_email_address_path, ignore_query: true)
203+
expect(page).to have_content('email address')
204+
end
205+
206+
def when_i_enter_email(email)
207+
fill_in 'Email address', with: email
208+
end
209+
210+
def then_i_should_be_on_the_start_date_step
211+
expect(page).to have_current_path(register_ect_start_date_path, ignore_query: true)
212+
expect(page).to have_content('start teaching as an ECT')
213+
end
214+
215+
def when_i_enter_start_date(day:, month:, year:)
216+
fill_in 'Day', with: day
217+
fill_in 'Month', with: month
218+
fill_in 'Year', with: year
219+
end
220+
221+
def then_i_should_be_on_the_working_pattern_step
222+
expect(page).to have_current_path(register_ect_working_pattern_path, ignore_query: true)
223+
expect(page).to have_content('working pattern')
224+
end
225+
226+
def when_i_choose_working_pattern(value)
227+
choose value
228+
end
229+
230+
def then_i_should_be_on_the_state_school_appropriate_body_step
231+
expect(page).to have_current_path(register_ect_state_school_appropriate_body_path, ignore_query: true)
232+
expect(page).to have_content('appropriate body')
233+
end
234+
235+
def then_i_should_be_on_the_independent_school_appropriate_body_step
236+
expect(page).to have_current_path(register_ect_independent_school_appropriate_body_path, ignore_query: true)
237+
expect(page).to have_content('appropriate body')
238+
end
239+
240+
def when_i_enter_appropriate_body_name(name)
241+
fill_in 'Enter appropriate body name', with: name
242+
end
243+
244+
def when_i_choose_independent_appropriate_body(name)
245+
choose 'A different appropriate body (teaching school hub)'
246+
fill_in 'Enter appropriate body name', with: name
247+
end
248+
249+
def then_i_should_be_on_the_programme_type_step
250+
expect(page).to have_current_path(register_ect_programme_type_path, ignore_query: true)
251+
expect(page).to have_content('training programme')
252+
end
253+
254+
def when_i_choose_training_programme(value)
255+
choose value
256+
end
257+
258+
def then_i_should_be_on_the_lead_provider_step
259+
expect(page).to have_current_path(register_ect_lead_provider_path, ignore_query: true)
260+
expect(page).to have_content('lead provider')
261+
end
262+
263+
def when_i_choose_lead_provider(name)
264+
choose name
265+
end
266+
267+
def then_i_should_be_on_the_check_answers_step
268+
expect(page).to have_current_path(register_ect_check_answers_path, ignore_query: true)
269+
expect(page).to have_content('Check your answers before submitting')
270+
end
271+
272+
def and_i_see_the_check_answers_summary(fields_and_answers)
273+
fields_and_answers.each do |field, answer|
274+
expect(page).to have_text(field)
275+
expect(page).to have_text(answer)
276+
end
277+
end
278+
279+
def and_i_confirm_details
280+
click_link_or_button 'Confirm details'
281+
end
282+
283+
def then_i_should_be_on_the_confirmation_step
284+
expect(page).to have_current_path(register_ect_confirmation_path, ignore_query: true)
285+
expect(page).to have_content('You have saved')
286+
end
287+
288+
def and_i_see_the_confirmation_summary
289+
expect(page).to have_content('Assign a mentor')
290+
end
291+
292+
def and_i_do_not_see_lead_provider_in_summary
293+
expect(page).to have_no_content('Lead provider')
294+
end
295+
296+
def then_i_should_be_on_the_trn_not_found_step
297+
expect(page).to have_current_path(register_ect_trn_not_found_path, ignore_query: true)
298+
expect(page).to have_content('unable to match the ECT with the TRN you provided')
299+
end
300+
301+
def when_i_try_again
302+
click_link_or_button 'Try again'
303+
end
304+
305+
def when_i_go_to_the_programme_type_step_directly
306+
visit register_ect_programme_type_path
307+
end
308+
309+
def when_i_go_to_the_check_answers_step_directly
310+
visit register_ect_check_answers_path
311+
end
312+
313+
def when_i_go_to_the_confirmation_step_directly
314+
visit register_ect_confirmation_path
315+
end
316+
317+
def then_i_see_a_404
318+
expect(page.status_code).to eq(404)
319+
end
320+
321+
def and_i_continue
322+
if page.has_button?('Continue')
323+
click_button 'Continue'
324+
else
325+
click_button 'Confirm and continue'
326+
end
327+
end
328+
end

spec/rails-dummy/app/controllers/register_ect/wizard_controller.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module RegisterECT
22
class WizardController < ApplicationController
33
before_action :assign_wizard
4+
before_action :verify_step_access
45

56
def new = nil
67

@@ -14,10 +15,18 @@ def create
1415

1516
private
1617

18+
def verify_step_access
19+
unless @wizard.valid_path_to_current_step?
20+
render status: :not_found, formats: [:html],
21+
template: 'errors/not_found'
22+
end
23+
end
24+
1725
def assign_wizard
1826
state_store = StateStores::RegisterECTStore.new(
1927
repository: DfE::Wizard::Repository::Session.new(session:, key: :register_ect_wizard),
2028
)
29+
state_store.write(school_type: params[:school_type]) if params[:school_type].present?
2130

2231
@wizard = RegisterECTWizard.new(
2332
current_step: current_step,

0 commit comments

Comments
 (0)