Skip to content

Commit a00670d

Browse files
committed
Fix import tests to work with new issues text + pds logic
Since PDS searches are being done on all imported records and the import issues text has changed, the integration tests need to be amended.
1 parent b2315d0 commit a00670d

11 files changed

+240
-25
lines changed

spec/features/hpv_vaccination_offline_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,11 +464,15 @@ def then_i_see_the_successful_import
464464
expect(page).not_to have_content("Invalid")
465465

466466
expect(page).to have_content("4 vaccination records")
467-
expect(page).to have_content("2 previously imported records were omitted")
467+
expect(page).to have_content(
468+
"2 records were not imported because they already exist in Mavis"
469+
)
468470
end
469471

470472
def then_i_see_a_duplicate_record_needs_review
471-
expect(page).to have_content("1 duplicate record needs review")
473+
expect(page).to have_content(
474+
"1 record has import issues to resolve before it can be imported into Mavis"
475+
)
472476
end
473477

474478
def then_i_should_see_a_success_message

spec/features/import_child_pds_lookup_extravaganza_spec.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# Case 3: Existing patient with NHS number (Catherine) - should show duplicate review
3030
when_i_go_back_to_the_import_page
3131
then_i_see_an_import_review_for_the_second_patient_uploaded_without_nhs_number
32-
when_i_click_review
32+
when_i_click_review_for("WILLIAMS, Catherine")
3333
then_i_see_both_records_have_an_nhs_number
3434
and_i_see_address_differences_for_review
3535
when_i_use_duplicate_record_during_merge
@@ -293,8 +293,13 @@ def when_i_go_back_to_the_import_page
293293
click_link "1 September 2025 at 12:00pm"
294294
end
295295

296-
def when_i_click_review
297-
click_link "Review", match: :first
296+
def when_i_click_review_for(name)
297+
within(
298+
:xpath,
299+
"//div[h3[contains(text(), 'records with import issues')]]"
300+
) do
301+
within(:xpath, ".//tr[contains(., '#{name}')]") { click_link "Review" }
302+
end
298303
end
299304

300305
def and_i_upload_import_file(filename)

spec/features/import_child_records_preparation_spec.rb

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,36 @@ def given_today_is_the_start_of_the_2024_25_preparation_period
196196
def and_pds_lookup_during_import_is_enabled
197197
Flipper.enable(:pds_lookup_during_import)
198198

199-
stub_pds_search_to_return_a_patient
200-
stub_pds_get_nhs_number_to_return_a_patient
199+
stub_pds_search_to_return_no_patients(
200+
"family" => "Smith",
201+
"given" => "Jimmy",
202+
"birthdate" => "eq2010-01-02",
203+
"address-postalcode" => "SW1A 1AA"
204+
)
205+
206+
stub_pds_search_to_return_a_patient(
207+
"9999075320",
208+
"family" => "Clarke",
209+
"given" => "Jennifer",
210+
"birthdate" => "eq2010-01-01",
211+
"address-postalcode" => "SW1A 1AA"
212+
)
213+
214+
stub_pds_search_to_return_a_patient(
215+
"9999075320",
216+
"family" => "Clarke",
217+
"given" => "Jennifer",
218+
"birthdate" => "eq2010-01-01",
219+
"address-postalcode" => "SW1A 1AB"
220+
)
221+
222+
stub_pds_search_to_return_a_patient(
223+
"9435764479",
224+
"family" => "Doe",
225+
"given" => "Mark",
226+
"birthdate" => "eq2010-01-03",
227+
"address-postalcode" => "SW1A 1AA"
228+
)
201229
end
202230

203231
def and_i_can_choose_the_academic_year_on_import

spec/features/import_child_records_slow_spec.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,24 @@ def given_the_app_is_setup
6464
def and_pds_lookup_during_import_is_enabled
6565
Flipper.enable(:pds_lookup_during_import)
6666

67-
stub_pds_search_to_return_a_patient
68-
stub_pds_get_nhs_number_to_return_a_patient
67+
csv_path =
68+
Rails.root.join("spec/fixtures/cohort_import/valid_1000_rows.csv")
69+
70+
CSV.foreach(csv_path, headers: true) do |row|
71+
nhs_number = row["CHILD_NHS_NUMBER"]
72+
family = row["CHILD_LAST_NAME"]
73+
given = row["CHILD_FIRST_NAME"]
74+
birthdate = row["CHILD_DATE_OF_BIRTH"]
75+
postcode = row["CHILD_POSTCODE"]
76+
77+
stub_pds_search_to_return_a_patient(
78+
nhs_number,
79+
"family" => family,
80+
"given" => given,
81+
"birthdate" => "eq#{birthdate}",
82+
"address-postalcode" => postcode
83+
)
84+
end
6985
end
7086

7187
def when_i_visit_the_import_page

spec/features/import_child_records_spec.rb

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,36 @@ def given_the_app_is_setup
140140
def and_pds_lookup_during_import_is_enabled
141141
Flipper.enable(:pds_lookup_during_import)
142142

143-
stub_pds_search_to_return_a_patient
144-
stub_pds_get_nhs_number_to_return_a_patient
143+
stub_pds_search_to_return_no_patients(
144+
"family" => "Smith",
145+
"given" => "Jimmy",
146+
"birthdate" => "eq2010-01-02",
147+
"address-postalcode" => "SW1A 1AA"
148+
)
149+
150+
stub_pds_search_to_return_a_patient(
151+
"9999075320",
152+
"family" => "Clarke",
153+
"given" => "Jennifer",
154+
"birthdate" => "eq2010-01-01",
155+
"address-postalcode" => "SW1A 1AA"
156+
)
157+
158+
stub_pds_search_to_return_a_patient(
159+
"9999075320",
160+
"family" => "Clarke",
161+
"given" => "Jennifer",
162+
"birthdate" => "eq2010-01-01",
163+
"address-postalcode" => "SW1A 1AB"
164+
)
165+
166+
stub_pds_search_to_return_a_patient(
167+
"9435764479",
168+
"family" => "Doe",
169+
"given" => "Mark",
170+
"birthdate" => "eq2010-01-03",
171+
"address-postalcode" => "SW1A 1AA"
172+
)
145173
end
146174

147175
def when_i_visit_the_import_page

spec/features/import_child_records_with_duplicates_spec.rb

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,36 @@ def and_pds_lookup_during_import_is_enabled
112112

113113
Flipper.enable(:pds_lookup_during_import)
114114

115-
stub_pds_search_to_return_a_patient
116-
stub_pds_get_nhs_number_to_return_a_patient
115+
stub_pds_search_to_return_no_patients(
116+
"family" => "Smith",
117+
"given" => "Jimmy",
118+
"birthdate" => "eq2010-01-02",
119+
"address-postalcode" => "SW1A 1AA"
120+
)
121+
122+
stub_pds_search_to_return_a_patient(
123+
"9999075320",
124+
"family" => "Clarke",
125+
"given" => "Jennifer",
126+
"birthdate" => "eq2010-01-01",
127+
"address-postalcode" => "SW1A 1AA"
128+
)
129+
130+
stub_pds_search_to_return_a_patient(
131+
"9999075320",
132+
"family" => "Clarke",
133+
"given" => "Jennifer",
134+
"birthdate" => "eq2010-01-01",
135+
"address-postalcode" => "SW1A 1AB"
136+
)
137+
138+
stub_pds_search_to_return_a_patient(
139+
"9435764479",
140+
"family" => "Doe",
141+
"given" => "Mark",
142+
"birthdate" => "eq2010-01-03",
143+
"address-postalcode" => "SW1A 1AA"
144+
)
117145
end
118146

119147
def and_an_hpv_programme_is_underway
@@ -190,7 +218,9 @@ def and_i_upload_a_file_with_duplicate_records
190218
end
191219

192220
def then_i_should_see_the_import_page_with_duplicate_records
193-
expect(page).to have_content("3 duplicate records need review")
221+
expect(page).to have_content(
222+
"3 records have import issues to resolve before they can be imported into Mavis"
223+
)
194224
end
195225

196226
def when_i_choose_to_keep_the_duplicate_record

spec/features/import_child_records_with_twins_spec.rb

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
after { Flipper.disable(:pds_lookup_during_import) }
88

99
scenario "User reviews and selects between duplicate records" do
10-
stub_pds_get_nhs_number_to_return_a_patient
11-
stub_pds_search_to_return_a_patient
10+
and_pds_lookup_during_import_returns_nhs_numbers
1211

1312
given_i_am_signed_in
1413
and_an_hpv_programme_is_underway
@@ -36,6 +35,31 @@ def given_i_am_signed_in
3635
sign_in @team.users.first
3736
end
3837

38+
def and_pds_lookup_during_import_returns_nhs_numbers
39+
stub_pds_search_to_return_no_patients(
40+
"family" => "Smith",
41+
"given" => "Jimmy",
42+
"birthdate" => "eq2010-01-02",
43+
"address-postalcode" => "SW1A 1AA"
44+
)
45+
46+
stub_pds_search_to_return_a_patient(
47+
"9999075320",
48+
"family" => "Clarke",
49+
"given" => "Jennifer",
50+
"birthdate" => "eq2010-01-01",
51+
"address-postalcode" => "SW1A 1AA"
52+
)
53+
54+
stub_pds_search_to_return_a_patient(
55+
"9449306168",
56+
"family" => "Doe",
57+
"given" => "Mark",
58+
"birthdate" => "eq2010-01-03",
59+
"address-postalcode" => "SW1A 1AA"
60+
)
61+
end
62+
3963
def and_an_hpv_programme_is_underway
4064
@school = create(:school, urn: "123456", team: @team)
4165
@session =
@@ -78,7 +102,9 @@ def and_i_upload_a_file_with_a_twin
78102
end
79103

80104
def then_i_should_see_the_import_page_with_successful_import
81-
expect(page).to have_content("0 previously imported records were omitted")
105+
expect(page).to have_content(
106+
"0 records were not imported because they already exist in Mavis"
107+
)
82108
expect(Patient.count).to eq(4)
83109
end
84110

spec/features/import_class_lists_move_spec.rb

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,36 @@ def given_an_hpv_programme_is_underway
8383
def and_pds_lookup_during_import_is_enabled
8484
Flipper.enable(:pds_lookup_during_import)
8585

86-
stub_pds_search_to_return_a_patient
87-
stub_pds_get_nhs_number_to_return_a_patient
86+
stub_pds_search_to_return_no_patients(
87+
"family" => "Smith",
88+
"given" => "Jimmy",
89+
"birthdate" => "eq2010-01-02",
90+
"address-postalcode" => "SW1A 1AA"
91+
)
92+
93+
stub_pds_search_to_return_a_patient(
94+
"9999075320",
95+
"family" => "Clarke",
96+
"given" => "Jennifer",
97+
"birthdate" => "eq2010-01-01",
98+
"address-postalcode" => "SW1A 1AA"
99+
)
100+
101+
stub_pds_search_to_return_a_patient(
102+
"9999075320",
103+
"family" => "Clarke",
104+
"given" => "Jennifer",
105+
"birthdate" => "eq2010-01-01",
106+
"address-postalcode" => "SW1A 1AB"
107+
)
108+
109+
stub_pds_search_to_return_a_patient(
110+
"9435764479",
111+
"family" => "Doe",
112+
"given" => "Mark",
113+
"birthdate" => "eq2010-01-03",
114+
"address-postalcode" => "SW1A 1AA"
115+
)
88116
end
89117

90118
def when_i_visit_a_session_page_for_the_hpv_programme

spec/features/import_class_lists_spec.rb

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,36 @@ def given_an_hpv_programme_is_underway
8989
def and_pds_lookup_during_import_is_enabled
9090
Flipper.enable(:pds_lookup_during_import)
9191

92-
stub_pds_search_to_return_a_patient
93-
stub_pds_get_nhs_number_to_return_a_patient
92+
stub_pds_search_to_return_no_patients(
93+
"family" => "Smith",
94+
"given" => "Jimmy",
95+
"birthdate" => "eq2010-01-02",
96+
"address-postalcode" => "SW1A 1AA"
97+
)
98+
99+
stub_pds_search_to_return_a_patient(
100+
"9999075320",
101+
"family" => "Clarke",
102+
"given" => "Jennifer",
103+
"birthdate" => "eq2010-01-01",
104+
"address-postalcode" => "SW1A 1AA"
105+
)
106+
107+
stub_pds_search_to_return_a_patient(
108+
"9999075320",
109+
"family" => "Clarke",
110+
"given" => "Jennifer",
111+
"birthdate" => "eq2010-01-01",
112+
"address-postalcode" => "SW1A 1AB"
113+
)
114+
115+
stub_pds_search_to_return_a_patient(
116+
"9435764479",
117+
"family" => "Doe",
118+
"given" => "Mark",
119+
"birthdate" => "eq2010-01-03",
120+
"address-postalcode" => "SW1A 1AA"
121+
)
94122
end
95123

96124
def when_i_visit_a_session_page_for_the_hpv_programme

spec/features/import_class_lists_with_duplicates_spec.rb

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,26 @@ def given_i_am_signed_in
9494
def and_pds_lookup_during_import_is_enabled
9595
Flipper.enable(:pds_lookup_during_import)
9696

97-
stub_pds_search_to_return_a_patient
98-
stub_pds_get_nhs_number_to_return_a_patient
97+
stub_pds_search_to_return_no_patients(
98+
"family" => "Smith",
99+
"given" => "Jimmy",
100+
"birthdate" => "eq2010-01-01",
101+
"address-postalcode" => "SW1A 1BB"
102+
)
103+
104+
stub_pds_search_to_return_no_patients(
105+
"family" => "Salles",
106+
"given" => "Rebecca",
107+
"birthdate" => "eq2010-02-03",
108+
"address-postalcode" => "SW1A 3BB"
109+
)
110+
111+
stub_pds_search_to_return_no_patients(
112+
"family" => "Jones",
113+
"given" => "Sara",
114+
"birthdate" => "eq2010-02-02",
115+
"address-postalcode" => "SW1A 2BB"
116+
)
99117
end
100118

101119
def and_an_hpv_programme_is_underway
@@ -185,7 +203,9 @@ def and_i_upload_a_file_with_duplicate_records
185203
end
186204

187205
def then_i_should_see_the_import_page_with_duplicate_records
188-
expect(page).to have_content("3 duplicate records need review")
206+
expect(page).to have_content(
207+
"3 records have import issues to resolve before they can be imported into Mavis"
208+
)
189209
end
190210

191211
def when_i_review_the_first_duplicate_record

0 commit comments

Comments
 (0)