* add tests for the dev agreement page

* run black
This commit is contained in:
Alexandra Gal-Moga 2023-05-15 17:09:16 +03:00 коммит произвёл GitHub
Родитель d61015b83c
Коммит dc8e339128
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 156 добавлений и 14 удалений

Просмотреть файл

@ -128,6 +128,8 @@
"devhub_resources_write_some_code_text": "Help make add-ons better by contributing your coding skills.",
"devhub_resources_participate_text": "You don't need coding skills to help keep Firefox the most customizable browser available!",
"devhub_submit_addon_agreement_header": "Add-on Distribution Agreement",
"distribution_page_explainer": "Before starting, please read and accept our Firefox Add-on Distribution Agreement as well as our Review Policies and Rules. The Firefox Add-on Distribution Agreement also links to our Privacy Notice which explains how we handle your information.",
"distribution_user_consent": "I have read and accept this Agreement and the Rules and Policies.",
"devhub_submit_addon_distribution_header": "How to Distribute this Version",
"unlisted_submission_confirmation": "Youre done! ✨ You will be notified by email when the signed file is ready to be downloaded from the Developer Hub. If you do not see an email after 24 hours, please check your spam folder.",

Просмотреть файл

@ -18,6 +18,33 @@ class SubmitAddon(Page):
By.CSS_SELECTOR,
'.addon-submission-process h3',
)
_distribution_page_explainer_locator = (
By.CSS_SELECTOR,
'.addon-submission-process p:nth-of-type(1)',
)
_distribution_agreement_checkbox_locator = (By.ID, 'id_distribution_agreement')
_distribution_agreement_link_locator = (
By.CSS_SELECTOR,
'.addon-submission-process li:nth-of-type(1) a',
)
_review_policies_checkbox_locator = (By.ID, 'id_review_policy')
_review_policies_link_locator = (
By.CSS_SELECTOR,
'.addon-submission-process li:nth-of-type(2) a',
)
_user_consent_text_locator = (
By.CSS_SELECTOR,
'.addon-submission-process p:nth-of-type(2)',
)
_recaptcha_locator = (By.ID, 'id_recaptcha')
_recaptcha_checkbox_locator = (By.ID, 'recaptcha-anchor')
_recaptcha_checkbox_is_selected_locator = (
By.CSS_SELECTOR,
'span[aria-checked="true"]',
)
_accept_agreement_button = (By.ID, 'accept-agreement')
_cancel_agreement_button = (By.CSS_SELECTOR, '.submit-buttons a')
_dev_accounts_info_link_locator = (By.CSS_SELECTOR, '.addon-submission-process p a')
_listed_option_locator = (By.CSS_SELECTOR, 'input[value="listed"]')
_unlisted_option_locator = (By.CSS_SELECTOR, 'input[value="unlisted"]')
_change_distribution_link_locator = (By.CSS_SELECTOR, '.addon-submit-distribute a')
@ -43,6 +70,75 @@ class SubmitAddon(Page):
def distribution_header(self):
return self.find_element(*self._addon_distribution_header_locator)
@property
def distribution_page_explainer(self):
return self.find_element(*self._distribution_page_explainer_locator).text
@property
def distribution_agreement_checkbox(self):
return self.find_element(*self._distribution_agreement_checkbox_locator)
@property
def distribution_agreement_article_link(self):
return self.find_element(*self._distribution_agreement_link_locator)
@property
def review_policies_checkbox(self):
return self.find_element(*self._review_policies_checkbox_locator)
@property
def review_policies_article_link(self):
return self.find_element(*self._review_policies_link_locator)
def click_distribution_and_policy_article_link(self, link, text):
"""Clicks on the Distribution agreement and the Policies links
which open an Extension Workshop article page in a new tab"""
link.click()
self.wait.until(
EC.number_of_windows_to_be(2),
message=f'Number of windows was {len(self.driver.window_handles)}, expected 2',
)
new_tab = self.driver.window_handles[1]
self.driver.switch_to.window(new_tab)
self.wait.until(
EC.text_to_be_present_in_element((By.CSS_SELECTOR, '.page-hero h1'), text)
)
self.driver.close()
# return to the main tab
self.driver.switch_to.window(self.driver.window_handles[0])
@property
def user_consent_text(self):
return self.find_element(*self._user_consent_text_locator).text
@property
def recaptcha(self):
return self.find_element(*self._recaptcha_locator)
def click_recaptcha_checkbox(self):
"""reCAPTCHA is stored in an iframe; switch to the iframe and click on the checkbox"""
el = self.find_element(By.CSS_SELECTOR, 'iframe[title="reCAPTCHA"]')
self.driver.switch_to.frame(el)
self.find_element(*self._recaptcha_checkbox_locator).click()
@property
def accept_agreement(self):
return self.find_element(*self._accept_agreement_button)
@property
def cancel_agreement(self):
return self.find_element(*self._cancel_agreement_button)
def click_dev_accounts_info_link(self):
"""click on the Developer account info link and check that the
correct Extension Workshop article is opened"""
self.find_element(*self._dev_accounts_info_link_locator).click()
self.wait.until(
EC.text_to_be_present_in_element(
(By.CSS_SELECTOR, '.page-hero h1'), 'Developer accounts'
)
)
def select_listed_option(self):
self.find_element(*self._listed_option_locator).click()

Просмотреть файл

@ -132,6 +132,8 @@
"devhub_resources_participate_text": "You don't need coding skills to help keep Firefox the most customizable browser available!",
"devhub_submit_addon_agreement_header": "Add-on Distribution Agreement",
"devhub_submit_addon_distribution_header": "How to Distribute this Version",
"distribution_page_explainer": "Before starting, please read and accept our Firefox Add-on Distribution Agreement as well as our Review Policies and Rules. The Firefox Add-on Distribution Agreement also links to our Privacy Notice which explains how we handle your information.",
"distribution_user_consent": "I have read and accept this Agreement and the Rules and Policies.",
"unlisted_submission_confirmation": "Youre done! ✨ You will be notified by email when the signed file is ready to be downloaded from the Developer Hub. If you do not see an email after 24 hours, please check your spam folder.",
"listed_submission_confirmation": "Youre done! ✨ You will receive a confirmation email when this version is published on addons.allizom.org. Note that it may take up to 24 hours before publication occurs, or longer if your add-on is selected for manual review. If you do not see an email after 24 hours, please check your spam folder.",

Просмотреть файл

@ -226,23 +226,65 @@ def test_devhub_click_submit_new_theme_button(selenium, base_url, wait):
@pytest.mark.nondestructive
def test_devhub_click_first_addon_button(selenium, base_url, variables):
def test_devhub_developer_agreement_page_contents(selenium, base_url, variables, wait):
page = DevHubHome(selenium, base_url).open().wait_for_page_to_load()
# an account with no add-ons submitted is used
# use an account that hasn't accepted the agreement before
page.devhub_login('regular_user')
page.wait_for_page_to_load()
distribution_page = page.click_submit_addon_button()
# if this user never accepted the distribution agreement, it should be displayed in the page, otherwise not
try:
assert (
variables['devhub_submit_addon_agreement_header']
in distribution_page.distribution_header.text
)
except AssertionError:
assert (
variables['devhub_submit_addon_distribution_header']
in distribution_page.distribution_header.text
)
dist_agreement = page.click_submit_addon_button()
assert (
variables['devhub_submit_addon_agreement_header']
in dist_agreement.distribution_header.text
)
assert (
variables['distribution_page_explainer']
in dist_agreement.distribution_page_explainer
)
assert (
'Firefox Add-on Distribution Agreement'
in dist_agreement.distribution_agreement_article_link.text
)
assert (
'Review Policies and Rules' in dist_agreement.review_policies_article_link.text
)
assert variables['distribution_user_consent'] in dist_agreement.user_consent_text
wait.until(lambda _: dist_agreement.recaptcha.is_displayed())
# clicking on Cancel agreement should redirect to Devhub Homepage
dist_agreement.cancel_agreement.click()
page = DevHubHome(selenium, base_url).wait_for_page_to_load()
assert page.page_logo.is_displayed()
@pytest.mark.nondestructive
def test_devhub_developer_agreement_page_links(selenium, base_url):
page = DevHubHome(selenium, base_url).open().wait_for_page_to_load()
# use an account that hasn't accepted the agreement before
page.devhub_login('regular_user')
dist_agreement = page.click_submit_addon_button()
# check that the distribution agreement link opens the correct Extension workshop page
dist_agreement.click_distribution_and_policy_article_link(
dist_agreement.distribution_agreement_article_link,
'Firefox Add-on Distribution Agreement',
)
# check that the review policies link opens the correct Extension workshop page
dist_agreement.click_distribution_and_policy_article_link(
dist_agreement.review_policies_article_link, 'Add-on Policies'
)
# verify that the Dev Account info link opens an Extension Workshop article page
dist_agreement.click_dev_accounts_info_link()
@pytest.mark.nondestructive
def test_devhub_developer_agreement_checkboxes(selenium, base_url):
page = DevHubHome(selenium, base_url).open().wait_for_page_to_load()
# use an account that hasn't accepted the agreement before
page.devhub_login('regular_user')
dist_agreement = page.click_submit_addon_button()
dist_agreement.distribution_agreement_checkbox.click()
assert dist_agreement.distribution_agreement_checkbox.is_selected()
dist_agreement.review_policies_checkbox.click()
assert dist_agreement.review_policies_checkbox.is_selected()
dist_agreement.click_recaptcha_checkbox()
@pytest.mark.nondestructive