@zohodesk/testinglibrary 0.0.41-n20-experimental → 0.0.42-n20-experimental
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/agents/StepDefinitionValidator.agent.md +49 -0
- package/.github/agents/assertion-generator.agent.md +37 -0
- package/.github/agents/pom-generator.agent.md +50 -0
- package/.github/agents/selector-generator.agent.md +47 -0
- package/.github/agents/selector-recorder.agent.md +99 -0
- package/.github/agents/step-definition-generator.agent.md +55 -0
- package/.github/agents/steps-generation-orchestrator.agent.md +75 -0
- package/.github/copilot-instructions.md +95 -0
- package/.github/instructions/assertions.instructions.md +36 -0
- package/.github/instructions/dom-selectors.instructions.md +33 -0
- package/.github/instructions/pom-files.instructions.md +48 -0
- package/.github/instructions/step-definitions.instructions.md +44 -0
- package/.github/styleGuides/DomSelectors_README.md +72 -0
- package/.github/styleGuides/POM_README.md +602 -0
- package/.github/styleGuides/Steps_README.md +653 -0
- package/.vscode/mcp.json +1 -1
- package/build/core/playwright/constants/reporterConstants.js +0 -1
- package/build/core/playwright/report-generator.js +42 -0
- package/build/lib/cli.js +13 -29
- package/build/utils/commonUtils.js +3 -0
- package/npm-shrinkwrap.json +169 -106
- package/package.json +7 -8
- package/build/core/playwright/reporter/PlaywrightReporter.js +0 -44
- package/build/core/playwright/reporter/UnitReporter.js +0 -27
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: "**/test-slices/**/steps/*.spec.js"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Step Definitions Layer
|
|
6
|
+
|
|
7
|
+
BDD step definition files live in each module's `steps/` folder. They are the **thin wiring layer** between Gherkin feature files and POM factory functions.
|
|
8
|
+
|
|
9
|
+
## Standard File Structure
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
import { createBdd } from '@zohodesk/testinglibrary';
|
|
13
|
+
import { XyzPOM, AbcPOM } from '../index';
|
|
14
|
+
import Assertions from '../../_assertions/Assertions';
|
|
15
|
+
|
|
16
|
+
const { Given, When, Then } = createBdd();
|
|
17
|
+
|
|
18
|
+
Given('the user is in {string} department', async ({ page, i18N }, department) => {
|
|
19
|
+
// navigation / precondition only
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
When('the user clicks {string} button', async ({ page, i18N }, buttonLabel) => {
|
|
23
|
+
const pom = XyzPOM({ page, i18N });
|
|
24
|
+
await pom.clickButton(buttonLabel);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
Then('the {string} element should be visible', async ({ page, i18N }, label) => {
|
|
28
|
+
const pom = XyzPOM({ page, i18N });
|
|
29
|
+
const elem = await pom.getElement(label);
|
|
30
|
+
await Assertions.isElementVisible(elem);
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Step Rules
|
|
35
|
+
|
|
36
|
+
- **Given** = setup only (navigation, preconditions)
|
|
37
|
+
- **When** = user actions only (clicks, fills, submissions)
|
|
38
|
+
- **Then** = assertions ONLY (no clicks, fills, navigation)
|
|
39
|
+
- **No branching** (`if/else`, `switch`, ternary) in step bodies — delegate to POM
|
|
40
|
+
- Use `{string}` for dynamic values
|
|
41
|
+
- Destructure only needed context properties
|
|
42
|
+
- Use `await i18N('key')` for all user-facing strings
|
|
43
|
+
- Use `cacheLayer` for sharing data between steps
|
|
44
|
+
- All DOM access via POM methods — no raw selectors
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# DOM Selectors Structure Guide
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
This document describes the strict rules and naming conventions for selector files used in the `dom-selectors/` folder of each test module. Selector files are the **single source of truth** for all raw locator strings.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## What `dom-selectors/` Should Contain
|
|
11
|
+
|
|
12
|
+
Store selector constants and selector builder helpers here.
|
|
13
|
+
|
|
14
|
+
Examples:
|
|
15
|
+
|
|
16
|
+
- one file per major page, panel, or UI responsibility
|
|
17
|
+
- grouped selector constants exported as a single object
|
|
18
|
+
- selector builder helpers for dynamic locators
|
|
19
|
+
|
|
20
|
+
This keeps selector updates centralized and prevents raw locator strings from spreading across POM files and step files.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 1. Naming Conventions (Strict)
|
|
25
|
+
|
|
26
|
+
To ensure consistency across the framework, you must strictly adhere to these casing rules:
|
|
27
|
+
|
|
28
|
+
* **Files:** Must use **PascalCase** and end in `Selectors.js` (e.g., `TicketSelectors.js`).
|
|
29
|
+
* **Exported Object:** Must match the file name exactly in **PascalCase** (e.g., `export const TicketSelectors`).
|
|
30
|
+
* **Static Keys:** Must use **SCREAMING_SNAKE_CASE** (e.g., `COMMENT_INPUT: '[data-test-id="comment"]'`).
|
|
31
|
+
* **Dynamic Builder Functions:** Must use **camelCase** (e.g., `ticketRowById: (id) => ...`).
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 2. The Selector Priority Hierarchy (For UI Inspection)
|
|
36
|
+
|
|
37
|
+
When capturing live selectors (e.g., via Playwright MCP) or writing new ones, you MUST prefer stable identifiers in this exact order:
|
|
38
|
+
|
|
39
|
+
1. `data-test-id` (Highest Priority)
|
|
40
|
+
2. `data-id`
|
|
41
|
+
3. `id`
|
|
42
|
+
4. `name`
|
|
43
|
+
5. ARIA roles
|
|
44
|
+
6. Labels / Placeholders (Lowest acceptable)
|
|
45
|
+
|
|
46
|
+
**Absolutely Forbidden Selectors:**
|
|
47
|
+
|
|
48
|
+
- Deep, brittle CSS chains (`div > div > span > ul > li > a`).
|
|
49
|
+
- Index-based locators (`nth-child`, `.first()`, `.last()`) when a stable identifier is available.
|
|
50
|
+
- Selectors tied to text content that changes across locales/translations.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## 3. Architectural Isolation Rules
|
|
55
|
+
|
|
56
|
+
* **Rule 1: Keep it Pure.** Selector files must ONLY contain locator strings and dynamic locator functions. They must NEVER contain Playwright actions (`click()`), assertions (`expect()`), waits, or business logic.
|
|
57
|
+
|
|
58
|
+
* **Rule 2: No Duplication.** Never repeat the same raw selector string twice.
|
|
59
|
+
|
|
60
|
+
* **Rule 3: No Step File Imports.** Step files (`.spec.js`) are strictly forbidden from importing from `dom-selectors/`. The flow is always: **Step File → POM → Selector File**.
|
|
61
|
+
|
|
62
|
+
## Validation Checklist
|
|
63
|
+
*To be used by the Step Definition Validator Agent:*
|
|
64
|
+
|
|
65
|
+
1. [ ] Is the file placed in the correct `dom-selectors/` folder?
|
|
66
|
+
2. [ ] Does the file name and exported object use `PascalCase` (e.g., `TicketSelectors`)?
|
|
67
|
+
3. [ ] Are static keys `SCREAMING_SNAKE_CASE` and dynamic functions `camelCase`?
|
|
68
|
+
4. [ ] Are there ZERO Playwright actions, assertions, or `page.` calls in the file?
|
|
69
|
+
5. [ ] Are stable selectors (`data-test-id`) used instead of brittle DOM paths (`nth-child`)?
|
|
70
|
+
6. [ ] Is the framework free of Step files directly importing this selector file?
|
|
71
|
+
|
|
72
|
+
---
|