-
Notifications
You must be signed in to change notification settings - Fork 0
Harden the suite: cross-browser CI, parallel runs, typed data, selector + flake fixes #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ee11ff1
build: pin dependency versions for reproducible CI
larelgit b2e4a60
test: stop hardcoding --browser in pytest.ini so CLI override works
larelgit 3459bf7
fix(cart): target stable a.check_out class instead of brittle text
larelgit f92a2d8
refactor: type test data with TypedDict (User, PaymentCard)
larelgit 5fcecff
refactor(tests): extract register_via_ui flow, kill duplicate signup …
larelgit 07ad510
ci: cross-browser matrix (chromium/firefox/webkit) + parallel -n 4
larelgit 52af7c6
chore: extend .gitignore (venv, trace.zip)
larelgit 2455f5c
docs: reflect cross-browser CI, xdist, typed data, selector field note
larelgit 636c76c
ci: run e2e suite on every pull request
larelgit f1a9334
Potential fix for pull request finding
larelgit d556704
Potential fix for pull request finding
larelgit b1415d1
docs: add Copilot custom instructions for smarter PR review
larelgit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,60 @@ | ||
| # Copilot instructions — ecommerce-e2e-playwright | ||
|
|
||
| ## What this repo is | ||
| End-to-end UI test suite for the demo shop **automationexercise.com**. | ||
| Python + Playwright (sync API) + pytest, Page Object Model. 12 tests across | ||
| auth, search, cart, checkout. ~365 LOC. Runs headless in CI on push and PR | ||
| across Chromium/Firefox/WebKit. | ||
|
|
||
| ## Layout | ||
| - `pages/` — Page Object Model. One class per page; `base_page.py` holds shared | ||
| navigation (with 5xx retry) and the `parse_price` helper. `flows.py` holds | ||
| cross-page actions (e.g. `register_via_ui`) that several tests reuse. | ||
| - `tests/` — one file per area (`test_auth`, `test_search`, `test_cart`, | ||
| `test_checkout`, `test_smoke`). Tests read as business scenarios; no selectors. | ||
| - `utils/data_generator.py` — Faker-backed factories returning `TypedDict`s | ||
| (`User`, `PaymentCard`). Every test gets fresh, unique data. | ||
| - `conftest.py` — fixtures: API-backed user setup/teardown, ad blocking via | ||
| network route, and a `base_url` fixture (sourced from `pytest.ini`). | ||
| - `.github/workflows/tests.yml` — CI matrix. | ||
|
|
||
| ## How to build / run | ||
| ```bash | ||
| pip install -r requirements.txt # versions are pinned, do not loosen | ||
| playwright install chromium | ||
| pytest # full suite, chromium | ||
| pytest -n 4 # parallel (data isolation supports it) | ||
| pytest --browser firefox # other engines | ||
| ``` | ||
| Tests hit a live third-party site, so transient failures are expected; CI uses | ||
| `--reruns 2`. A green local run is the bar before committing. | ||
|
|
||
| ## Conventions to follow in reviews and changes | ||
| - **No `time.sleep()`.** Use Playwright auto-waiting and web-first `expect`. | ||
| - **Selectors, in order of preference:** `data-qa` attributes, then stable CSS | ||
| classes, then `get_by_role`. Avoid matching on display text (breaks under | ||
| i18n) and never use XPath. Note: some buttons are `<a>` with no `href`, so | ||
| they have NO ARIA `link` role — `get_by_role("link", ...)` will not find them; | ||
| use the stable class (e.g. `a.check_out`). | ||
| - **Page objects hold selectors and actions; tests hold assertions and flow.** | ||
| Don't put raw locators in test files. Reusable multi-page journeys go in | ||
| `pages/flows.py`, not duplicated across tests. | ||
| - **Test data is typed.** Extend the `TypedDict`s in `utils/data_generator.py` | ||
| rather than passing loose dicts. The signup form and account API use different | ||
| field names (`first_name` vs `firstname`) — map explicitly, don't rename keys. | ||
| - **Every test owns its data** and must be order-agnostic and xdist-safe (unique | ||
| emails via uuid). Don't introduce shared mutable state between tests. | ||
| - **Pin dependencies.** `requirements.txt` uses `==`; bump deliberately, never | ||
| switch to `>=`. | ||
| - **Don't hardcode `--browser` in `pytest.ini`** — it must stay overridable from | ||
| the CLI and the CI matrix. | ||
|
|
||
| ## What to flag in PR review | ||
| - Any `time.sleep`, XPath, or text-based selector for a button. | ||
| - New locators living in `tests/` instead of `pages/`. | ||
| - Loosened dependency pins. | ||
| - Tests that depend on execution order or another test's side effects. | ||
| - New cross-page flows duplicated instead of added to `pages/flows.py`. | ||
|
|
||
| ## Trust these instructions | ||
| Only search the codebase if something here is incomplete or proves wrong. |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| # virtualenv | ||
| .venv/ | ||
|
|
||
| # python | ||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
|
|
||
| # pytest / playwright artifacts | ||
| .venv/ | ||
| venv/ | ||
| .pytest_cache/ | ||
| test-results/ | ||
|
|
||
| # Test artifacts | ||
| report.html | ||
| test-results/ | ||
| playwright-report/ | ||
| trace.zip |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,26 @@ | ||
| """Cross-page user flows that several tests share. | ||
|
|
||
| Lives outside the page objects because it spans pages (login -> signup), | ||
| and outside conftest because it's a reusable action, not a fixture. | ||
| """ | ||
| from playwright.sync_api import Page, expect | ||
|
|
||
| from pages.login_page import LoginPage | ||
| from pages.signup_page import SignupPage | ||
| from utils.data_generator import User | ||
|
|
||
|
|
||
| def register_via_ui(page: Page, user: User) -> SignupPage: | ||
| """Full UI signup journey ending logged in. Returns the SignupPage | ||
| so callers can chain logout/delete-account checks.""" | ||
| login = LoginPage(page) | ||
| login.open() | ||
| login.start_signup(user["name"], user["email"]) | ||
|
|
||
| signup = SignupPage(page) | ||
| expect(signup.form_heading).to_be_visible() | ||
| signup.fill_account_details(user) | ||
| expect(signup.account_created_message).to_be_visible() | ||
| signup.continue_after_signup() | ||
| expect(signup.logged_in_as(user["name"])).to_be_visible() | ||
| return signup |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| [pytest] | ||
| testpaths = tests | ||
| base_url = https://automationexercise.com | ||
| addopts = --browser chromium --screenshot only-on-failure --output test-results | ||
| # Browser is NOT hardcoded here so `--browser firefox|webkit` works from the CLI | ||
| # and the CI matrix. Default (chromium) comes from pytest-playwright. | ||
| addopts = --screenshot only-on-failure --output test-results |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| pytest>=8.0 | ||
| pytest-playwright>=0.5.2 | ||
| pytest-html>=4.1 | ||
| pytest-rerunfailures>=14.0 | ||
| faker>=33.0 | ||
| # Pinned for reproducible CI runs. Bump deliberately, not by surprise. | ||
| pytest==9.1.0 | ||
| pytest-playwright==0.8.0 | ||
| pytest-html==4.2.0 | ||
| pytest-rerunfailures==16.3 | ||
| pytest-xdist==3.8.0 | ||
| faker==40.23.0 |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.