f26a150086
* Remove amo-validator, remove more support for uploading legacy-addons. This is dropping most of our compatibility checks for legacy add-ons and completely blocks them from being uploaded. We workaround this block for mozilla-signed add-ons by issuing the same error, just as a warning instead of an actual error. This affected *loads* of our tests so the PR contains more test-changes then I'd like. In addition to that this PR adds file extension validation for uploads, we only did that in our JavaScript and never in our code. So from now on, we have a hard limit to only allow whatever is in `VALID_EXTENSIONS`. Further... * drop amo-validator and related dependencies * remove `dump_apps` management command * removed unused fixture files from the repo Fixes #10502 Future improvement idea for our test-suite: Unify add-on file fixtures under one single folder to avoid any duplication. There is most certainly some more improvements that could be made to code and test structure but I went for the least changes, it's way too huge already :-/ * Fix syntax error in JavaScript, thus ui tests * Switch back to passing 'channel' around * Move valid addon file extensions to constants/base * Fix validate() call * Fix more tests * Update src/olympia/devhub/tests/test_views_validation.py Co-Authored-By: EnTeQuAk <cg@webshox.org> * Remove old comment * Issue description specific only to Thunderbird and Seamonkey if targeting thunderbird or seamonkey |
||
---|---|---|
.. | ||
pages | ||
regions | ||
README.md | ||
conftest.py | ||
docker-compose.selenium.yml | ||
setup.cfg | ||
test_devhub.py | ||
test_home.py | ||
test_install.py | ||
test_login.py | ||
test_search.py |
README.md
Integration Tests for the Mozilla Addons Website.
How to run the tests locally
Clone the repository
If you have cloned this project already then you can skip this, otherwise you'll need to clone this repo using Git. If you do not know how to clone a GitHub repository, check out this help page from GitHub.
If you think you would like to contribute to the tests by writing or maintaining them in the future, it would be a good idea to create a fork of this repository first, and then clone that. GitHub also has great instructions for forking a repository.
Server Install
Follow the instructions found here.
Run the tests
IMPORTANT : Run the script in scripts/ui-test-hostname-setup.sh
before running the test to setup the hostnames within the docker container.
The selenium tests are included in a separate tests/ui/docker-compose.selenium.yml
file. This image contains Firefox Nightly. tox
is our test environment manager and pytest is the test runner.
To run the tests, execute the commands below:
# Make sure all required containers are running.
docker-compose -f docker-compose.yml -f tests/ui/docker-compose.selenium.yml up -d
docker-compose -f docker-compose.yml -f tests/ui/docker-compose.selenium.yml exec --user root selenium-firefox tox -e ui-tests
WARNING: This will WIPE the database as the test will create specific data for itself to look for. If you have anything you don't want to be deleted, please do not run these tests.
Adding a test
The tests are written in Python using a POM, or Page Object Model. The plugin we use for this is called pypom. Please read the documentation there for good examples on how to use the Page Object Model when writing tests.
The pytest plugin that we use for running tests has a number of advanced command line options available too. The full documentation for the plugin can be found here.
Additional Information
The tests run against the newest version of the AMO frontend using a docker image provided by addons-frontend. You can view the frontend after the build has been completed at olympia.test:3000
.
Watching a test run
The tests are run on a live version of Firefox, but they are run headless. To access the container where the tests are run to view them follow these steps:
IMPORTANT: Please comment out this line within the tests/ui/conftest.py
file if you would like to view or debug the tests.
firefox_options.add_argument('-headless')
- Make sure all of the containers are running:
docker-compose ps
If not start them detached:
docker-compose -f docker-compose.yml -f tests/ui/docker-compose.selenium.yml up -d
- Copy the port that is forwarded for the
selenium-firefox
image:
0.0.0.0:32771->5900/tcp
Note: Your port may not match what is seen here.
You will want to copy what ever IP address and port is before the ->5900/tcp
.
- Open your favorite VNC viewer and type in, or paste that address.
- The password is
secret
. - The viewer should open a window with a Ubuntu logo. If that happens you are connected to the
selenium-firefox
image and if you start the test, you should see a Firefox window open and the tests running.
Firefox setup
The preferences used to setup Firefox are here:
firefox_options.set_preference(
'extensions.install.requireBuiltInCerts', False)
firefox_options.set_preference('xpinstall.signatures.required', False)
firefox_options.set_preference('extensions.webapi.testing', True)
firefox_options.set_preference('ui.popup.disable_autohide', True)
firefox_options.add_argument('-foreground')
firefox_options.add_argument('-headless')
firefox_options.log.level = 'trace'
These shouldn't need to be touched as they allow for unsigned addon installation as well as disabling the autohide function and setting the Firefox browser to run headless.
If you do need to edit these settings, as mentioned above please visit the file conftest.py
within this directory.
Mobile and Desktop testing
If you would like to add or edit tests please consider that these are run on both a mobile resolution and a desktop resolution. The mobile resolution is 738x414 (iPhone 7+)
, the desktop resolution is: 1920x1080
. Your tests should be able to work on both.
Debugging a failure
Whether a test passes or fails will result in a HTML report being created. This report will have detailed information of the test run and if a test does fail, it will provide geckodriver logs, terminal logs, as well as a screenshot of the browser when the test failed. We use a pytest plugin called pytest-html to create this report. The report can be found within the root directory of the project and is named ui-test.html
. It should be viewed within a browser.