Skip to content

Commit d7c64c1

Browse files
committed
Merge branch 'develop' of github.com:CenterForOpenScience/osf-selenium-tests into develop
2 parents 52abc93 + a12db25 commit d7c64c1

14 files changed

+396
-147
lines changed

.github/workflows/nightly_core_functionality_tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ env:
4343
jobs:
4444

4545
build:
46-
runs-on: ubuntu-20.04
46+
runs-on: ubuntu-latest
4747
env:
48-
GHA_DISTRO: ubuntu-20.04
48+
GHA_DISTRO: ubuntu-latest
4949
if: "!contains(github.event.head_commit.message, 'skip ci')"
5050
strategy:
5151
matrix:
@@ -73,14 +73,14 @@ jobs:
7373
core_functionality_test:
7474
name: Core Functionality tests (${{ matrix.browser }})
7575
needs: build
76-
runs-on: ubuntu-20.04
76+
runs-on: ubuntu-latest
7777
env:
78-
GHA_DISTRO: ubuntu-20.04
78+
GHA_DISTRO: ubuntu-latest
7979
strategy:
8080
fail-fast: false
8181
max-parallel: 1 # run in series
8282
matrix:
83-
browser: [chrome, firefox, edge]
83+
browser: [firefox, edge, chrome]
8484
steps:
8585
- uses: actions/checkout@v4
8686
- name: Set up Python 3.9

.github/workflows/production_smoke_tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ env:
3939
jobs:
4040

4141
build:
42-
runs-on: ubuntu-20.04
42+
runs-on: ubuntu-latest
4343
env:
44-
GHA_DISTRO: ubuntu-20.04
44+
GHA_DISTRO: ubuntu-latest
4545
if: "!contains(github.event.head_commit.message, 'skip ci')"
4646
strategy:
4747
matrix:
@@ -69,9 +69,9 @@ jobs:
6969
smoke_test:
7070
name: Prod smoke tests (${{ matrix.browser }})
7171
needs: build
72-
runs-on: ubuntu-20.04
72+
runs-on: ubuntu-latest
7373
env:
74-
GHA_DISTRO: ubuntu-20.04
74+
GHA_DISTRO: ubuntu-latest
7575
strategy:
7676
fail-fast: false
7777
max-parallel: 1 # run in series

.github/workflows/two_minute_drill.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ env:
5252
jobs:
5353

5454
build:
55-
runs-on: ubuntu-20.04
55+
runs-on: ubuntu-latest
5656
env:
57-
GHA_DISTRO: ubuntu-20.04
57+
GHA_DISTRO: ubuntu-latest
5858
if: "!contains(github.event.head_commit.message, 'skip ci')"
5959
strategy:
6060
matrix:
@@ -82,9 +82,9 @@ jobs:
8282
two_minute_drill_tests:
8383
name: Two Minute Drill Tests (${{ github.event.inputs.browser }})
8484
needs: [build]
85-
runs-on: ubuntu-20.04
85+
runs-on: ubuntu-latest
8686
env:
87-
GHA_DISTRO: ubuntu-20.04
87+
GHA_DISTRO: ubuntu-latest
8888
strategy:
8989
fail-fast: false
9090
max-parallel: 1 # run in series

.github/workflows/weekly_regression_tests.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ env:
8484
jobs:
8585

8686
build:
87-
runs-on: ubuntu-20.04
87+
runs-on: ubuntu-latest
8888
env:
89-
GHA_DISTRO: ubuntu-20.04
89+
GHA_DISTRO: ubuntu-latest
9090
if: "!contains(github.event.head_commit.message, 'skip ci')"
9191
strategy:
9292
matrix:
@@ -116,7 +116,7 @@ jobs:
116116
# will be used since the scheduler does not have inputs.
117117
set_variables:
118118
name: Set the Domain, Service, and Browser for Regression Tests
119-
runs-on: ubuntu-20.04
119+
runs-on: ubuntu-latest
120120
outputs:
121121
domain: ${{ github.event.inputs.domain || env.DEFAULT_DOMAIN }}
122122
service: ${{ github.event.inputs.service || env.DEFAULT_SERVICE }}
@@ -130,7 +130,7 @@ jobs:
130130
set_matrix:
131131
name: Set Matrix of Browser Values
132132
needs: [set_variables]
133-
runs-on: ubuntu-20.04
133+
runs-on: ubuntu-latest
134134
outputs:
135135
matrix: ${{ steps.set_browser_2.outputs.matrix }}
136136
steps:
@@ -147,9 +147,9 @@ jobs:
147147
regression_test:
148148
name: Regression tests (${{ matrix.browser }})
149149
needs: [build, set_variables, set_matrix]
150-
runs-on: ubuntu-20.04
150+
runs-on: ubuntu-latest
151151
env:
152-
GHA_DISTRO: ubuntu-20.04
152+
GHA_DISTRO: ubuntu-latest
153153
strategy:
154154
fail-fast: false
155155
max-parallel: 1 # run in series

api/osf_api.py

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def create_child_node(
4646
node_id=None,
4747
title='osf selenium child node',
4848
tags=None,
49-
**kwargs
49+
**kwargs,
5050
):
5151
"""Create a child node (a.k.a. component) of a given project node."""
5252
if tags is None:
@@ -863,6 +863,43 @@ def accept_moderated_preprint(session=None, preprint_node=None):
863863
)
864864

865865

866+
def get_preprint_id(session=None, preprint_node=None):
867+
"""Get priprint's id"""
868+
if not session:
869+
session = get_default_session()
870+
request_url = f'/v2/preprints/{preprint_node}/requests/'
871+
872+
response = session.get(url=request_url)
873+
preprint_id = ''
874+
for item in response.get('data', []):
875+
preprint_id = item.get('id')
876+
return preprint_id
877+
878+
879+
def accept_withdraw_preprint(session=None, preprint_id=None):
880+
"""Accept a withdrawal request for a given preprint request ID."""
881+
if not session:
882+
session = get_default_session()
883+
review_url = '/v2/actions/requests/preprints/'
884+
review_payload = {
885+
'data': {
886+
'type': 'preprint-request-actions',
887+
'attributes': {
888+
'trigger': 'accept',
889+
'comment': 'Preprint Withdraw Approval via OSF api',
890+
},
891+
'relationships': {
892+
'target': {'data': {'id': preprint_id, 'type': 'preprint-requests'}}
893+
},
894+
}
895+
}
896+
session.post(
897+
url=review_url,
898+
item_type='review-actions',
899+
raw_body=json.dumps(review_payload),
900+
)
901+
902+
866903
def create_preprint_withdrawal_request(session=None, preprint_node=None):
867904
"""Create a withdrawal request for a given preprint node id."""
868905
if not session:
@@ -1279,3 +1316,45 @@ def create_registration_resource(registration_guid, resource_type):
12791316
item_id=resource_id,
12801317
item_type='resources',
12811318
)['data']
1319+
1320+
1321+
def update_registration_title(registration_guid, title):
1322+
"""This method updates the title of the given
1323+
registration."""
1324+
session = client.Session(
1325+
api_base_url=settings.API_DOMAIN,
1326+
auth=(settings.REGISTRATIONS_USER, settings.REGISTRATIONS_USER_PASSWORD),
1327+
)
1328+
url = '/v2/registrations/{}/'.format(registration_guid)
1329+
payload = {
1330+
'data': {
1331+
'id': registration_guid,
1332+
'type': 'registrations',
1333+
'attributes': {'title': title},
1334+
}
1335+
}
1336+
session.patch(
1337+
url=url,
1338+
raw_body=json.dumps(payload),
1339+
item_id=registration_guid,
1340+
item_type='registrations',
1341+
)['data']
1342+
1343+
1344+
def delete_registration_contributor(registration_guid, user_name):
1345+
"""This method deletes the given user from the given registration"""
1346+
session = client.Session(
1347+
api_base_url=settings.API_DOMAIN,
1348+
auth=(settings.REGISTRATIONS_USER, settings.REGISTRATIONS_USER_PASSWORD),
1349+
)
1350+
url = '/v2/registrations/{}/contributors/'.format(registration_guid)
1351+
data = session.get(url)['data']
1352+
1353+
for i in range(0, len(data)):
1354+
if user_name in data[i]['embeds']['users']['data']['attributes']['full_name']:
1355+
user_id = data[i]['embeds']['users']['data']['id']
1356+
delete_url = '/v2/registrations/{}/contributors/{}/'.format(
1357+
registration_guid, user_id
1358+
)
1359+
session.delete(delete_url, item_type='users')
1360+
break

pages/preprints.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,10 @@ class PreprintWithdrawPage(GuidBasePage, BasePreprintPage):
258258
By.CSS_SELECTOR, '[data-test-comment-input] textarea'
259259
)
260260
request_withdrawal_button = Locator(
261-
By.XPATH, '//div[@class="_Footer_gyio2l"]/button[text()="Withdraw"]'
261+
By.CSS_SELECTOR, '[data-test-confirm-withdraw-button]'
262+
)
263+
withdrawn_banner = Locator(
264+
By.XPATH, "//span[normalize-space(text())='This preprint has been withdrawn.']"
262265
)
263266

264267

@@ -313,6 +316,7 @@ class PreprintDetailPage(GuidBasePage, BasePreprintPage):
313316
downloads_count = Locator(By.CSS_SELECTOR, '[data-test-download-count]')
314317
download_button = Locator(By.CSS_SELECTOR, '[data-test-download-button]')
315318
edit_preprint_button = Locator(By.CSS_SELECTOR, '[data-test-edit-preprint-button]')
319+
withdraw_preprint_button = Locator(By.CSS_SELECTOR, '[data-test-withdrawal-button]')
316320
default_citation = Locator(By.CSS_SELECTOR, '[data-test-default-citation="apa"]')
317321

318322
# Locators for the reviews app preprint detail page
@@ -341,8 +345,10 @@ class PendingPreprintDetailPage(PreprintDetailPage):
341345
settings.LONG_TIMEOUT,
342346
)
343347
# This locator needs a data-test-selector from software devs
344-
# title = Locator(By.CSS_SELECTOR, '[data-test-preprint-title]', settings.LONG_TIMEOUT)
345-
title = Locator(By.ID, 'preprintTitle', settings.LONG_TIMEOUT)
348+
title = Locator(
349+
By.CSS_SELECTOR, '[data-test-preprint-title]', settings.LONG_TIMEOUT
350+
)
351+
# title = Locator(By.ID, 'preprintTitle', settings.LONG_TIMEOUT)
346352

347353

348354
class ReviewsDashboardPage(OSFBasePage):

pages/project.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,11 +563,13 @@ class ProjectMetadataPage(GuidBasePage):
563563
add_contributor_button = Locator(
564564
By.CSS_SELECTOR, 'a.btn.btn-success.btn-sm.m-l-md[href="#addContributors"]'
565565
)
566-
contributor_search_button = Locator(By.XPATH, '//input[@class="btn btn-default"]')
566+
contributor_search_button = Locator(
567+
By.CSS_SELECTOR, '[data-test-user-search-button]'
568+
)
567569
add_displayed_contributor_button = Locator(
568570
By.CSS_SELECTOR, '[a.btn.btn-success.contrib-button.btn-mini]'
569571
)
570-
search_input = Locator(By.XPATH, '//input[@class="form-control"]')
572+
search_input = Locator(By.CSS_SELECTOR, '[data-test-user-search-input]')
571573
resource_type = Locator(
572574
By.CSS_SELECTOR, '[data-test-display-resource-type-general]'
573575
)
@@ -595,6 +597,37 @@ def select_from_dropdown_listbox(self, selection):
595597
resource_information_save_button = Locator(
596598
By.CSS_SELECTOR, '[data-test-save-resource-metadata-button]'
597599
)
600+
# Get the rows of search results matching the locator
601+
rows = GroupLocator(By.CSS_SELECTOR, '[data-test-user-card-main]')
602+
603+
# Select the correct user from the table of search results
604+
def select_from_table_of_rows(self, selection):
605+
for row in self.rows:
606+
cell = row.find_element(
607+
By.CSS_SELECTOR, '[data-analytics-name="View user"]'
608+
)
609+
if selection in cell.text.strip():
610+
row.find_element(
611+
By.CSS_SELECTOR, '[data-test-add-contributor-button]'
612+
).click()
613+
break
614+
615+
contributors_list = GroupLocator(
616+
By.CSS_SELECTOR, '[data-analytics-name="Contributor name"]'
617+
)
618+
619+
# Select new_user from contributors list on metadata page
620+
def select_from_list(self, selection):
621+
for contributor in self.contributors_list:
622+
if selection in contributor.text.strip():
623+
return contributor
624+
625+
search_cancel_button = Locator(
626+
By.CSS_SELECTOR, '[data-test-user-search-cancel-button]'
627+
)
628+
add_contributor_finish_button = Locator(
629+
By.CSS_SELECTOR, '[data-test-finish-node-contributor-editing-button]'
630+
)
598631

599632
funder_name = Locator(By.XPATH, '//span[@class="ember-power-select-status-icon"]')
600633
funder_name_search_input = Locator(

pages/registries.py

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,22 +143,27 @@ def select_from_dropdown_listbox(self, selection):
143143
class RegistrationMetadataPage(BaseSubmittedRegistrationPage):
144144
url_addition = 'metadata'
145145
identity = Locator(By.CSS_SELECTOR, '[data-test-display-resource-type-general]')
146-
146+
metadata_title = Locator(By.CSS_SELECTOR, '[data-test-display-node-title]')
147147
metadata_description = Locator(
148148
By.CSS_SELECTOR, '[data-test-display-node-description]'
149149
)
150150
edit_metadata_description_button = Locator(
151151
By.CSS_SELECTOR, '[data-test-edit-node-description-button]'
152152
)
153+
save_metadata_title_button = Locator(
154+
By.CSS_SELECTOR, '[data-test-save-node-title-button]'
155+
)
153156
save_metadata_description_button = Locator(
154157
By.CSS_SELECTOR, '[data-test-save-node-description-button]'
155158
)
156159
contributors_list = Locator(By.CSS_SELECTOR, '[data-test-contributors-list]')
157-
contributor_search_button = Locator(By.XPATH, '//input[@class="btn btn-default"]')
160+
contributor_search_button = Locator(
161+
By.CSS_SELECTOR, '[data-test-user-search-button]'
162+
)
158163
add_displayed_contributor_button = Locator(
159164
By.CSS_SELECTOR, '[a.btn.btn-success.contrib-button.btn-mini]'
160165
)
161-
search_input = Locator(By.XPATH, '//input[@class="form-control"]')
166+
search_input = Locator(By.CSS_SELECTOR, '[data-test-user-search-input]')
162167
resource_type = Locator(
163168
By.CSS_SELECTOR, '[data-test-display-resource-type-general]'
164169
)
@@ -183,6 +188,35 @@ def select_from_dropdown_listbox(self, selection):
183188
option.click()
184189
break
185190

191+
rows = GroupLocator(By.CSS_SELECTOR, '[data-test-user-card-main]')
192+
193+
def select_from_table_of_rows(self, selection):
194+
for row in self.rows:
195+
cell = row.find_element(
196+
By.CSS_SELECTOR, '[data-analytics-name="View user"]'
197+
)
198+
if selection in cell.text.strip():
199+
row.find_element(
200+
By.CSS_SELECTOR, '[data-test-add-contributor-button]'
201+
).click()
202+
break
203+
204+
contributors_list = GroupLocator(
205+
By.CSS_SELECTOR, '[data-analytics-name="Contributor name"]'
206+
)
207+
208+
def select_from_list(self, selection):
209+
for contributor in self.contributors_list:
210+
if selection in contributor.text.strip():
211+
return contributor
212+
213+
search_cancel_button = Locator(
214+
By.CSS_SELECTOR, '[data-test-user-search-cancel-button]'
215+
)
216+
add_contributor_finish_button = Locator(
217+
By.CSS_SELECTOR, '[data-test-finish-node-contributor-editing-button]'
218+
)
219+
186220
resource_information_save_button = Locator(
187221
By.CSS_SELECTOR, '[data-test-save-resource-metadata-button]'
188222
)

pages/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def get_unconfirmed_email_item(self, email_address):
147147
class ConfigureAddonsPage(BaseUserSettingsPage):
148148
url = settings.OSF_HOME + '/settings/addons/'
149149

150-
identity = Locator(By.CSS_SELECTOR, '#configureAddons')
150+
identity = Locator(By.CSS_SELECTOR, 'div[data-analytics-scope="User addons"]')
151151

152152

153153
class NotificationsPage(BaseUserSettingsPage):

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ autopep8==1.3.3
77
requests>=2.20.0
88
urllib3<2
99
pythosf==0.0.9
10-
environs==3.0.0
10+
environs==14.1.1
1111
faker==0.9.0
1212
pre-commit==2.14.0
1313
ipdb==0.13.13

0 commit comments

Comments
 (0)