Skip to content

Commit e1813a5

Browse files
authored
Merge pull request #40 from CenterForOpenScience/newTest/metadata
[ENG-4305] Add New A11y Tests for Metadata Pages
2 parents 7f808ff + 1bb2419 commit e1813a5

File tree

4 files changed

+80
-4
lines changed

4 files changed

+80
-4
lines changed

pages/project.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ class MyProjectsPage(OSFBasePage):
6868
project_created_modal = ComponentLocator(ProjectCreatedModal)
6969

7070

71+
class MetadataPage(GuidBasePage):
72+
base_url = settings.OSF_HOME + '/{guid}/metadata/'
73+
74+
identity = Locator(By.CSS_SELECTOR, 'div[data-analytics-scope="Node"]')
75+
loading_indicator = Locator(By.CSS_SELECTOR, '.ball-pulse')
76+
77+
7178
class AnalyticsPage(GuidBasePage):
7279
base_url = settings.OSF_HOME + '/{guid}/analytics/'
7380

pages/registries.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ class BaseSubmittedRegistrationPage(GuidBasePage):
6868
base_url = settings.OSF_HOME
6969
url_addition = ''
7070

71+
def __init__(self, driver, verify=False, guid=''):
72+
# Set the cookie that prevents the New Feature popover from appearing on
73+
# submitted registration pages since this popover can get in the way of other
74+
# actions.
75+
driver.add_cookie({'name': 'metadataFeaturePopover', 'value': '1'})
76+
77+
super().__init__(driver, verify, guid)
78+
7179
@property
7280
def url(self):
7381
return self.base_url + '/' + self.guid + '/' + self.url_addition
@@ -97,6 +105,12 @@ class RegistrationResourcesPage(BaseSubmittedRegistrationPage):
97105
identity = Locator(By.CSS_SELECTOR, '[data-test-add-resource-section]')
98106

99107

108+
class RegistrationMetadataPage(BaseSubmittedRegistrationPage):
109+
url_addition = 'metadata'
110+
identity = Locator(By.CSS_SELECTOR, '[data-test-edit-resource-metadata-button]')
111+
loading_indicator = Locator(By.CSS_SELECTOR, '.ball-scale')
112+
113+
100114
class RegistrationAddNewPage(BaseRegistriesPage):
101115
url_addition = 'new'
102116
identity = Locator(

tests/test_a11y_project.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
FilesPage,
1414
FileViewPage,
1515
ForksPage,
16+
MetadataPage,
1617
ProjectPage,
1718
RegistrationsPage,
1819
RequestAccessPage,
@@ -51,6 +52,34 @@ def test_accessibility(
5152
)
5253

5354

55+
@markers.ember_page
56+
class TestMetadataPage:
57+
def test_accessibility(
58+
self,
59+
driver,
60+
session,
61+
default_project,
62+
write_files,
63+
exclude_best_practice,
64+
must_be_logged_in,
65+
):
66+
"""For the Project Metadata page test we are creating a new dummy test project
67+
and then deleting it after we have finished unless we are running in Production,
68+
then we are using a Preferred Node from the environment settings file.
69+
"""
70+
metadata_page = MetadataPage(driver, guid=default_project.id)
71+
metadata_page.goto()
72+
assert MetadataPage(driver, verify=True)
73+
metadata_page.loading_indicator.here_then_gone()
74+
a11y.run_axe(
75+
driver,
76+
session,
77+
'prjMeta',
78+
write_files=write_files,
79+
exclude_best_practice=exclude_best_practice,
80+
)
81+
82+
5483
@markers.ember_page
5584
class TestFilesPage:
5685
def test_accessibility(

tests/test_a11y_registries.py

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
RegistrationDetailPage,
1919
RegistrationFileDetailPage,
2020
RegistrationFileListPage,
21+
RegistrationMetadataPage,
2122
RegistrationResourcesPage,
2223
RegistriesDiscoverPage,
2324
RegistriesLandingPage,
@@ -169,10 +170,7 @@ def my_registrations_page(self, driver, log_in_as_user_with_draft_registrations)
169170
"""
170171
my_registrations_page = MyRegistrationsPage(driver)
171172
my_registrations_page.goto()
172-
# Set the cookie that prevents the New Feature popover from appearing on
173-
# submitted registration pages since this popover can get in the way of other
174-
# actions.
175-
driver.add_cookie({'name': 'outputFeaturePopover', 'value': '1'})
173+
176174
# Wait for registration cards to load on page
177175
WebDriverWait(driver, 5).until(
178176
EC.presence_of_element_located((By.CSS_SELECTOR, '[data-test-node-card]'))
@@ -306,6 +304,34 @@ def test_accessibility_resources_page(
306304
exclude_best_practice=exclude_best_practice,
307305
)
308306

307+
@markers.ember_page
308+
def test_accessibility_metadata_page(
309+
self, driver, session, write_files, exclude_best_practice, my_registrations_page
310+
):
311+
"""This test is for checking the accessibility of the Registration Metadata
312+
Page of a submitted registration. First search through the registration cards
313+
on the Submitted tab of the My Registration Page for a specific registration
314+
(searching by registration title). When you find the desired registration get
315+
the registration node id from its link and then use the node id to navigate to
316+
the Meatadata page for this registration.
317+
"""
318+
registration_node = my_registrations_page.get_node_id_by_title(
319+
'Registration With Files for A11y Testing'
320+
)
321+
registration_metadata_page = RegistrationMetadataPage(
322+
driver, guid=registration_node
323+
)
324+
registration_metadata_page.goto()
325+
assert RegistrationMetadataPage(driver, verify=True)
326+
registration_metadata_page.loading_indicator.here_then_gone()
327+
a11y.run_axe(
328+
driver,
329+
session,
330+
'regmeta',
331+
write_files=write_files,
332+
exclude_best_practice=exclude_best_practice,
333+
)
334+
309335

310336
# User with registrations is not setup in production
311337
@markers.dont_run_on_prod

0 commit comments

Comments
 (0)