# Common Pitfalls (Humand E2E)

## 1) Using fragile selectors

- Problem: class-based selectors break with MUI/rendering changes.
- Fix: prefer role/label/text and keep locators in page objects.

## 2) Overusing `waitForTimeout`

- Problem: slow and flaky tests.
- Fix: web-first assertions and URL/locator-based synchronization.

## 3) Shared test state

- Problem: tests pass alone but fail in parallel.
- Fix: create isolated data per test and cleanup explicitly.

## 4) Missing metadata

- Problem: failures are hard to triage.
- Fix: include `owner`, `module`, `severity` annotations; add `jira`/`issue` when relevant.

## 5) Mixing concerns

- Problem: tests contain locator internals and flow logic all together.
- Fix: move interactions to page object methods; keep tests scenario-focused.

## 6) Ignoring known product bugs

- Problem: noisy red pipelines without actionability.
- Fix: mark with `test.fixme()` and a clear reason while bug is active.

## 7) Strict mode violations from leftover test data

- Problem: `filter({ hasText })` or row locators match multiple elements because previous test runs left behind entities with similar names or descriptions (e.g., `'E2E test description'` appears in 3 rows).
- Fix: always filter by the unique name generated with `Date.now()`, never by shared/generic text. For tests that don't create data (e.g., "cancel delete"), use `tableRows.first()` instead of filtering by content.

## 8) Assertion order causing race conditions

- Problem: asserting a slow-rendering element before a fast one can timeout if the page hasn't fully loaded.
- Fix: assert the heaviest/slowest element first (e.g., table before tab label) so later assertions benefit from the implicit wait.

## 9) Locale or auth contract drift

- Problem: tests assume one locale or auth flow, but the project contract in `playwright.config.ts` and `auth.setup.ts` says otherwise.
- Fix: inspect the local contract before generating or healing locators and refresh auth when the storage state is stale.

## 10) Non-standard interactive regions

- Problem: collapsed panels, rotated labels, or icon-only triggers tempt the generator to guess selectors that are not really stable.
- Fix: inspect the region with MCP first. If it still cannot be automated reliably, mark the scenario as `test.fixme()` with a clear reason.
