Skip to content

Commit f12c6ad

Browse files
committed
Update test_withdraw_preprint
1 parent 0fdd942 commit f12c6ad

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

pages/preprints.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,10 @@ class PreprintWithdrawPage(GuidBasePage, BasePreprintPage):
225225
By.CSS_SELECTOR, '[data-test-comment-input] textarea'
226226
)
227227
request_withdrawal_button = Locator(
228-
By.XPATH, '//div[@class="_Footer_gyio2l"]/button[text()="Withdraw"]'
228+
By.CSS_SELECTOR, '[data-test-confirm-withdraw-button]'
229+
)
230+
withdrawn_banner = Locator(
231+
By.XPATH, "//span[normalize-space(text())='This preprint has been withdrawn.']"
229232
)
230233

231234

@@ -280,6 +283,7 @@ class PreprintDetailPage(GuidBasePage, BasePreprintPage):
280283
downloads_count = Locator(By.CSS_SELECTOR, '[data-test-download-count]')
281284
download_button = Locator(By.CSS_SELECTOR, '[data-test-download-button]')
282285
edit_preprint_button = Locator(By.CSS_SELECTOR, '[data-test-edit-preprint-button]')
286+
withdraw_preprint_button = Locator(By.CSS_SELECTOR, '[data-test-withdrawal-button]')
283287
default_citation = Locator(By.CSS_SELECTOR, '[data-test-default-citation="apa"]')
284288

285289
# Locators for the reviews app preprint detail page
@@ -303,13 +307,15 @@ class PreprintDetailPage(GuidBasePage, BasePreprintPage):
303307
class PendingPreprintDetailPage(PreprintDetailPage):
304308
# This class is for preprints that are pending moderation
305309
identity = Locator(
306-
By.ID,
307-
'preprintTitle',
310+
By.CSS_SELECTOR,
311+
'[data-test-preprint-title]',
308312
settings.LONG_TIMEOUT,
309313
)
310314
# This locator needs a data-test-selector from software devs
311-
# title = Locator(By.CSS_SELECTOR, '[data-test-preprint-title]', settings.LONG_TIMEOUT)
312-
title = Locator(By.ID, 'preprintTitle', settings.LONG_TIMEOUT)
315+
title = Locator(
316+
By.CSS_SELECTOR, '[data-test-preprint-title]', settings.LONG_TIMEOUT
317+
)
318+
# title = Locator(By.ID, 'preprintTitle', settings.LONG_TIMEOUT)
313319

314320

315321
class ReviewsDashboardPage(OSFBasePage):

tests/test_preprints.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def test_edit_preprint(self, session, driver, preprint_detail_page):
328328
assert tag_found
329329

330330
@markers.dont_run_on_prod
331-
@pytest.mark.xfail(reason='https://openscience.atlassian.net/browse/ENG-6065')
331+
# @pytest.mark.xfail(reason='https://openscience.atlassian.net/browse/ENG-6065')
332332
def test_withdraw_preprint(self, session, driver, preprint_detail_page):
333333
"""Test the Withdraw Preprint functionality. Using the preprint_detail_page
334334
fixture we start on the Preprint Detail page for an api created preprint. Then
@@ -341,7 +341,6 @@ def test_withdraw_preprint(self, session, driver, preprint_detail_page):
341341
that the withdrawal request record is created.
342342
"""
343343
assert PreprintDetailPage(driver, verify=True)
344-
preprint_detail_page.edit_preprint_button.click()
345344
edit_page = PreprintEditPage(driver)
346345
WebDriverWait(driver, 5).until(
347346
EC.element_to_be_clickable(
@@ -363,8 +362,13 @@ def test_withdraw_preprint(self, session, driver, preprint_detail_page):
363362
)
364363
assert withdraw_page.request_withdrawal_button.is_enabled()
365364
withdraw_page.request_withdrawal_button.click()
365+
WebDriverWait(driver, 5).until(EC.visibility_of(withdraw_page.withdrawn_banner))
366366
# Should be redirected back to Preprint Detail page
367367
assert PendingPreprintDetailPage(driver, verify=True)
368+
# Verify that "This preprint has been withdrawn." banner is displayed on Preprint Detail page.
369+
assert (
370+
withdraw_page.withdrawn_banner.text == 'This preprint has been withdrawn.'
371+
)
368372
# Verify via the api that the Withdrawal Request record was created
369373
requests = osf_api.get_preprint_requests_records(
370374
node_id=preprint_detail_page.guid
@@ -374,7 +378,7 @@ def test_withdraw_preprint(self, session, driver, preprint_detail_page):
374378
record_found = False
375379
for request in requests:
376380
if request['attributes']['request_type'] == 'withdrawal':
377-
assert request['attributes']['machine_state'] == 'pending'
381+
assert request['attributes']['machine_state'] == 'accepted'
378382
record_found = True
379383
break
380384
if not record_found:

0 commit comments

Comments
 (0)