Skip to content

Commit

Permalink
Merge pull request #49 from CenterForOpenScience/feature/xfail-tests
Browse files Browse the repository at this point in the history
Update A11y test suite
  • Loading branch information
jh27539 authored Apr 12, 2024
2 parents fdb2517 + 6a3d355 commit 86487dd
Show file tree
Hide file tree
Showing 11 changed files with 229 additions and 181 deletions.
6 changes: 3 additions & 3 deletions components/accessibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def run_axe(
page_name,
write_files=True,
terminal_errors=True,
exclude_best_practice=False,
exclude_best_practice=True,
):
"""Use the axe testing engine to perform accessibility checks on a web page
Parameters:
Expand All @@ -25,7 +25,7 @@ def run_axe(
errors to terminal window - default = True
- exclude_best_practice - boolean - used to determine whether or not to
exclude the Best Practice rule set when performing accessibility check.
- default = False
- set default to True
"""
axe = Axe(driver)
# Inject axe-core javascript into page.
Expand Down Expand Up @@ -53,7 +53,7 @@ def run_axe(
)
else:
# This runs axe with all available rule sets which includes WCAG and Best
# Practoce rules.
# Practice rules.
results = axe.run()
if write_files:
write_results_files(axe, results, page_name)
Expand Down
22 changes: 15 additions & 7 deletions pages/institutions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from selenium.webdriver.common.by import By

import settings
from base.locators import ComponentLocator, GroupLocator, Locator
from base.locators import (
ComponentLocator,
GroupLocator,
Locator,
)
from components.navbars import InstitutionsNavbar
from pages.base import OSFBasePage

Expand All @@ -11,13 +15,13 @@ class InstitutionsLandingPage(OSFBasePage):

# TODO fix insitution typo
identity = Locator(
By.CSS_SELECTOR, 'div[data-test-insitutions-header]', settings.VERY_LONG_TIMEOUT
By.CSS_SELECTOR, 'div[data-test-insitutions-header]', settings.TIMEOUT
)

search_bar = Locator(By.CSS_SELECTOR, '.ember-text-field')

# Group Locators
institution_list = GroupLocator(By.CSS_SELECTOR, 'span[data-test-institution-name]')
institution_list = GroupLocator(By.CSS_SELECTOR, 'div[data-test-institution-name]')

navbar = ComponentLocator(InstitutionsNavbar)

Expand All @@ -38,12 +42,16 @@ def url(self):

class InstitutionBrandedPage(BaseInstitutionPage):

identity = Locator(
By.CSS_SELECTOR,
'#fileBrowser > div.db-header.row > div.db-buttonRow.col-xs-12.col-sm-4.col-lg-3 > div > input',
identity = Locator(By.CSS_SELECTOR, 'img[data-test-institution-banner]')

empty_collection_indicator = Locator(
By.CSS_SELECTOR, '[data-test-search-page-no-results]'
)

empty_collection_indicator = Locator(By.CLASS_NAME, 'db-non-load-template')
# Group Locators
project_list = GroupLocator(
By.CSS_SELECTOR, 'a[data-test-search-result-card-title]'
)


class InstitutionAdminDashboardPage(BaseInstitutionPage):
Expand Down
178 changes: 83 additions & 95 deletions pages/preprints.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
from urllib.parse import urljoin

import pytest
from selenium.webdriver.common.by import By

import settings
from base.locators import ComponentLocator, Locator
from base.locators import (
ComponentLocator,
GroupLocator,
Locator,
)
from components.navbars import PreprintsNavbar
from pages.base import GuidBasePage, OSFBasePage
from pages.base import (
GuidBasePage,
OSFBasePage,
)


class BasePreprintPage(OSFBasePage):
Expand Down Expand Up @@ -47,119 +55,80 @@ def verify(self):

class PreprintLandingPage(BasePreprintPage):
identity = Locator(
By.CSS_SELECTOR, '.ember-application .preprint-header', settings.LONG_TIMEOUT
)
add_preprint_button = Locator(
By.CLASS_NAME, 'preprint-submit-button', settings.LONG_TIMEOUT
By.CSS_SELECTOR,
'[data-analytics-scope="preprints landing page"]',
settings.LONG_TIMEOUT,
)
search_button = Locator(By.CSS_SELECTOR, '.preprint-search .btn-default')
submit_navbar = Locator(By.CSS_SELECTOR, '.branded-nav > :nth-child(2)')
submit_button = Locator(By.CSS_SELECTOR, '.btn.btn-success')


class PreprintSubmitPage(BasePreprintPage):
url_addition = 'submit'

identity = Locator(By.CLASS_NAME, 'preprint-submit-header')
select_a_service_help_text = Locator(
By.CSS_SELECTOR, 'dl[class="dl-horizontal dl-description"]'
)
select_a_service_save_button = Locator(
By.CSS_SELECTOR, '#preprint-form-server button.btn.btn-primary'
)

upload_from_existing_project_button = Locator(
By.XPATH, '//button[text()="Select from an existing OSF project"]'
)
upload_project_selector = Locator(
By.CSS_SELECTOR, 'span[class="ember-power-select-placeholder"]'
)
upload_project_selector_input = Locator(
By.CSS_SELECTOR, 'input[class="ember-power-select-search-input"]'
)
upload_project_help_text = Locator(
By.CSS_SELECTOR, '.ember-power-select-option--search-message'
)
upload_project_selector_project = Locator(
By.CSS_SELECTOR, '.ember-power-select-option'
)
upload_select_file = Locator(By.CSS_SELECTOR, '.file-browser-item > a:nth-child(2)')
upload_file_save_continue = Locator(
By.CSS_SELECTOR,
'div[class="p-t-xs pull-right"] > button[class="btn btn-primary"]',
)

# Author Assertions
public_available_button = Locator(
By.ID, 'hasDataLinksAvailable', settings.QUICK_TIMEOUT
)
public_data_input = Locator(
By.CSS_SELECTOR, '[data-test-multiple-textbox-index] > input'
)
preregistration_no_button = Locator(By.ID, 'hasPreregLinksNo')
preregistration_input = Locator(By.NAME, 'whyNoPrereg')
save_author_assertions = Locator(
By.CSS_SELECTOR, '[data-test-author-assertions-continue]'
)

basics_license_dropdown = Locator(
By.CSS_SELECTOR, 'select[class="form-control"]', settings.LONG_TIMEOUT
)
basics_tags_section = Locator(By.CSS_SELECTOR, '#preprint-form-basics .tagsinput')
basics_tags_input = Locator(
By.CSS_SELECTOR, '#preprint-form-basics .tagsinput input'
)
basics_abstract_input = Locator(By.NAME, 'basicsAbstract')
basics_save_button = Locator(By.CSS_SELECTOR, '#preprint-form-basics .btn-primary')
class PreprintEditPage(GuidBasePage, BasePreprintPage):
url_base = urljoin(settings.OSF_HOME, '{guid}')
url_addition = '/edit'

first_discipline = Locator(
By.CSS_SELECTOR, 'ul[role="listbox"] > li:nth-child(2)', settings.QUICK_TIMEOUT
)
discipline_save_button = Locator(
By.CSS_SELECTOR, '#preprint-form-subjects .btn-primary'
identity = Locator(
By.CSS_SELECTOR, '.m-t-md.preprint-header-preview > p:nth-child(1) > em.m-r-md'
)
basics_section = Locator(By.ID, 'preprint-form-basics')

authors_save_button = Locator(
By.CSS_SELECTOR, '#preprint-form-authors .btn-primary', settings.QUICK_TIMEOUT
)

conflict_of_interest = Locator(By.ID, 'coiNo', settings.QUICK_TIMEOUT)
coi_save_button = Locator(By.CSS_SELECTOR, '[data-test-coi-continue]')
class PreprintWithdrawPage(GuidBasePage, BasePreprintPage):
url_base = urljoin(settings.OSF_HOME, '{guid}')
url_addition = '/withdraw'

supplemental_create_new_project = Locator(
identity = Locator(
By.CSS_SELECTOR,
'div[class="start"] > div[class="row"] > div:nth-child(2)',
settings.QUICK_TIMEOUT,
)
supplemental_save_button = Locator(
By.CSS_SELECTOR, '#supplemental-materials .btn-primary'
'section.preprint-form-block.preprint-form-section-withdraw-comment',
)

create_preprint_button = Locator(
By.CSS_SELECTOR,
'.preprint-submit-body .submit-section > div > button.btn.btn-success.btn-md.m-t-md.pull-right',
)
modal_create_preprint_button = Locator(
By.CSS_SELECTOR,
'.modal-footer button.btn-success:nth-child(2)',
settings.LONG_TIMEOUT,

@pytest.mark.usefixtures('must_be_logged_in')
class PreprintDiscoverPage(BasePreprintPage):
base_url = settings.OSF_HOME + '/search?resourceType=Preprint'

identity = Locator(
By.CSS_SELECTOR, 'a[data-test-topbar-object-type-link="Preprints"]'
)
loading_indicator = Locator(By.CSS_SELECTOR, '.ball-scale')


class PreprintDiscoverPage(BasePreprintPage):
@pytest.mark.usefixtures('must_be_logged_in')
class BrandedPreprintsDiscoverPage(BasePreprintPage):
url_addition = 'discover'

identity = Locator(By.ID, 'share-logo')
identity = Locator(By.CSS_SELECTOR, '[data-test-search-provider-logo]')
loading_indicator = Locator(By.CSS_SELECTOR, '.ball-scale')


class PreprintDetailPage(GuidBasePage, BasePreprintPage):
url_base = urljoin(settings.OSF_HOME, '{guid}')
identity = Locator(
By.CSS_SELECTOR,
'[data-test-preprint-header]',
settings.LONG_TIMEOUT,
)

identity = Locator(By.ID, 'preprintTitle', settings.LONG_TIMEOUT)
title = Locator(By.ID, 'preprintTitle', settings.LONG_TIMEOUT)
title = Locator(
By.CSS_SELECTOR, 'h1[data-test-preprint-title]', settings.LONG_TIMEOUT
)
view_page = Locator(By.ID, 'view-page')
authors_load_indicator = Locator(By.CSS_SELECTOR, '.comma-list > .ball-pulse')


class PendingPreprintDetailPage(PreprintDetailPage):
# This class is for preprints that are pending moderation
identity = Locator(
By.ID,
'preprintTitle',
settings.LONG_TIMEOUT,
)

# This locator needs a data-test-selector from software devs
title = Locator(By.ID, 'preprintTitle', settings.LONG_TIMEOUT)


class ReviewsDashboardPage(OSFBasePage):
Expand Down Expand Up @@ -199,28 +168,39 @@ def verify(self):


class ReviewsSubmissionsPage(BaseReviewsPage):
identity = Locator(
By.CLASS_NAME, '_reviews-list-heading_k45x8p', settings.LONG_TIMEOUT
)
loading_indicator = Locator(By.CSS_SELECTOR, '.ball-scale')
identity = Locator(By.CLASS_NAME, '_reviews-list-heading_k45x8p')
no_submissions = Locator(
By.CSS_SELECTOR,
'div._reviews-list-body_k45x8p > div.text-center.p-v-md._moderation-list-row_xkm0pa',
)
loading_indicator = Locator(By.CSS_SELECTOR, '.ball-scale')
withdrawal_requests_tab = Locator(
By.CSS_SELECTOR,
'div._flex-container_hcnzoe > div:nth-child(3) > ul > li:nth-child(2) > a',
)
submissions = GroupLocator(By.CSS_SELECTOR, 'div._moderation-list-row_xkm0pa')

def click_submission_row(self, provider_id, preprint_id):
"""Search through the rows of submitted preprints on the Reviews Submissions
page to find the preprint that has the given preprint_id in its url. When the
row is found click it to open the Preprint Detail page for that preprint.
"""
for row in self.submissions:
url = row.find_element_by_css_selector('a').get_attribute('href')
node_id = url.split(provider_id + '/', 1)[1]
if node_id == preprint_id:
row.click()
break


class ReviewsWithdrawalsPage(BaseReviewsPage):
url_addition = 'withdrawals'
identity = Locator(By.CLASS_NAME, '_reviews-list-heading_k45x8p')
loading_indicator = Locator(By.CSS_SELECTOR, '.ball-scale')
no_requests = Locator(
By.CSS_SELECTOR,
'div._reviews-list-body_k45x8p > div.text-center.p-v-md._moderation-list-row_xkm0pa',
)


class ReviewsModeratorsPage(BaseReviewsPage):
url_addition = 'moderators'
url_addition = '/moderators'
identity = Locator(By.CLASS_NAME, 'moderator-list-row')
loading_indicator = Locator(By.CSS_SELECTOR, '.ball-scale')

Expand All @@ -235,3 +215,11 @@ class ReviewsSettingsPage(BaseReviewsPage):
url_addition = 'settings'
identity = Locator(By.CLASS_NAME, '_reviews-settings_1r3x0j')
loading_indicator = Locator(By.CSS_SELECTOR, '.ball-scale')


class PreprintPageNotFoundPage(OSFBasePage):
identity = Locator(By.CSS_SELECTOR, '[data-analytics-scope="404"]')
page_header = Locator(
By.CSS_SELECTOR,
'[data-analytics-scope="404"] > h2',
)
2 changes: 1 addition & 1 deletion pages/registries.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def url(self):

class RegistriesLandingPage(BaseRegistriesPage):
identity = Locator(
By.CSS_SELECTOR, '._RegistriesHeader_3zbd8x', settings.LONG_TIMEOUT
By.CSS_SELECTOR, '[data-test-registries-list-paragraph]', settings.LONG_TIMEOUT
)
search_box = Locator(By.ID, 'search')

Expand Down
50 changes: 50 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,56 @@
],
)

# As of January 24, 2022, the Engineering Archive ('engrxiv') preprint provider
# has switched away from using OSF as their preprint service. Therefore the
# web page that OSF automatically redirects to is no longer based on the OSF
# Preprints landing/discover page design. However, they remain in our active
# preprint provider list in the OSF api due to legal issues that are still being
# worked out. The best guess is that the transition will be completed (and
# engrxiv removed from the api list) by the end of the first quarter of 2022
# (i.e. end of March). So to prevent this test from failing in Production
# every night for 'engrxiv' we are going to skip the following steps for this
# provider.
# UPDATE 10/26/2022 - the status of 'engrxiv' has not changed and now another
# provider - 'ecoevorxiv' is also leaving OSF.
# UPDATE 10/13/2023 - After the Search Improvements project release, OSF and other providers
# that have moved away from OSF now redirect to https://osf.io/search?q=&resourceType=Preprint&q=
providers_leaving_OSF = ['ecoevorxiv', 'engrxiv', 'livedata', 'osf']
non_branded_registries = ['osf', 'assessment']

# Documented failures for branded preprint discover pages
# ENG-5422 CoP Preprints
# ENG-5423 EdArXiv
# ENG-5424 NewAddictionsX
# ENG-5425 SocArXiv
# ENG-5426 Thesis Commons
known_preprints_discover_failures = [
"edarxiv", "coppreprints", "newaddictionsx", "socarxiv", "thesiscommons"
]

# Documented failures for branded preprint landing pages
# ENG-5398 AfricaArXiv
# ENG-5399 ArabiXiv
# ENG-5400 BodoArXiv
# ENG-5401 CoP Preprints
# ENG-5402 ECSarXiv
# ENG-5403 & ENG-5404 EdArXiv
# ENG-5406 Focus Archive
# ENG-5407 FrenXiv
# ENG-5408 IndiaRxiv
# ENG-5409 MarXiv
# ENG-5410 MindRxiv
# ENG-5411 & ENG-5413 NewAddictionsX
# ENG-5414 & ENG-5415 SocArXiv
# ENG-5416 SportRxiv
# ENG-5417 Thesis Commons
known_preprints_landing_failures = [
"africarxiv", "arabixiv", "bodoarxiv", "coppreprints",
"ecsarxiv", "edarxiv", "focusarchive", "frenxiv", "indiarxiv",
"marxiv", "mindrxiv", "newaddictionsx", "socarxiv", "sportrxiv", "thesiscommons"
]


OSF_HOME = domains[DOMAIN]['home']
API_DOMAIN = domains[DOMAIN]['api']
FILE_DOMAIN = domains[DOMAIN]['files']
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,6 @@ def exclude_best_practice(pytestconfig):
Raises ValueError if input value is anything else.
"""
if pytestconfig.getoption('exclude_best_practice') is None:
return False
return True
else:
return strtobool(pytestconfig.getoption('exclude_best_practice'))
Loading

0 comments on commit 86487dd

Please sign in to comment.