Add tests for the devhub upload file page (#791)
This commit is contained in:
Родитель
7902e27b28
Коммит
d5d436fffd
6
dev.json
6
dev.json
|
@ -135,7 +135,11 @@
|
|||
"unlisted_option_helptext": "After your submission is signed by Mozilla, you can download the .xpi file from the Developer Hub and distribute it to your audience. Please make sure the add-on manifest’s update_url is provided, as this is the URL where Firefox finds updates for automatic deployment to your users.",
|
||||
"distribution_and_signing_helptext": "You can learn more about these options by reading Add-on Distribution and Signing on Firefox Extension Workshop.",
|
||||
"addon_policies_helptext": "All add-ons must comply with Mozilla’s Add-on Policies and are subject to manual review at any time after submission.",
|
||||
|
||||
"upload_extension_file_helptext": "Use the fields below to upload your add-on package. After upload, a series of automated validation tests will be run on your file.",
|
||||
"upload_theme_file_helptext": "You can upload a finished theme using the upload option above, or you can build it yourself using this tool.",
|
||||
"supported_filetypes": "Your add-on should end with .zip, .xpi or .crx",
|
||||
"compatibility_helptext": "Which applications is this version compatible with?",
|
||||
"create_theme_subheader": "Create a Theme Version",
|
||||
|
||||
"unlisted_submission_confirmation": "You’re 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": "You’re done! ✨ You will receive a confirmation email when this version is published on addons-dev.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.",
|
||||
|
|
|
@ -18,6 +18,7 @@ class SubmitAddon(Page):
|
|||
By.CSS_SELECTOR,
|
||||
'.addon-submission-process h3',
|
||||
)
|
||||
_developer_notification_box_locator = (By.CSS_SELECTOR, '.notification-box')
|
||||
_distribution_page_explainer_locator = (
|
||||
By.CSS_SELECTOR,
|
||||
'.addon-submission-process p:nth-of-type(1)',
|
||||
|
@ -66,13 +67,28 @@ class SubmitAddon(Page):
|
|||
)
|
||||
_change_distribution_link_locator = (By.CSS_SELECTOR, '.addon-submit-distribute a')
|
||||
_continue_button_locator = (By.CSS_SELECTOR, '.addon-submission-field button')
|
||||
_file_upload_process_helptext_locator = (By.CSS_SELECTOR, '.new-addon-file p')
|
||||
_upload_file_button_locator = (By.CSS_SELECTOR, '.invisible-upload input')
|
||||
_accepted_file_types_locator = (By.CLASS_NAME, 'upload-details')
|
||||
_compatibility_helptext_locator = (By.CSS_SELECTOR, '.compatible-apps label')
|
||||
_compatibility_error_message_locator = (By.CSS_SELECTOR, '.errorlist li')
|
||||
_firefox_compat_checkbox_locator = (By.CSS_SELECTOR, '.app.firefox input')
|
||||
_android_compat_checkbox_locator = (By.CSS_SELECTOR, '.app.android input')
|
||||
_create_theme_subheader_locator = (
|
||||
By.CSS_SELECTOR,
|
||||
'.addon-create-theme-section h3',
|
||||
)
|
||||
_create_theme_button_locator = (By.ID, 'wizardlink')
|
||||
_submit_file_button_locator = (By.ID, 'submit-upload-file-finish')
|
||||
_addon_validation_success_locator = (By.CLASS_NAME, 'bar-success')
|
||||
_validation_fail_message_locator = (By.CLASS_NAME, 'status-fail')
|
||||
_validation_fail_bar_locator = (By.CLASS_NAME, 'bar-fail')
|
||||
_validation_support_link_locator = (By.CSS_SELECTOR, '#upload-status-results a')
|
||||
_validation_failed_message_locator = (
|
||||
By.CSS_SELECTOR,
|
||||
'#upload-status-results strong',
|
||||
)
|
||||
_validation_fail_reason_locator = (By.CSS_SELECTOR, '#upload_errors li')
|
||||
_validation_status_text_locator = (By.ID, 'upload-status-text')
|
||||
_validation_success_message_locator = (By.ID, 'upload-status-results')
|
||||
|
||||
@property
|
||||
|
@ -84,9 +100,13 @@ class SubmitAddon(Page):
|
|||
return self.find_element(*self._submission_form_header_locator)
|
||||
|
||||
@property
|
||||
def distribution_header(self):
|
||||
def submission_form_subheader(self):
|
||||
return self.find_element(*self._addon_distribution_header_locator)
|
||||
|
||||
@property
|
||||
def developer_notification_box(self):
|
||||
return self.find_element(*self._developer_notification_box_locator)
|
||||
|
||||
@property
|
||||
def distribution_page_explainer(self):
|
||||
return self.find_element(*self._distribution_page_explainer_locator).text
|
||||
|
@ -202,12 +222,28 @@ class SubmitAddon(Page):
|
|||
def click_continue(self):
|
||||
self.find_element(*self._continue_button_locator).click()
|
||||
|
||||
@property
|
||||
def file_upload_helptext(self):
|
||||
return self.find_elements(*self._file_upload_process_helptext_locator)
|
||||
|
||||
def upload_addon(self, addon):
|
||||
"""Selects an addon from the 'sample-addons' folder and uploads it"""
|
||||
button = self.find_element(*self._upload_file_button_locator)
|
||||
archive = Path(f'{os.getcwd()}/sample-addons/{addon}')
|
||||
button.send_keys(str(archive))
|
||||
|
||||
@property
|
||||
def accepted_file_types(self):
|
||||
return self.find_element(*self._accepted_file_types_locator).text
|
||||
|
||||
@property
|
||||
def compatibility_helptext(self):
|
||||
return self.find_elements(*self._compatibility_helptext_locator)[0].text
|
||||
|
||||
@property
|
||||
def compatibility_error_message(self):
|
||||
return self.find_element(*self._compatibility_error_message_locator).text
|
||||
|
||||
@property
|
||||
def firefox_compat_checkbox(self):
|
||||
return self.find_element(*self._firefox_compat_checkbox_locator)
|
||||
|
@ -216,6 +252,10 @@ class SubmitAddon(Page):
|
|||
def android_compat_checkbox(self):
|
||||
return self.find_element(*self._android_compat_checkbox_locator)
|
||||
|
||||
@property
|
||||
def create_theme_subheader(self):
|
||||
return self.find_element(*self._create_theme_subheader_locator).text
|
||||
|
||||
def click_create_theme_button(self):
|
||||
self.find_element(*self._create_theme_button_locator).click()
|
||||
return ThemeWizard(self.driver, self.base_url).wait_for_page_to_load()
|
||||
|
@ -227,8 +267,33 @@ class SubmitAddon(Page):
|
|||
)
|
||||
|
||||
@property
|
||||
def failed_validation_message(self):
|
||||
return self.find_element(*self._validation_fail_message_locator)
|
||||
def failed_validation_bar(self):
|
||||
return self.find_element(*self._validation_fail_bar_locator)
|
||||
|
||||
@property
|
||||
def validation_status_title(self):
|
||||
return self.find_element(*self._validation_status_text_locator).text
|
||||
|
||||
def click_validation_support_link(self):
|
||||
self.find_element(*self._validation_support_link_locator).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.url_contains('/mozilla/addons-linter/'))
|
||||
self.driver.close()
|
||||
# return to the main tab
|
||||
self.driver.switch_to.window(self.driver.window_handles[0])
|
||||
|
||||
@property
|
||||
def validation_failed_message(self):
|
||||
return self.find_element(*self._validation_failed_message_locator).text
|
||||
|
||||
@property
|
||||
def validation_failed_reason(self):
|
||||
return self.find_elements(*self._validation_fail_reason_locator)
|
||||
|
||||
@property
|
||||
def success_validation_message(self):
|
||||
|
|
|
@ -138,6 +138,11 @@
|
|||
"unlisted_option_helptext": "After your submission is signed by Mozilla, you can download the .xpi file from the Developer Hub and distribute it to your audience. Please make sure the add-on manifest’s update_url is provided, as this is the URL where Firefox finds updates for automatic deployment to your users.",
|
||||
"distribution_and_signing_helptext": "You can learn more about these options by reading Add-on Distribution and Signing on Firefox Extension Workshop.",
|
||||
"addon_policies_helptext": "All add-ons must comply with Mozilla’s Add-on Policies and are subject to manual review at any time after submission.",
|
||||
"upload_extension_file_helptext": "Use the fields below to upload your add-on package. After upload, a series of automated validation tests will be run on your file.",
|
||||
"upload_theme_file_helptext": "You can upload a finished theme using the upload option above, or you can build it yourself using this tool.",
|
||||
"supported_filetypes": "Your add-on should end with .zip, .xpi or .crx",
|
||||
"compatibility_helptext": "Which applications is this version compatible with?",
|
||||
"create_theme_subheader": "Create a Theme Version",
|
||||
|
||||
"unlisted_submission_confirmation": "You’re 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": "You’re 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.",
|
||||
|
|
|
@ -18,7 +18,7 @@ def test_devhub_developer_agreement_page_contents(selenium, base_url, variables,
|
|||
dist_agreement = page.click_submit_addon_button()
|
||||
assert (
|
||||
variables['devhub_submit_addon_agreement_header']
|
||||
in dist_agreement.distribution_header.text
|
||||
in dist_agreement.submission_form_subheader.text
|
||||
)
|
||||
assert (
|
||||
variables['distribution_page_explainer']
|
||||
|
@ -78,7 +78,7 @@ def test_addon_distribution_page_contents(selenium, base_url, variables, wait):
|
|||
wait.until(lambda _: dist_page.submission_form_header.is_displayed())
|
||||
assert (
|
||||
variables['devhub_submit_addon_distribution_header']
|
||||
in dist_page.distribution_header.text
|
||||
in dist_page.submission_form_subheader.text
|
||||
)
|
||||
# checks that the listed option is selected by default
|
||||
assert dist_page.listed_option_radiobutton.is_selected()
|
||||
|
@ -105,6 +105,65 @@ def test_addon_distribution_page_contents(selenium, base_url, variables, wait):
|
|||
)
|
||||
|
||||
|
||||
def test_devhub_upload_file_page_contents(selenium, base_url, wait, variables):
|
||||
"""Verify the elements present on the upload file page, where the user
|
||||
uploads and validates an addon file"""
|
||||
page = DevHubHome(selenium, base_url).open().wait_for_page_to_load()
|
||||
page.devhub_login('submissions_user')
|
||||
selenium.get(f'{base_url}/developers/addon/submit/upload-listed')
|
||||
upload_page = SubmitAddon(selenium, base_url).wait_for_page_to_load()
|
||||
upload_page.developer_notification_box.is_displayed()
|
||||
assert (
|
||||
variables['upload_extension_file_helptext']
|
||||
in upload_page.file_upload_helptext[0].text
|
||||
)
|
||||
assert variables['supported_filetypes'] in upload_page.accepted_file_types
|
||||
assert variables['compatibility_helptext'] in upload_page.compatibility_helptext
|
||||
assert variables['create_theme_subheader'] in upload_page.create_theme_subheader
|
||||
assert (
|
||||
variables['upload_theme_file_helptext']
|
||||
in upload_page.file_upload_helptext[2].text
|
||||
)
|
||||
|
||||
|
||||
def test_upload_unsupported_file_validation_error(selenium, base_url, wait):
|
||||
"""Verify validation results for errors triggered by unsupported file uploads"""
|
||||
page = DevHubHome(selenium, base_url).open().wait_for_page_to_load()
|
||||
page.devhub_login('submissions_user')
|
||||
selenium.get(f'{base_url}/developers/addon/submit/upload-listed')
|
||||
upload_page = SubmitAddon(selenium, base_url).wait_for_page_to_load()
|
||||
file = 'tar-ext.tar'
|
||||
upload_page.upload_addon(file)
|
||||
wait.until(lambda _: upload_page.failed_validation_bar.is_displayed())
|
||||
# check that the validation results show the following 'error specific' components
|
||||
assert f'Error with {file}' in upload_page.validation_status_title
|
||||
upload_page.click_validation_support_link()
|
||||
assert 'Your add-on failed validation' in upload_page.validation_failed_message
|
||||
assert (
|
||||
"The filetype you uploaded isn't recognized"
|
||||
in upload_page.validation_failed_reason[0].text
|
||||
)
|
||||
|
||||
|
||||
def test_upload_file_no_compatibility_selected(selenium, base_url, wait):
|
||||
"""Verify that at least one compatibility needs to be selected when uploading an addon"""
|
||||
page = DevHubHome(selenium, base_url).open().wait_for_page_to_load()
|
||||
page.devhub_login('submissions_user')
|
||||
selenium.get(f'{base_url}/developers/addon/submit/upload-listed')
|
||||
upload_page = SubmitAddon(selenium, base_url).wait_for_page_to_load()
|
||||
# un-check the Firefox compat checkbox to leave all compatibility options disabled
|
||||
upload_page.firefox_compat_checkbox.click()
|
||||
upload_page.upload_addon('unlisted-addon.zip')
|
||||
upload_page.is_validation_successful()
|
||||
assert upload_page.success_validation_message.is_displayed()
|
||||
upload_page.click_continue_upload_button()
|
||||
wait.until(
|
||||
lambda _: 'Need to select at least one application.'
|
||||
in upload_page.compatibility_error_message,
|
||||
message=f'The actual error message raised was: {upload_page.compatibility_error_message}',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.sanity
|
||||
@pytest.mark.serial
|
||||
# The first test starts the browser with a normal login in order to store de session cookie
|
||||
|
|
|
@ -236,12 +236,12 @@ def test_devhub_click_first_theme_button(selenium, base_url, variables):
|
|||
try:
|
||||
assert (
|
||||
variables['devhub_submit_addon_agreement_header']
|
||||
in distribution_page.distribution_header.text
|
||||
in distribution_page.submission_form_subheader.text
|
||||
)
|
||||
except AssertionError:
|
||||
assert (
|
||||
variables['devhub_submit_addon_distribution_header']
|
||||
in distribution_page.distribution_header.text
|
||||
in distribution_page.submission_form_subheader.text
|
||||
)
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче