Skip to content

Commit 385ea37

Browse files
authored
Merge pull request #4443 from nhsuk/refactor-import-tests
2 parents 7cee906 + 2b7a42d commit 385ea37

17 files changed

+38
-1256
lines changed

spec/features/e2e_journey_spec.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,7 @@ def when_i_upload_the_cohort_import_containing_one_child
115115
click_on "Continue"
116116
attach_file "cohort_import[csv]", csv_file.path
117117
click_on "Continue"
118-
119-
perform_enqueued_jobs(only: ProcessImportJob)
120-
perform_enqueued_jobs(only: ProcessPatientChangesetsJob)
121-
perform_enqueued_jobs(only: CommitPatientChangesetsJob)
122-
123-
visit cohort_import_path(CohortImport.last)
118+
wait_for_import_to_complete(CohortImport)
124119
end
125120

126121
def then_i_see_that_the_cohort_has_been_uploaded

spec/features/hpv_vaccination_offline_spec.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,7 @@ def and_i_upload_the_modified_csv_file
365365
attach_file("immunisation_import[csv]", "tmp/modified.csv")
366366
click_on "Continue"
367367

368-
perform_enqueued_jobs(only: ProcessImportJob)
369-
perform_enqueued_jobs(only: ProcessPatientChangesetsJob)
370-
perform_enqueued_jobs(only: CommitPatientChangesetsJob)
371-
372-
click_link ImmunisationImport.last.created_at.to_fs(:long), match: :first
368+
wait_for_import_to_complete(ImmunisationImport)
373369
end
374370

375371
def when_i_navigate_to_the_session_page

spec/features/import_child_pds_lookup_extravaganza_spec.rb

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -424,15 +424,7 @@ def and_i_upload_import_file(filename)
424424
click_button "Continue"
425425
attach_file("cohort_import[csv]", "spec/fixtures/cohort_import/#{filename}")
426426
click_on "Continue"
427-
428-
perform_enqueued_jobs(only: ProcessImportJob)
429-
perform_enqueued_jobs(only: ProcessPatientChangesetsJob)
430-
perform_enqueued_jobs(only: CommitPatientChangesetsJob)
431-
432-
# TODO: Hack to make sure all the steps are processed.
433-
10.times { perform_enqueued_jobs }
434-
435-
visit cohort_import_path(CohortImport.last)
427+
wait_for_import_to_complete(CohortImport)
436428
end
437429

438430
def when_i_visit_a_session_page_for_the_hpv_programme
@@ -463,13 +455,7 @@ def when_i_upload_a_valid_file
463455
"spec/fixtures/class_import/pds_extravaganza.csv"
464456
)
465457
click_on "Continue"
466-
467-
perform_enqueued_jobs(only: ProcessImportJob)
468-
perform_enqueued_jobs(only: ProcessPatientChangesetsJob)
469-
perform_enqueued_jobs(only: CommitPatientChangesetsJob)
470-
471-
click_link ClassImport.order(:created_at).last.created_at.to_fs(:long),
472-
match: :first
458+
wait_for_import_to_complete(ClassImport)
473459
end
474460

475461
def when_i_visit_the_import_page

spec/features/import_child_records_preparation_spec.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,7 @@ def then_i_should_see_the_import_page
280280
def when_i_upload_a_valid_file
281281
attach_file("cohort_import[csv]", "spec/fixtures/cohort_import/valid.csv")
282282
click_on "Continue"
283-
284-
perform_enqueued_jobs(only: ProcessImportJob)
285-
perform_enqueued_jobs(only: ProcessPatientChangesetsJob)
286-
perform_enqueued_jobs(only: CommitPatientChangesetsJob)
287-
288-
click_link CohortImport.last.created_at.to_fs(:long), match: :first
283+
wait_for_import_to_complete(CohortImport)
289284
end
290285

291286
def then_i_should_see_the_patients

spec/features/import_child_records_slow_spec.rb

Lines changed: 0 additions & 154 deletions
This file was deleted.

spec/features/import_child_records_spec.rb

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,7 @@ def then_i_should_see_the_import_page
192192
def and_i_upload_a_valid_file
193193
attach_file("cohort_import[csv]", "spec/fixtures/cohort_import/valid.csv")
194194
click_on "Continue"
195-
196-
perform_enqueued_jobs(only: ProcessImportJob)
197-
perform_enqueued_jobs(only: ProcessPatientChangesetsJob)
198-
perform_enqueued_jobs(only: CommitPatientChangesetsJob)
199-
200-
click_link CohortImport.last.created_at.to_fs(:long), match: :first
195+
wait_for_import_to_complete(CohortImport)
201196
end
202197

203198
def and_i_should_see_the_patients
@@ -359,12 +354,7 @@ def when_i_upload_a_valid_file_with_changes
359354
"spec/fixtures/cohort_import/valid_with_changes.csv"
360355
)
361356
click_on "Continue"
362-
363-
perform_enqueued_jobs(only: ProcessImportJob)
364-
perform_enqueued_jobs(only: ProcessPatientChangesetsJob)
365-
perform_enqueued_jobs(only: CommitPatientChangesetsJob)
366-
367-
click_link CohortImport.last.created_at.to_fs(:long), match: :first
357+
wait_for_import_to_complete(CohortImport)
368358
end
369359

370360
def and_i_go_to_the_import_page

spec/features/import_child_records_with_duplicates_spec.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,7 @@ def and_i_start_adding_children_to_the_cohort
216216
def and_i_upload_a_file_with_duplicate_records
217217
attach_file("cohort_import[csv]", "spec/fixtures/cohort_import/valid.csv")
218218
click_on "Continue"
219-
220-
perform_enqueued_jobs(only: ProcessImportJob)
221-
perform_enqueued_jobs(only: ProcessPatientChangesetsJob)
222-
perform_enqueued_jobs(only: CommitPatientChangesetsJob)
223-
224-
click_link CohortImport.last.created_at.to_fs(:long), match: :first
219+
wait_for_import_to_complete(CohortImport)
225220
end
226221

227222
def then_i_should_see_the_import_page_with_duplicate_records

spec/features/import_child_records_with_twins_spec.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,7 @@ def and_i_start_adding_children_to_the_cohort
100100
def and_i_upload_a_file_with_a_twin
101101
attach_file("cohort_import[csv]", "spec/fixtures/cohort_import/valid.csv")
102102
click_on "Continue"
103-
104-
perform_enqueued_jobs(only: ProcessImportJob)
105-
perform_enqueued_jobs(only: ProcessPatientChangesetsJob)
106-
perform_enqueued_jobs(only: CommitPatientChangesetsJob)
107-
108-
visit cohort_import_path(CohortImport.last)
103+
wait_for_import_to_complete(CohortImport)
109104
end
110105

111106
def then_i_should_see_the_import_page_with_successful_import

spec/features/import_class_lists_move_spec.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,7 @@ def then_i_should_see_the_import_page
152152
def when_i_upload_a_valid_file
153153
attach_file("class_import[csv]", "spec/fixtures/class_import/valid.csv")
154154
click_on "Continue"
155-
156-
perform_enqueued_jobs(only: ProcessImportJob)
157-
perform_enqueued_jobs(only: ProcessPatientChangesetsJob)
158-
perform_enqueued_jobs(only: CommitPatientChangesetsJob)
159-
160-
visit class_import_path(ClassImport.last)
155+
wait_for_import_to_complete(ClassImport)
161156
end
162157

163158
alias_method :and_i_upload_a_valid_file, :when_i_upload_a_valid_file

spec/features/import_class_lists_spec.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,7 @@ def and_i_upload_a_valid_file
163163
attach_file("class_import[csv]", "spec/fixtures/class_import/valid.csv")
164164
click_on "Continue"
165165

166-
perform_enqueued_jobs(only: ProcessImportJob)
167-
perform_enqueued_jobs(only: ProcessPatientChangesetsJob)
168-
perform_enqueued_jobs(only: CommitPatientChangesetsJob)
169-
170-
click_link ClassImport.order(:created_at).last.created_at.to_fs(:long),
171-
match: :first
166+
wait_for_import_to_complete(ClassImport)
172167
end
173168

174169
def then_i_should_see_the_patients

0 commit comments

Comments
 (0)