Skip to content

Commit 19dcde7

Browse files
docs(e2e): Revise README for dotCMS End-to-End Testing (dotCMS#36602)
This pull request updates the documentation for the dotCMS UI E2E test suite to clarify project structure, setup, and best practices. The changes improve onboarding for both human developers and AI agents, standardize terminology, and provide detailed guidance on data setup, environment configuration, and when to use E2E vs. unit/integration tests. The documentation now emphasizes REST API-based test data setup, project layout, and the preferred workflow for writing and debugging tests. **Major documentation improvements:** *General onboarding and entry points:* - Updated `README.md` to serve as the canonical entry point for human developers, with step-by-step local debug flow, CI parity instructions, and a clear project layout. - Clarified that `AGENTS.md` is the source of truth for code conventions and is the primary reference for AI agents, while humans should start at `README.md`. [[1]](diffhunk://#diff-321c3ccef76190510309d87100a88a346ae02222eadd2be3c29ce977f44530dcL3-R5) [[2]](diffhunk://#diff-ff8c2a8737638f98cbda3a44a2446fc3e7e129efe9afe526cb9ccea38434f918L3-R3) *Test data setup and REST API usage:* - Standardized the requirement that all test data must be created via REST API helpers in `src/requests/`, not through the UI, and described the available helper modules and how to add new ones. [[1]](diffhunk://#diff-321c3ccef76190510309d87100a88a346ae02222eadd2be3c29ce977f44530dcR51-R66) [[2]](diffhunk://#diff-d013b2a862cab8f5c8a89abc5657680b0f8f881e854ad0997d64868d36113afcL1-R263) - Updated documentation to clarify that specs and fixtures should import from `src/requests/`, with orchestration in `fixtures/` and raw endpoint calls in `requests/`. [[1]](diffhunk://#diff-321c3ccef76190510309d87100a88a346ae02222eadd2be3c29ce977f44530dcL12-L33) [[2]](diffhunk://#diff-321c3ccef76190510309d87100a88a346ae02222eadd2be3c29ce977f44530dcR51-R66) [[3]](diffhunk://#diff-d013b2a862cab8f5c8a89abc5657680b0f8f881e854ad0997d64868d36113afcL1-R263) *Environment and workflow:* - Expanded and clarified environment variable documentation, test run modes (dev vs. CI), and the full local/CI test lifecycle with commands and expected behavior. - Provided a detailed cheat sheet for when to use unit, integration, or E2E tests, and established rules for test isolation and data cleanup. *Project structure and conventions:* - Improved project layout documentation, clarified folder purposes, and reinforced file naming and locator conventions. [[1]](diffhunk://#diff-321c3ccef76190510309d87100a88a346ae02222eadd2be3c29ce977f44530dcL12-L33) [[2]](diffhunk://#diff-d013b2a862cab8f5c8a89abc5657680b0f8f881e854ad0997d64868d36113afcL1-R263) - Added guidance on how to create new E2E tests, including copying patterns, using the Page Object Model, and locator priority. *AI-assisted workflow:* - Outlined a recommended process for AI-assisted E2E test creation, including redundancy checks and integration with QA/test planning. This PR fixes: dotCMS#31718 --------- Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 7028ef2 commit 19dcde7

4 files changed

Lines changed: 197 additions & 369 deletions

File tree

core-web/apps/dotcms-ui-e2e/AGENTS.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# E2E — dotCMS Playwright
22

3-
> **Source of truth.** `CLAUDE.md` in this directory only points here.
3+
> **Source of truth for code conventions.** `CLAUDE.md` in this directory points here.
4+
5+
**How to run tests, CI parity, unit vs E2E cheat sheet, and AI workflow:** see [README.md](README.md).
46

57
## Layout
68

@@ -9,28 +11,13 @@ src/
911
fixtures/ # auth, API setup (e.g. relationship.fixture.ts)
1012
pages/ # shared page objects (*.page.ts)
1113
utils/ # iframe, portlets, credentials
12-
requests/ # content type / contentlet API
14+
requests/ # REST API helpers for test data (content types, contentlets, sites, …)
1315
tests/edit-content/fields/{field-type}/
1416
helpers/ # locators for that field only
1517
*.spec.ts
1618
playwright.config.ts
1719
```
1820

19-
## Run
20-
21-
```bash
22-
pnpm nx e2e dotcms-ui-e2e --grep "pattern"
23-
HEADLESS=true pnpm nx e2e dotcms-ui-e2e --grep "pattern"
24-
pnpm e2e:dev | e2e:dev:headless | e2e:ci | e2e:ui # from core-web/
25-
npx playwright codegen http://localhost:4200/dotAdmin
26-
```
27-
28-
| | `dev` (default) | `ci` |
29-
|---|---|---|
30-
| URL | `:4200` (proxy → `:8080`) | `:8080` direct |
31-
32-
Env: `CURRENT_ENV`, `HEADLESS`, `E2E_BASE_URL`, `E2E_REUSE_EXISTING_SERVER`. Reports: `dist/.playwright/apps/dotcms-ui-e2e/`.
33-
3421
## Conventions
3522

3623
- **Files:** kebab-case; specs `{feature}-{journey}.spec.ts`; helpers in `helpers/` (no suffix); shared pages `*.page.ts`; fixtures `{feature}.fixture.ts`.
@@ -41,7 +28,7 @@ Env: `CURRENT_ENV`, `HEADLESS`, `E2E_BASE_URL`, `E2E_REUSE_EXISTING_SERVER`. Rep
4128

4229
1. `getByRole` → 2. `getByTestId` → 3. `getByLabel` → 4. CSS **only** in Dojo iframe.
4330

44-
Unsure? **Codegen first.** Avoid fragile `#dijit_*` IDs, CSS when `data-testid` exists, `.locator('button')` on `getByRole('button')`, and `isVisible()` for waits (use `waitFor` / `expect().toBeVisible`).
31+
Unsure? **Codegen first** (`npx playwright codegen http://localhost:4200/dotAdmin`). Avoid fragile `#dijit_*` IDs, CSS when `data-testid` exists, `.locator('button')` on `getByRole('button')`, and `isVisible()` for waits (use `waitFor` / `expect().toBeVisible`).
4532

4633
## Angular + Dojo
4734

@@ -61,9 +48,22 @@ Field-specific selectors and flows: copy `tests/.../helpers/` and nearest `*.spe
6148
| Generic (iframe, URLs) | `utils/` |
6249
| HTTP setup | `requests/` + `fixtures/` |
6350

51+
## REST API setup (`src/requests/`)
52+
53+
**Always create test data through the REST API** — never via the UI during setup. Specs and fixtures import helpers from `src/requests/`; raw endpoint calls live there, not in test files.
54+
55+
Modules: `contentType.ts`, `contentlets.ts`, `sites.ts`, `folders.ts`, `pages.ts`, `templates.ts`, `schemas.ts`, `workflow.ts`, `workflowActions.ts`, `field-variables.ts`, `updateFeatureFlag.ts`.
56+
57+
**Adding a new helper:**
58+
59+
1. Search `src/requests/` first — reuse an existing function if it covers your endpoint/payload.
60+
2. Do not duplicate the same API call in a spec, fixture, or another request file.
61+
3. If missing, add to the appropriate `src/requests/*.ts` file so all specs can reuse it.
62+
4. Multi-step orchestration → `fixtures/`; single-endpoint calls → `requests/`.
63+
6464
## Data & isolation
6565

66-
- Assume **empty starter** — create types/content via API in `beforeEach`, delete in `afterEach`; unique names (`testSuffix`, `Date.now()`, UUID).
66+
- Assume **empty starter** — create types/content via API helpers in `src/requests/` inside `beforeEach`, delete in `afterEach`; unique names (`testSuffix`, `Date.now()`, UUID).
6767
- Content types need **SystemWorkflow** for Save — see existing fixtures/requests.
6868
- **Relationships:** reuse `fixtures/relationship.fixture.ts` and `tests/edit-content/fields/relationship-field/`; do not invent payloads or cardinality numbers.
6969

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# E2E — dotCMS Playwright
22

3-
**Read [AGENTS.md](AGENTS.md)** — single source of truth for structure, commands, locators, and gotchas.
3+
**Humans:** start at [README.md](README.md). **Agents:** read [AGENTS.md](AGENTS.md) for code conventions, locators, and gotchas.

0 commit comments

Comments
 (0)