Skip to content

Commit 4314c38

Browse files
authored
Added the initial ADR document (#24627)
* Added ADR documents, in order to improve test code quality and consistency, which help * to document important test-related decisions with reasoning * to Improve long-term clarity and team alignment * to establish consistent guidelines how to write tests
1 parent 7618a23 commit 4314c38

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

e2e/adr/0001-aaa-test-structure.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Adopt Arrange–Act–Assert (AAA) Pattern for All Tests
2+
3+
## Status
4+
Proposed
5+
6+
## Context
7+
8+
Our tests are currently written in different styles, which makes them harder to read, understand, and maintain.
9+
10+
To improve **readability** and make it easier to **debug failing tests**, we want to standardize the structure of tests by following the well-known **Arrange–Act–Assert (AAA)** pattern.
11+
12+
## Decision
13+
14+
We will adopt the AAA pattern for tests. Every test should follow this structure:
15+
16+
1. **Arrange**: Set up data, mocks, page state, or environment
17+
2. **Act**: Perform the action being tested
18+
3. **Assert**: Check the expected outcome
19+
20+
## Guidelines
21+
22+
- ✅ Multiple actions and assertions are **allowed** as long as they belong to a **single AAA flow**
23+
- 🚫 **Repeating the full AAA structure in a single test is discouraged**, except for performance‑sensitive tests where setup cost is prohibitively high
24+
- ✂️ If a test involves multiple unrelated behaviors, **split it into separate test cases**
25+
- 🧼 Keep tests focused and predictable: one test = one scenario
26+
27+
## Example
28+
29+
```ts
30+
test('user can view their post', async ({ page }) => {
31+
// Arrange
32+
const user = await userFactory.create();
33+
const post = await postFactory.create({ userId: user.id });
34+
35+
// Act
36+
await page.goto(`/posts/${post.id}`);
37+
38+
// Assert
39+
await expect(page.getByText(post.title)).toBeVisible();
40+
});

e2e/adr/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Architecture Decision Records (ADRs)
2+
3+
This directory contains Architecture Decision Records (ADRs) specific to the E2E test suite.
4+
5+
ADRs are short, version-controlled documents that capture important architectural and process decisions, along with the reasoning behind them.
6+
They help document **why** something was decided — not just **what** was done — which improves transparency, consistency, and long-term maintainability.
7+
8+
Each ADR includes the following sections:
9+
10+
- `Status``Proposed`, `Accepted`, `Rejected`, etc.
11+
- `Context` – Why the decision was needed
12+
- `Decision` – What was decided and why
13+
- `Guidelines` – (Optional) How the decision should be applied
14+
- `Example` – (Optional) Minimal working example to clarify intent
15+
16+
## Guidelines for contributing
17+
18+
- We follow a simplified and slightly adapted version of the [Michael Nygard ADR format](https://github.com/joelparkerhenderson/architecture-decision-record/tree/main/locales/en/templates/decision-record-template-by-michael-nygard)
19+
- Keep ADRs focused, short, and scoped to one decision
20+
- Start with `Status: Proposed` and update to `Status: Accepted` after code review
21+
- Use sequential filenames with a descriptive slug, for example: `0002-page-objects-pattern.md`

0 commit comments

Comments
 (0)