Skip to content

Commit 00a9048

Browse files
committed
Add assertions for OSFI affiliations on preprint rewiev and detail pages
1 parent 0fdd942 commit 00a9048

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

pages/preprints.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ class PreprintSubmitPage(BasePreprintPage):
100100
By.CSS_SELECTOR,
101101
'#ember-basic-dropdown-wormhole > div > ul >li.ember-power-select-option',
102102
)
103+
affiliated_institutions = GroupLocator(By.CSS_SELECTOR, '[data-test-institution]')
104+
105+
def get_affiliated_institutions(self) -> list:
106+
return [el.text for el in self.affiliated_institutions]
103107

104108
def select_from_dropdown_listbox(self, selection):
105109
for option in self.dropdown_options:
@@ -180,13 +184,28 @@ def select_top_level_subject(self, selection):
180184
By.CSS_SELECTOR, '[data-test-create-project-submit]'
181185
)
182186

187+
# Review Page
188+
preprint_institution_list_review = GroupLocator(
189+
By.CSS_SELECTOR, 'img[data-test-preprint-institution-list]'
190+
)
183191
create_preprint_button = Locator(By.CSS_SELECTOR, '[data-test-submit-button]')
184192
modal_create_preprint_button = Locator(
185193
By.CSS_SELECTOR,
186194
'.modal-footer button.btn-success:nth-child(2)',
187195
settings.LONG_TIMEOUT,
188196
)
189197

198+
def get_preprint_institution_list_review(self) -> list:
199+
return [el.get_attribute('alt') for el in self.preprint_institution_list_review]
200+
201+
# Preprint Detail Page
202+
preprint_institution_list_detail = GroupLocator(
203+
By.CSS_SELECTOR, 'img[data-test-preprint-institution-list]'
204+
)
205+
206+
def get_preprint_institution_list_detail(self) -> list:
207+
return [el.get_attribute('alt') for el in self.preprint_institution_list_detail]
208+
190209

191210
class PreprintEditPage(PreprintSubmitPage):
192211
url_base = urljoin(settings.OSF_HOME, '{guid}')

tests/test_preprints.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ def test_create_preprint_from_landing(
9999
submit_page.next_button.click()
100100

101101
# Metadata page
102+
WebDriverWait(driver, 5).until(
103+
EC.visibility_of_element_located(
104+
(By.CSS_SELECTOR, '[data-test-institution]')
105+
)
106+
)
107+
affiliated_institutions_names_metadata_page = (
108+
submit_page.get_affiliated_institutions()
109+
)
102110
WebDriverWait(driver, 5).until(
103111
EC.element_to_be_clickable(
104112
(By.CSS_SELECTOR, '[data-test-power-select-dropdown]')
@@ -195,11 +203,38 @@ def test_create_preprint_from_landing(
195203
submit_page.supplemental_project_create_button.click()
196204
submit_page.info_toast.here_then_gone()
197205
submit_page.next_button.click()
206+
WebDriverWait(driver, 5).until(
207+
EC.visibility_of_element_located(
208+
(By.CSS_SELECTOR, 'img[data-test-preprint-institution-list]')
209+
)
210+
)
211+
affiliated_institutions_names_review_page = (
212+
submit_page.get_preprint_institution_list_review()
213+
)
214+
assert (
215+
affiliated_institutions_names_metadata_page
216+
== affiliated_institutions_names_review_page
217+
), (
218+
f'Affiliated institutions on the Review Page do not match expected values.\n'
219+
f'Expected: {affiliated_institutions_names_metadata_page }\n'
220+
f'Actual: {affiliated_institutions_names_review_page}'
221+
)
198222
submit_page.info_toast.here_then_gone()
199223
submit_page.create_preprint_button.click()
200224
preprint_detail = PreprintDetailPage(driver, verify=True)
201225
WebDriverWait(driver, 10).until(EC.visibility_of(preprint_detail.title))
202226
assert preprint_detail.title.text == 'Selenium Test Preprint'
227+
affiliated_institutions_names_detail_page = (
228+
submit_page.get_preprint_institution_list_detail()
229+
)
230+
assert (
231+
affiliated_institutions_names_metadata_page
232+
== affiliated_institutions_names_detail_page
233+
), (
234+
f'Affiliated institutions on the Preprint Detail Page do not match expected values.\n'
235+
f'Expected: {affiliated_institutions_names_metadata_page }\n'
236+
f'Actual: {affiliated_institutions_names_detail_page}'
237+
)
203238
# Capture guid of supplemental materials project created during workflow
204239
supplemental_url = preprint_detail.view_page.get_attribute('href')
205240
supplemental_guid = utils.get_guid_from_url(supplemental_url, 3)

0 commit comments

Comments
 (0)