-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic UI testing via playwright, requires Python3 (Fixes #5)
- Includes a dev server test - Includes a few download button tests Update readme, and add requirements-test.txt
- Loading branch information
1 parent
ca0275b
commit 09d0c0f
Showing
7 changed files
with
120 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
[pytest] | ||
addopts = --browser firefox --browser chromium | ||
# webkit doesn't currently work? | ||
# --browser webkit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Specific requirements for testing | ||
pytest==7.3.1 | ||
pytest-playwright==0.3.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import pytest | ||
|
||
import builder | ||
import settings | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def handle_server(): | ||
print("! Starting local test server at {}".format(settings.TEST_URL_BASE)) | ||
server = builder.setup_httpd(settings.TEST_PORT, settings.WEBSITE_RENDERPATH) | ||
yield | ||
print("! Shutting down local test server") | ||
server.terminate() | ||
server.join() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import re | ||
import pytest | ||
from playwright.sync_api import Page, expect | ||
from product_details import thunderbird_desktop | ||
import settings | ||
|
||
@pytest.fixture | ||
def download_page_download_states(page: Page): | ||
"""Returns a list of tuples, which contains the download page to goto, and the download version the visible download button should be.""" | ||
download_page_url = f"{settings.TEST_URL}/download/" | ||
|
||
download_versions = ( | ||
thunderbird_desktop.latest_version('release'), | ||
thunderbird_desktop.latest_version('beta'), | ||
thunderbird_desktop.latest_version('daily') | ||
) | ||
|
||
return [ | ||
(download_page_url, download_versions[0]), | ||
(f"{download_page_url}?downloaded=True", download_versions[0]), | ||
(f"{download_page_url}?downloaded=False", download_versions[0]), | ||
(f"{download_page_url}?download_channel=esr", download_versions[0]), | ||
(f"{download_page_url}?download_channel=beta", download_versions[1]), | ||
(f"{download_page_url}?download_channel=daily", download_versions[2]), | ||
(f"{download_page_url}?download_channel=nonsense", download_versions[0]), | ||
(f"{download_page_url}?download_channel=&downloaded=true&download_channel=beta", download_versions[1]), # Javascript check looks for (esr|beta|daily), empty params are ignored | ||
(f"{download_page_url}?download_channel=&downloaded=true&download_channel=daily&download_channel=beta", download_versions[2]), # Javascript check will only use the first instance | ||
] | ||
|
||
|
||
def test_download_links_exist(page: Page, download_page_download_states): | ||
"""Tests the existence of the `Try Again` button on our download thank you page.""" | ||
for state in download_page_download_states: | ||
page.goto(state[0]) | ||
expect(page.locator('.download-link:visible')).to_have_count(1) | ||
|
||
|
||
def test_download_links_are_correct(page: Page, download_page_download_states): | ||
"""Tests the validity of our download buttons when different download channels have been requested.""" | ||
for state in download_page_download_states: | ||
page.goto(state[0]) | ||
expect(page.locator('.download-link:visible')).to_have_attribute("href", re.compile(state[1])) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import pytest | ||
import settings | ||
from playwright.sync_api import Page, expect | ||
|
||
|
||
def test_server_is_working(page: Page): | ||
"""Make sure our test server works correctly""" | ||
response = page.goto(settings.TEST_URL) | ||
assert response is not None | ||
assert response.ok is True | ||
|
||
# Make sure our title is correct, and this isn't an empty 200. | ||
expect(page).to_have_title('Thunderbird — Make Email Easier. — Thunderbird') | ||
|