Skip to content

Commit b1415d1

Browse files
committed
docs: add Copilot custom instructions for smarter PR review
Repo-specific guidance: layout, run commands, selector/POM/typing conventions, and what to flag in review (sleep, XPath, text selectors, loosened pins, order-dependent tests).
1 parent d556704 commit b1415d1

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

.github/copilot-instructions.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copilot instructions — ecommerce-e2e-playwright
2+
3+
## What this repo is
4+
End-to-end UI test suite for the demo shop **automationexercise.com**.
5+
Python + Playwright (sync API) + pytest, Page Object Model. 12 tests across
6+
auth, search, cart, checkout. ~365 LOC. Runs headless in CI on push and PR
7+
across Chromium/Firefox/WebKit.
8+
9+
## Layout
10+
- `pages/` — Page Object Model. One class per page; `base_page.py` holds shared
11+
navigation (with 5xx retry) and the `parse_price` helper. `flows.py` holds
12+
cross-page actions (e.g. `register_via_ui`) that several tests reuse.
13+
- `tests/` — one file per area (`test_auth`, `test_search`, `test_cart`,
14+
`test_checkout`, `test_smoke`). Tests read as business scenarios; no selectors.
15+
- `utils/data_generator.py` — Faker-backed factories returning `TypedDict`s
16+
(`User`, `PaymentCard`). Every test gets fresh, unique data.
17+
- `conftest.py` — fixtures: API-backed user setup/teardown, ad blocking via
18+
network route, and a `base_url` fixture (sourced from `pytest.ini`).
19+
- `.github/workflows/tests.yml` — CI matrix.
20+
21+
## How to build / run
22+
```bash
23+
pip install -r requirements.txt # versions are pinned, do not loosen
24+
playwright install chromium
25+
pytest # full suite, chromium
26+
pytest -n 4 # parallel (data isolation supports it)
27+
pytest --browser firefox # other engines
28+
```
29+
Tests hit a live third-party site, so transient failures are expected; CI uses
30+
`--reruns 2`. A green local run is the bar before committing.
31+
32+
## Conventions to follow in reviews and changes
33+
- **No `time.sleep()`.** Use Playwright auto-waiting and web-first `expect`.
34+
- **Selectors, in order of preference:** `data-qa` attributes, then stable CSS
35+
classes, then `get_by_role`. Avoid matching on display text (breaks under
36+
i18n) and never use XPath. Note: some buttons are `<a>` with no `href`, so
37+
they have NO ARIA `link` role — `get_by_role("link", ...)` will not find them;
38+
use the stable class (e.g. `a.check_out`).
39+
- **Page objects hold selectors and actions; tests hold assertions and flow.**
40+
Don't put raw locators in test files. Reusable multi-page journeys go in
41+
`pages/flows.py`, not duplicated across tests.
42+
- **Test data is typed.** Extend the `TypedDict`s in `utils/data_generator.py`
43+
rather than passing loose dicts. The signup form and account API use different
44+
field names (`first_name` vs `firstname`) — map explicitly, don't rename keys.
45+
- **Every test owns its data** and must be order-agnostic and xdist-safe (unique
46+
emails via uuid). Don't introduce shared mutable state between tests.
47+
- **Pin dependencies.** `requirements.txt` uses `==`; bump deliberately, never
48+
switch to `>=`.
49+
- **Don't hardcode `--browser` in `pytest.ini`** — it must stay overridable from
50+
the CLI and the CI matrix.
51+
52+
## What to flag in PR review
53+
- Any `time.sleep`, XPath, or text-based selector for a button.
54+
- New locators living in `tests/` instead of `pages/`.
55+
- Loosened dependency pins.
56+
- Tests that depend on execution order or another test's side effects.
57+
- New cross-page flows duplicated instead of added to `pages/flows.py`.
58+
59+
## Trust these instructions
60+
Only search the codebase if something here is incomplete or proves wrong.

0 commit comments

Comments
 (0)