Skip to content

Commit 64a3fc1

Browse files
authored
Merge pull request #520 from NHSDigital/fix-remove-from-cohort-test
Change readd to cohort test to archive/unarchive test
2 parents 58179af + 37d4a40 commit 64a3fc1

File tree

2 files changed

+40
-43
lines changed

2 files changed

+40
-43
lines changed

mavis/test/pages/children.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def __init__(self, page: Page, test_data: TestData):
3535
self.change_nhs_no_link = self.page.get_by_role(
3636
"link", name="Change   NHS number"
3737
)
38-
self.remove_from_cohort_button = self.page.get_by_role(
39-
"button", name="Remove from cohort"
38+
self.archive_child_record_link = self.page.get_by_role(
39+
"link", name="Archive child record"
4040
)
4141
self.continue_button = self.page.get_by_role("button", name="Continue")
4242

@@ -48,6 +48,12 @@ def __init__(self, page: Page, test_data: TestData):
4848
self.manually_matched_card = self.page.get_by_text(
4949
"Consent response manually matched with child record"
5050
)
51+
self.imported_in_error_radio = self.page.get_by_role(
52+
"radio", name="It was imported in error"
53+
)
54+
self.archive_record_button = self.page.get_by_role(
55+
"button", name="Archive record"
56+
)
5157

5258
def verify_headers(self):
5359
expect(self.children_heading).to_be_visible()
@@ -128,9 +134,9 @@ def click_edit_child_record(self) -> None:
128134
def click_continue(self) -> None:
129135
self.continue_button.click()
130136

131-
@step("Click on Remove from cohort")
132-
def click_remove_from_cohort(self) -> None:
133-
self.remove_from_cohort_button.click()
137+
@step("Click on Archive child record")
138+
def click_archive_child_record(self) -> None:
139+
self.archive_child_record_link.click()
134140

135141
@step("Fill NHS number {2} for child {1}")
136142
def fill_nhs_no_for_child(self, child: Child, nhs_no: str) -> None:
@@ -165,8 +171,24 @@ def verify_activity_log_for_created_or_matched_child(
165171
# FIXME: Update this text when MAVIS-1896/MAV-253 is closed
166172
self.check_log_updates_with_match()
167173

168-
def remove_child_from_cohort(self, child: Child):
174+
def archive_child_record(self, child: Child):
169175
self.search_for_a_child_name(str(child))
170176
self.click_record_for_child(child)
171-
self.click_remove_from_cohort()
172-
self.expect_text_in_main(f"{str(child)} removed from cohort")
177+
self.click_archive_child_record()
178+
self.click_imported_in_error()
179+
self.click_archive_record()
180+
expect(self.page.get_by_role("alert")).to_contain_text(
181+
"This record has been archived"
182+
)
183+
expect(self.page.get_by_text("Archive reason")).to_be_visible()
184+
185+
@step("Click on Imported in error")
186+
def click_imported_in_error(self):
187+
self.imported_in_error_radio.check()
188+
189+
@step("Click on Archive record")
190+
def click_archive_record(self):
191+
self.archive_record_button.click()
192+
193+
def check_child_is_unarchived(self):
194+
expect(self.archive_child_record_link).to_be_visible()

tests/test_programmes.py

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -139,58 +139,33 @@ def test_cohorts_empty_file(setup_cohort_upload, import_records_page):
139139
@issue("MAV-909")
140140
@pytest.mark.cohorts
141141
@pytest.mark.bug
142-
def test_cohorts_readd_to_cohort(
142+
def test_cohorts_archive_and_unarchive(
143143
setup_cohort_upload,
144144
programmes_page,
145145
dashboard_page,
146146
children_page,
147147
import_records_page,
148-
test_data,
149148
children,
150149
):
151-
"""
152-
Steps to reproduce:
153-
Find a patient in Year 8 and remove them from cohort using the button
154-
Upload a cohort list with their first name, surname, URN, date of birth and postcode
155-
156-
Scenario 1
157-
Duplicate review is not flagged
158-
159-
Expected result:
160-
The child is added back into the cohort, and in all the relevant sessions
161-
Actual Result:
162-
Server error page and user cannot bring the child back into the cohort
163-
164-
Scenario 2
165-
The import screen flags for duplicate review, and user clicks "Review" next to the child's name
166-
167-
Expected result:
168-
System allows you to review the new details against the previous record (before removing from cohort) and lets you choose which record to keep. Once review confirmed, the child is added back into the cohort, and in all the relevant sessions.
169-
Actual Result:
170-
Server error page and user cannot bring the child back into the cohort
171-
"""
172150
child = children[Programme.HPV][0]
173151

174-
input_file_path, _ = import_records_page.upload_and_verify_output(
175-
CohortsFileMapping.FIXED_CHILD
176-
)
152+
import_records_page.upload_and_verify_output(CohortsFileMapping.FIXED_CHILD)
177153

178154
dashboard_page.click_mavis()
179155
dashboard_page.click_children()
180-
children_page.remove_child_from_cohort(child)
156+
children_page.archive_child_record(child)
157+
181158
dashboard_page.click_mavis()
182159
dashboard_page.click_programmes()
183160
programmes_page.navigate_to_cohort_import(Programme.HPV)
184161

185-
test_data.increment_date_of_birth_for_records(input_file_path)
186-
import_records_page.set_input_file(input_file_path)
187-
import_records_page.click_continue()
162+
import_records_page.upload_and_verify_output(CohortsFileMapping.FIXED_CHILD)
188163

189-
programmes_page.expect_text("1 duplicate record needs review")
190-
programmes_page.click_review()
191-
programmes_page.click_use_duplicate()
192-
programmes_page.click_resolve_duplicate()
193-
programmes_page.expect_text("Record updated")
164+
dashboard_page.click_mavis()
165+
dashboard_page.click_children()
166+
children_page.search_for_a_child_name(str(child))
167+
children_page.click_record_for_child(child)
168+
children_page.check_child_is_unarchived()
194169

195170

196171
@pytest.mark.rav

0 commit comments

Comments
 (0)