Skip to content

Commit b67b432

Browse files
committed
Code review fixes
1 parent cb17534 commit b67b432

File tree

6 files changed

+6
-258
lines changed

6 files changed

+6
-258
lines changed

Diff for: components/accessibility.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def run_axe(
1313
page_name,
1414
write_files=True,
1515
terminal_errors=True,
16-
exclude_best_practice=False,
16+
exclude_best_practice=True,
1717
):
1818
"""Use the axe testing engine to perform accessibility checks on a web page
1919
Parameters:
@@ -25,7 +25,7 @@ def run_axe(
2525
errors to terminal window - default = True
2626
- exclude_best_practice - boolean - used to determine whether or not to
2727
exclude the Best Practice rule set when performing accessibility check.
28-
- default = False
28+
- set default to True
2929
"""
3030
axe = Axe(driver)
3131
# Inject axe-core javascript into page.

Diff for: pages/institutions.py

+1-33
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class InstitutionBrandedPage(BaseInstitutionPage):
4545
identity = Locator(By.CSS_SELECTOR, 'img[data-test-institution-banner]')
4646

4747
empty_collection_indicator = Locator(
48-
By.CLASS_NAME, 'div[class="_no-results_fvrbco"]'
48+
By.CSS_SELECTOR, '[data-test-search-page-no-results]'
4949
)
5050

5151
# Group Locators
@@ -60,35 +60,3 @@ class InstitutionAdminDashboardPage(BaseInstitutionPage):
6060

6161
identity = Locator(By.CSS_SELECTOR, 'div[data-analytics-scope="Dashboard"]')
6262
loading_indicator = Locator(By.CSS_SELECTOR, '.ball-scale', settings.LONG_TIMEOUT)
63-
departments_listbox_trigger = Locator(
64-
By.CSS_SELECTOR,
65-
'div.ember-basic-dropdown-trigger.ember-power-select-trigger._select_tdvp4z',
66-
)
67-
total_user_count = Locator(
68-
By.CSS_SELECTOR,
69-
'div.ember-view._panel_1dj7yu._sso-users-connected_1w5vdt > div > div._panel-body_1lht4i > div > h3',
70-
)
71-
total_project_count = Locator(
72-
By.CSS_SELECTOR,
73-
'div.ember-view._panel_1dj7yu._projects_1w5vdt > div > div._panel-body_1lht4i > div > div > h3',
74-
)
75-
public_project_count = Locator(
76-
By.CSS_SELECTOR, 'div._projects-count_1ky9tx > span:nth-child(1) > strong'
77-
)
78-
private_project_count = Locator(
79-
By.CSS_SELECTOR, 'div._projects-count_1ky9tx > span:nth-child(2) > strong'
80-
)
81-
82-
department_options = GroupLocator(
83-
By.CSS_SELECTOR, 'ul.ember-power-select-options > li.ember-power-select-option'
84-
)
85-
user_table_rows = GroupLocator(
86-
By.CSS_SELECTOR,
87-
'div._table-wrapper_1w5vdt > div > div.ember-view > div > div > table > tbody > tr',
88-
)
89-
90-
def select_department_from_listbox(self, department):
91-
for option in self.department_options:
92-
if option.text == department:
93-
option.click()
94-
break

Diff for: pages/preprints.py

-218
Original file line numberDiff line numberDiff line change
@@ -59,104 +59,12 @@ class PreprintLandingPage(BasePreprintPage):
5959
'[data-analytics-scope="preprints landing page"]',
6060
settings.LONG_TIMEOUT,
6161
)
62-
add_preprint_button = Locator(
63-
By.CLASS_NAME, '[data-analytics-name="Add a preprint"]', settings.LONG_TIMEOUT
64-
)
65-
search_button = Locator(By.CSS_SELECTOR, '[data-analytics-name="Search"]')
66-
submit_button = Locator(By.CSS_SELECTOR, '[data-test-submit-button]')
6762

6863

6964
class PreprintSubmitPage(BasePreprintPage):
7065
url_addition = 'submit'
7166

7267
identity = Locator(By.CLASS_NAME, 'preprint-submit-header')
73-
select_a_service_help_text = Locator(
74-
By.CSS_SELECTOR, 'dl[class="dl-horizontal dl-description"]'
75-
)
76-
select_a_service_save_button = Locator(
77-
By.CSS_SELECTOR, '#preprint-form-server button.btn.btn-primary'
78-
)
79-
80-
upload_from_existing_project_button = Locator(
81-
By.XPATH, '//button[text()="Select from an existing OSF project"]'
82-
)
83-
upload_project_selector = Locator(
84-
By.CSS_SELECTOR, 'span[class="ember-power-select-placeholder"]'
85-
)
86-
upload_project_selector_input = Locator(
87-
By.CSS_SELECTOR, 'input[class="ember-power-select-search-input"]'
88-
)
89-
upload_project_help_text = Locator(
90-
By.CSS_SELECTOR, '.ember-power-select-option--search-message'
91-
)
92-
upload_project_selector_project = Locator(
93-
By.CSS_SELECTOR, '.ember-power-select-option'
94-
)
95-
upload_select_file = Locator(By.CSS_SELECTOR, '.file-browser-item > a:nth-child(2)')
96-
upload_file_save_continue = Locator(
97-
By.CSS_SELECTOR,
98-
'div[class="p-t-xs pull-right"] > button[class="btn btn-primary"]',
99-
)
100-
101-
# Author Assertions
102-
public_available_button = Locator(
103-
By.ID, 'hasDataLinksAvailable', settings.QUICK_TIMEOUT
104-
)
105-
public_data_input = Locator(
106-
By.CSS_SELECTOR, '[data-test-multiple-textbox-index] > input'
107-
)
108-
preregistration_no_button = Locator(By.ID, 'hasPreregLinksNo')
109-
preregistration_input = Locator(By.NAME, 'whyNoPrereg')
110-
save_author_assertions = Locator(
111-
By.CSS_SELECTOR, '[data-test-author-assertions-continue]'
112-
)
113-
114-
basics_license_dropdown = Locator(
115-
By.CSS_SELECTOR, 'select[class="form-control"]', settings.LONG_TIMEOUT
116-
)
117-
basics_tags_section = Locator(By.CSS_SELECTOR, '#preprint-form-basics .tagsinput')
118-
basics_tags_input = Locator(
119-
By.CSS_SELECTOR, '#preprint-form-basics .tagsinput input'
120-
)
121-
basics_abstract_input = Locator(By.NAME, 'basicsAbstract')
122-
basics_save_button = Locator(By.CSS_SELECTOR, '#preprint-form-basics .btn-primary')
123-
124-
first_discipline = Locator(
125-
By.CSS_SELECTOR, 'ul[role="listbox"] > li:nth-child(2)', settings.QUICK_TIMEOUT
126-
)
127-
discipline_save_button = Locator(
128-
By.CSS_SELECTOR, '#preprint-form-subjects .btn-primary'
129-
)
130-
131-
authors_save_button = Locator(
132-
By.CSS_SELECTOR, '#preprint-form-authors .btn-primary', settings.QUICK_TIMEOUT
133-
)
134-
135-
conflict_of_interest_yes = Locator(By.ID, 'coiYes', settings.QUICK_TIMEOUT)
136-
conflict_of_interest_no = Locator(By.ID, 'coiNo', settings.QUICK_TIMEOUT)
137-
no_coi_text_box = Locator(
138-
By.CSS_SELECTOR, '[data-test-has-no-coi]', settings.QUICK_TIMEOUT
139-
)
140-
coi_save_button = Locator(By.CSS_SELECTOR, '[data-test-coi-continue]')
141-
142-
supplemental_create_new_project = Locator(
143-
By.CSS_SELECTOR,
144-
'div[class="start"] > div[class="row"] > div:nth-child(2)',
145-
settings.QUICK_TIMEOUT,
146-
)
147-
supplemental_save_button = Locator(
148-
By.CSS_SELECTOR, '#supplemental-materials .btn-primary'
149-
)
150-
151-
create_preprint_button = Locator(
152-
By.CSS_SELECTOR,
153-
'.preprint-submit-body .submit-section > div > button.btn.btn-success.btn-md.m-t-md.pull-right',
154-
)
155-
modal_create_preprint_button = Locator(
156-
By.CSS_SELECTOR,
157-
'.modal-footer button.btn-success:nth-child(2)',
158-
settings.LONG_TIMEOUT,
159-
)
16068

16169

16270
class PreprintEditPage(GuidBasePage, BasePreprintPage):
@@ -167,46 +75,6 @@ class PreprintEditPage(GuidBasePage, BasePreprintPage):
16775
By.CSS_SELECTOR, '.m-t-md.preprint-header-preview > p:nth-child(1) > em.m-r-md'
16876
)
16977
basics_section = Locator(By.ID, 'preprint-form-basics')
170-
basics_tags_section = Locator(By.CSS_SELECTOR, '#preprint-form-basics .tagsinput')
171-
basics_tags_input = Locator(
172-
By.CSS_SELECTOR, '#preprint-form-basics .tagsinput input'
173-
)
174-
basics_save_button = Locator(By.CSS_SELECTOR, '#preprint-form-basics .btn-primary')
175-
basics_section_changes_saved_indicator = Locator(
176-
By.CSS_SELECTOR,
177-
'#preprint-form-basics > header > div.preprint-section-status.pull-right > span.text-success.',
178-
)
179-
discipline_section = Locator(By.ID, 'preprint-form-subjects')
180-
discipline_save_button = Locator(
181-
By.CSS_SELECTOR, '#preprint-form-subjects .btn-primary'
182-
)
183-
authors_save_button = Locator(
184-
By.CSS_SELECTOR, '#preprint-form-authors .btn-primary', settings.QUICK_TIMEOUT
185-
)
186-
return_to_preprint_button = Locator(
187-
By.CSS_SELECTOR,
188-
'div.submit-section > div > button.btn.btn-default.btn-md.m-t-md.pull-right',
189-
)
190-
withdraw_preprint_button = Locator(
191-
By.CSS_SELECTOR,
192-
'div.submit-section > div > button.btn.btn-danger.btn-md.m-t-md.pull-right',
193-
)
194-
195-
# Group Locators
196-
primary_subjects = GroupLocator(
197-
By.CSS_SELECTOR,
198-
'#preprint-form-subjects > div > div > div:nth-child(2) > div:nth-child(1) > ul > li',
199-
)
200-
201-
def select_primary_subject_by_name(self, subject_name):
202-
"""Select a subject from the first box in the Discipline section (i.e. 'primary'
203-
subject). This function would need to be modified or another separate function
204-
created to select from either of the 2 secondary subject boxes.
205-
"""
206-
for subject in self.primary_subjects:
207-
if subject.text == subject_name:
208-
subject.click()
209-
break
21078

21179

21280
class PreprintWithdrawPage(GuidBasePage, BasePreprintPage):
@@ -217,11 +85,6 @@ class PreprintWithdrawPage(GuidBasePage, BasePreprintPage):
21785
By.CSS_SELECTOR,
21886
'section.preprint-form-block.preprint-form-section-withdraw-comment',
21987
)
220-
reason_for_withdrawal_textarea = Locator(By.NAME, 'explanation')
221-
request_withdrawal_button = Locator(
222-
By.CSS_SELECTOR,
223-
'div.submit-section > button.btn.btn-danger.btn-md.m-t-md.pull-right',
224-
)
22588

22689

22790
@pytest.mark.usefixtures('must_be_logged_in')
@@ -232,17 +95,6 @@ class PreprintDiscoverPage(BasePreprintPage):
23295
By.CSS_SELECTOR, 'a[data-test-topbar-object-type-link="Preprints"]'
23396
)
23497
loading_indicator = Locator(By.CSS_SELECTOR, '.ball-scale')
235-
search_box = Locator(By.CSS_SELECTOR, 'input[data-test-search-input]')
236-
sort_button = Locator(By.CSS_SELECTOR, 'div[data-test-topbar-sort-dropdown]')
237-
sort_option_newest_to_oldest = Locator(
238-
By.CSS_SELECTOR, '#sortByOptionList > li:nth-child(3) > button'
239-
)
240-
241-
# Group Locators
242-
search_results = GroupLocator(By.CSS_SELECTOR, 'div[data-test-search-result-card]')
243-
sort_options = GroupLocator(
244-
By.CSS_SELECTOR, 'ul[class="ember-power-select-options"]'
245-
)
24698

24799

248100
@pytest.mark.usefixtures('must_be_logged_in')
@@ -251,15 +103,6 @@ class BrandedPreprintsDiscoverPage(BasePreprintPage):
251103

252104
identity = Locator(By.CSS_SELECTOR, '[data-test-search-provider-logo]')
253105
loading_indicator = Locator(By.CSS_SELECTOR, '.ball-scale')
254-
search_box = Locator(By.CSS_SELECTOR, 'input[data-test-search-input]')
255-
sort_button = Locator(By.CSS_SELECTOR, 'div[data-test-topbar-sort-dropdown]')
256-
sort_option_newest_to_oldest = Locator(
257-
By.CSS_SELECTOR, '#sortByOptionList > li:nth-child(3) > button'
258-
)
259-
no_results = Locator(By.CSS_SELECTOR, 'div[_no-results_fvrbco]')
260-
261-
# Group Locators
262-
search_results = GroupLocator(By.CSS_SELECTOR, 'div[data-test-search-result-card]')
263106

264107

265108
class PreprintDetailPage(GuidBasePage, BasePreprintPage):
@@ -274,31 +117,6 @@ class PreprintDetailPage(GuidBasePage, BasePreprintPage):
274117
By.CSS_SELECTOR, 'h1[data-test-preprint-title]', settings.LONG_TIMEOUT
275118
)
276119
view_page = Locator(By.ID, 'view-page')
277-
views_count = Locator(By.CSS_SELECTOR, '[data-test-view-count]')
278-
downloads_count = Locator(By.CSS_SELECTOR, '[data-test-download-count]')
279-
download_button = Locator(By.CSS_SELECTOR, '[data-test-download-button]')
280-
edit_preprint_button = Locator(By.CSS_SELECTOR, 'div[class="edit-preprint-button"]')
281-
default_citation = Locator(By.CSS_SELECTOR, '[data-test-default-citation="apa"]')
282-
283-
# Locators for the reviews app preprint detail page
284-
status = Locator(By.CSS_SELECTOR, 'span._status-badge_7ivjq4')
285-
status_explanation = Locator(By.CSS_SELECTOR, 'div.status-explanation')
286-
withdraw_reason = Locator(By.CSS_SELECTOR, '[data-test-withdrawal-justification]')
287-
make_decision_button = Locator(
288-
By.CSS_SELECTOR, 'button.btn.dropdown-toggle.btn-success'
289-
)
290-
accept_radio_button = Locator(By.CSS_SELECTOR, 'input[value="accepted"]')
291-
reject_radio_button = Locator(By.CSS_SELECTOR, 'input[value="rejected"]')
292-
withdraw_radio_button = Locator(By.CSS_SELECTOR, 'input[value="withdrawn"]')
293-
reason_textarea = Locator(By.CSS_SELECTOR, 'textarea.form-control.ember-text-area')
294-
submit_decision_button = Locator(By.ID, 'submit-btn')
295-
296-
# Group Locators
297-
subjects = GroupLocator(
298-
By.CSS_SELECTOR,
299-
'[class="subject-preview"]',
300-
)
301-
tags = GroupLocator(By.CSS_SELECTOR, 'div.tag-section.p-t-xs > span')
302120

303121

304122
class PendingPreprintDetailPage(PreprintDetailPage):
@@ -317,29 +135,6 @@ class ReviewsDashboardPage(OSFBasePage):
317135
url = settings.OSF_HOME + '/reviews'
318136
identity = Locator(By.CLASS_NAME, '_reviews-dashboard-header_jdu5ey')
319137
loading_indicator = Locator(By.CSS_SELECTOR, '.ball-scale')
320-
provider_group_links = GroupLocator(
321-
By.CSS_SELECTOR, 'li._provider-links-component_gp8jcl'
322-
)
323-
324-
def click_provider_group_link(self, provider_name, link_name):
325-
"""Search through the Provider Groups in the sidebar on the right side of the
326-
Reviews Dashboard page to find the group with the given provider_name. When
327-
the provider group is found, then search through the links in the group for the
328-
given link_name. Click this link when found.
329-
"""
330-
for provider_group in self.provider_group_links:
331-
group_name = provider_group.find_element_by_css_selector(
332-
'span._provider-name_gp8jcl'
333-
)
334-
if provider_name == group_name.text:
335-
links = provider_group.find_elements_by_css_selector(
336-
'ul._provider-links_gp8jcl > li > a'
337-
)
338-
for link in links:
339-
if link_name in link.text:
340-
link.click()
341-
break
342-
break
343138

344139

345140
class BaseReviewsPage(OSFBasePage):
@@ -402,19 +197,6 @@ class ReviewsWithdrawalsPage(BaseReviewsPage):
402197
url_addition = 'withdrawals'
403198
identity = Locator(By.CLASS_NAME, '_reviews-list-heading_k45x8p')
404199
loading_indicator = Locator(By.CSS_SELECTOR, '.ball-scale')
405-
requests = GroupLocator(By.CSS_SELECTOR, 'div._moderation-list-row_17iwzt')
406-
407-
def click_requests_row(self, provider_id, preprint_id):
408-
"""Search through the rows of requests on the Reviews Withdrawal Requests
409-
page to find the preprint that has the given preprint_id in its url. When the
410-
row is found click it to open the Preprint Detail page for that preprint.
411-
"""
412-
for row in self.requests:
413-
url = row.find_element_by_css_selector('a').get_attribute('href')
414-
node_id = url.split(provider_id + '/', 1)[1]
415-
if node_id == preprint_id:
416-
row.find_element_by_css_selector('div[title]').click()
417-
break
418200

419201

420202
class ReviewsModeratorsPage(BaseReviewsPage):

Diff for: tests/test_a11y_other_osf.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ def test_accessibility(
6363
my_projects_page.goto()
6464
assert MyProjectsPage(driver, verify=True)
6565
my_projects_page.empty_collection_indicator.present()
66-
pytest.xfail("Color-contrast issue documented here -> ENG-3616"
67-
"List issue documented here -> ENG-3146")
66+
pytest.xfail("Color-contrast issue documented here -> ENG-3616. List issue documented here -> ENG-3146")
6867
a11y.run_axe(
6968
driver,
7069
session,

Diff for: tests/test_a11y_preprints.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def test_accessibility_reviews_moderators(
293293
session,
294294
'revmod',
295295
write_files=write_files,
296-
exclude_best_practice=1,
296+
exclude_best_practice=True,
297297
)
298298

299299
def test_accessibility_reviews_notifications(

Diff for: tests/test_a11y_user.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@ def test_accessibility(
181181
assert NotificationsPage(driver, verify=True)
182182
# wait for Notification Preferences section to finish loading
183183
notifications_page.loading_indicator.here_then_gone()
184-
pytest.xfail("Label issue documented here -> ENG-3074"
185-
"Color-contrast issue documented here -> ENG-3075")
184+
pytest.xfail("Label issue documented here -> ENG-3074. Color-contrast issue documented here -> ENG-3075")
186185
a11y.run_axe(
187186
driver,
188187
session,

0 commit comments

Comments
 (0)