-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#203 Simplify dialog capture and continue E2E tests
- Loading branch information
Showing
10 changed files
with
367 additions
and
156 deletions.
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
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,27 @@ | ||
""" | ||
Global fixtures for E2E tests. | ||
Called automatically by Pytest before running tests. | ||
""" | ||
|
||
from __future__ import annotations | ||
import pytest | ||
from playwright.sync_api import Page, Dialog | ||
from tests.e2e.helpers import CaptureDialogs | ||
|
||
|
||
@pytest.fixture(name="capture_dialogs") | ||
def fixture_capture_dialogs(page: Page) -> CaptureDialogs: | ||
"""Capture dialogs and expose a an object with settings and captured values.""" | ||
capture_dialogs = CaptureDialogs() | ||
|
||
def handle_dialog(dialog: Dialog) -> None: | ||
capture_dialogs.num_dialogs += 1 | ||
capture_dialogs.last_dialog_message = dialog.message | ||
if capture_dialogs.accept: | ||
dialog.accept() | ||
else: | ||
dialog.dismiss() | ||
|
||
page.on("dialog", handle_dialog) | ||
return capture_dialogs |
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,62 @@ | ||
"""Tests for commit selection.""" | ||
|
||
import pytest | ||
from playwright.sync_api import Page, expect | ||
from tests.e2e.helpers import reset_db, CommitInfo | ||
|
||
FIRST_COMMIT = CommitInfo(1) | ||
LATEST_COMMIT = CommitInfo(3) | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def setup(page: Page) -> None: | ||
"""Automatically run before each test in this module.""" | ||
reset_db(3) | ||
page.goto("/") | ||
|
||
|
||
def test_commit_select_inputs(page: Page) -> None: | ||
"""Displays the latest commit, latest is checked, and inputs are not disabled.""" | ||
commit_select_combobox = page.get_by_test_id("commit-select-combobox") | ||
commit_select_combobox_input = commit_select_combobox.get_by_role("combobox") | ||
latest_checkbox = page.get_by_test_id("latest-checkbox") | ||
commit_id_item = page.get_by_test_id("parameter-list-item-commit_id") | ||
|
||
expect(commit_select_combobox).to_contain_text(LATEST_COMMIT.date) | ||
expect(commit_select_combobox_input).to_have_value(LATEST_COMMIT.message) | ||
expect(latest_checkbox).to_be_checked() | ||
expect(commit_id_item).to_have_text(f"commit_id{LATEST_COMMIT.id}") | ||
|
||
|
||
def test_commit_search(page: Page) -> None: | ||
"""Searches for the initial commit and switches to it.""" | ||
commit_select_combobox = page.get_by_test_id("commit-select-combobox") | ||
commit_select_combobox_input = commit_select_combobox.get_by_role("combobox") | ||
commit_id_item = page.get_by_test_id("parameter-list-item-commit_id") | ||
|
||
# Search and select first commit | ||
commit_select_combobox_input.fill(FIRST_COMMIT.message[:8]) | ||
commit_select_combobox_input.press("Enter") | ||
expect(commit_select_combobox).to_contain_text(FIRST_COMMIT.date) | ||
expect(commit_select_combobox_input).to_have_value(FIRST_COMMIT.message) | ||
expect(commit_id_item).to_have_text(f"commit_id{FIRST_COMMIT.id}") | ||
|
||
|
||
def test_latest_checkbox(page: Page) -> None: | ||
"""Switches to latest commit when latest checkbox is checked.""" | ||
commit_select_combobox = page.get_by_test_id("commit-select-combobox") | ||
commit_select_combobox_input = commit_select_combobox.get_by_role("combobox") | ||
latest_checkbox = page.get_by_test_id("latest-checkbox") | ||
commit_id_item = page.get_by_test_id("parameter-list-item-commit_id") | ||
|
||
# Switch to first commit | ||
commit_select_combobox_input.fill(FIRST_COMMIT.message[:8]) | ||
commit_select_combobox_input.press("Enter") | ||
expect(latest_checkbox).not_to_be_checked() | ||
|
||
# Check the latest checkbox | ||
latest_checkbox.check() | ||
expect(latest_checkbox).to_be_checked() | ||
expect(commit_select_combobox).to_contain_text(LATEST_COMMIT.date) | ||
expect(commit_select_combobox_input).to_have_value(LATEST_COMMIT.message) | ||
expect(commit_id_item).to_have_text(f"commit_id{LATEST_COMMIT.id}") |
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,22 @@ | ||
"""Tests for the page title.""" | ||
|
||
import pytest | ||
from playwright.sync_api import Page, expect | ||
from tests.e2e.helpers import DB_NAME, reset_db | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def setup(page: Page) -> None: | ||
"""Automatically run before each test in this module.""" | ||
reset_db() | ||
page.goto("/") | ||
|
||
|
||
def test_page_title(page: Page) -> None: | ||
"""Page title is the database file name.""" | ||
expect(page).to_have_title(DB_NAME) | ||
|
||
|
||
def test_database_name(page: Page) -> None: | ||
"""Database name header is the database file name.""" | ||
expect(page.get_by_test_id("database-name")).to_have_text(DB_NAME) |
Oops, something went wrong.