@zohodesk/testinglibrary 0.0.39-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 +9 -0
- package/build/core/playwright/constants/reporterConstants.js +0 -1
- package/build/core/playwright/report-generator.js +3 -22
- package/build/lib/cli.js +13 -21
- package/build/utils/commonUtils.js +12 -0
- package/npm-shrinkwrap.json +163 -104
- package/package.json +6 -7
- package/playwright.config.js +0 -2
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Step Definition Validator Agent
|
|
3
|
+
description: "Validate all generated step definition artifacts against style guides and produce a go/no-go report"
|
|
4
|
+
argument-hint: "<module name or list of created files>"
|
|
5
|
+
user-invocable: false
|
|
6
|
+
tools: ["read", "search"]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Step Definition Validator Agent
|
|
10
|
+
|
|
11
|
+
You perform the final cross-layer validation after all implementation phases are complete. Your job is to audit the generated code, not write it.
|
|
12
|
+
|
|
13
|
+
## Required Pre-reads (Single Source of Truth)
|
|
14
|
+
|
|
15
|
+
To perform your audit, you MUST evaluate the generated files strictly against the official checklists and anti-patterns defined in:
|
|
16
|
+
|
|
17
|
+
1. `.github/styleGuides/Steps_README.md` (Specifically Section 13: Anti-Patterns and Section 14: Checklist)
|
|
18
|
+
2. `.github/styleGuides/POM_README.md` (Specifically the Validation Checklist)
|
|
19
|
+
3. `.github/styleGuides/DomSelectors_README.md` (Specifically the Validation Checklist)
|
|
20
|
+
|
|
21
|
+
## Execution Protocol
|
|
22
|
+
|
|
23
|
+
### Step 1: Ingest & Map
|
|
24
|
+
|
|
25
|
+
Read all newly generated or updated files for the target feature. Map them to their architectural layer (`dom-selectors`, `page-object-model`, `steps`, `assertions`).
|
|
26
|
+
|
|
27
|
+
### Step 2: The Cross-Layer Audit
|
|
28
|
+
|
|
29
|
+
Cross-reference the generated files against the checklists in the Pre-reads. Pay special attention to these **High-Risk AI Failure Traps**:
|
|
30
|
+
|
|
31
|
+
- **Layer Bleed:** Raw locators sneaking into step files or POMs.
|
|
32
|
+
- **Layer Bleed:** Raw locators sneaking into step files or POMs.
|
|
33
|
+
- **Actionable Thens:** Clicks, fills, or navigations hiding inside `Then` steps.
|
|
34
|
+
- **Wait Violations:** The use of `page.waitForTimeout()` anywhere, or missing `element.waitFor()` calls before POM actions.
|
|
35
|
+
- **Class Contamination:** POMs using `class`, `this`, or `new` instead of the strict Factory Function pattern.
|
|
36
|
+
- **State Leaks:** Using module-level variables or `process.env` instead of the scenario-scoped `cacheLayer`.
|
|
37
|
+
- **Rogue Expectations:** Using native Playwright `expect()` calls instead of the centralized `_assertion/Assertion.js` methods (unless no matching central method exists).
|
|
38
|
+
|
|
39
|
+
### Step 3: Feature File Coverage Check
|
|
40
|
+
|
|
41
|
+
Verify that every `Given`/`When`/`Then` step in the source `.feature` file has a matching, executed step definition. Flag any missing or orphaned steps.
|
|
42
|
+
|
|
43
|
+
### Step 4: Output Generation
|
|
44
|
+
|
|
45
|
+
Generate a final "Go/No-Go" validation summary.
|
|
46
|
+
|
|
47
|
+
- **If GO:** Output a brief success message confirming all layers passed the strict framework rules.
|
|
48
|
+
|
|
49
|
+
- **If NO-GO:** Output a bulleted list of the specific files and line numbers that violated the rules, citing the exact rule they broke from the READMEs.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Assertion Creator Agent
|
|
3
|
+
description: "Create module assertion files when Then-step validation logic is reused across 2+ spec files"
|
|
4
|
+
argument-hint: "<assertion gap list from Feature File Analyzer>"
|
|
5
|
+
user-invocable: false
|
|
6
|
+
tools: ["read", "search", "edit"]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Assertion Creator Agent
|
|
10
|
+
|
|
11
|
+
You implement Phase 4: create assertion files in the module's `assertions/` folder, but only when required.
|
|
12
|
+
|
|
13
|
+
## Required Pre-reads (Your Single Source of Truth)
|
|
14
|
+
|
|
15
|
+
Before generating any code, you MUST read and strictly follow the rules and file patterns defined in:
|
|
16
|
+
1. `.github/instructions/assertions.instructions.md`
|
|
17
|
+
2. `.github/styleGuides/POM_README.md` — Rule 5 (for placement decisions)
|
|
18
|
+
3. `.github/styleGuides/Steps_README.md` — §4 (for the list of available central Assertion methods)
|
|
19
|
+
|
|
20
|
+
## Execution Protocol
|
|
21
|
+
|
|
22
|
+
### Step 1: Evaluate & Decide
|
|
23
|
+
|
|
24
|
+
Evaluate the `<assertion gap list>`. Apply the "Decision Rule" found in `POM_README.md` (Rule 5) to determine if an extraction to the `assertions/` folder is actually required (i.e., the exact same validation occurs in 2+ spec files).
|
|
25
|
+
* If it is only used once, DO NOT create a file. Instruct the Step Definition Writer to keep it inline.
|
|
26
|
+
|
|
27
|
+
### Step 2: Method Mapping (The Central Library Check)
|
|
28
|
+
|
|
29
|
+
If a new module assertion file is needed, you MUST build its functions using the centralized `modules/_assertion/Assertion.js` library.
|
|
30
|
+
|
|
31
|
+
1. Check Section 4 of `Steps_README.md` for the available `Assertions.*` methods.
|
|
32
|
+
2. If a matching method exists (e.g., `isElementVisible`), you must use it.
|
|
33
|
+
3. If, and ONLY if, the central library lacks a specific comparison (e.g., a complex regex or boolean check), you may fall back to using Playwright's native `expect()`.
|
|
34
|
+
|
|
35
|
+
### Step 3: File Generation
|
|
36
|
+
|
|
37
|
+
Generate the file using the exact "File Pattern" template provided in `assertions.instructions.md`.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: POM Creator Agent
|
|
3
|
+
description: "Create or update Page Object Model factory functions in page-object-model/"
|
|
4
|
+
argument-hint: "<POM method plan from the Orchestrator>"
|
|
5
|
+
user-invocable: false
|
|
6
|
+
tools: ["read", "search", "edit"]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# POM Creator Agent
|
|
10
|
+
|
|
11
|
+
You implement Phase 2: create or update POM factory function files in the module's `page-object-model/` folder.
|
|
12
|
+
|
|
13
|
+
## Required Pre-reads (Single Source of Truth)
|
|
14
|
+
|
|
15
|
+
Before generating or updating any code, you MUST read and strictly follow the architectural rules and file patterns defined in:
|
|
16
|
+
|
|
17
|
+
1. `.github/instructions/pom-files.instructions.md`
|
|
18
|
+
2. `.github/styleGuides/POM_README.md`
|
|
19
|
+
3. `.github/styleGuides/DomSelectors_README.md`
|
|
20
|
+
|
|
21
|
+
## Inputs
|
|
22
|
+
|
|
23
|
+
- POM method plan (file names, method signatures, required context properties from the Orchestrator's Checkpoint B)
|
|
24
|
+
- Selector files created in Phase 1 (import from `../dom-selectors/`)
|
|
25
|
+
|
|
26
|
+
## Execution Protocol
|
|
27
|
+
|
|
28
|
+
### Step 1: Analyze Inputs
|
|
29
|
+
|
|
30
|
+
Evaluate the POM method plan to determine which factory functions and specific UI interaction methods need to be created or updated.
|
|
31
|
+
|
|
32
|
+
### Step 2: Apply Patterns
|
|
33
|
+
|
|
34
|
+
Generate the code using the exact "Factory Function Pattern" provided in `pom-files.instructions.md`. Ensure you are correctly importing the fresh locator keys generated during Phase 1.
|
|
35
|
+
|
|
36
|
+
### Step 3: Enforce Strict Rules
|
|
37
|
+
|
|
38
|
+
As you write the code, continuously check your work against the "Rules" found in `POM_README.md`. Pay special attention to:
|
|
39
|
+
|
|
40
|
+
- **Explicit Waits:** Ensuring `element.waitFor()` or `page.waitForLoadState()` is called before executing actions.
|
|
41
|
+
- **No Assertions:** POMs must NEVER contain `expect()` or validations. They only read state, return values/locators, or perform actions.
|
|
42
|
+
- **No Classes:** Strictly adhere to the Factory Function pattern. Do not use `class`, `this`, or `new`.
|
|
43
|
+
|
|
44
|
+
### Step 4: Barrel Export
|
|
45
|
+
|
|
46
|
+
If a new POM file is created, you MUST update the module's `page-object-model/index.js` file to export the new factory function. This ensures the Step Definition Writer can import it cleanly.
|
|
47
|
+
|
|
48
|
+
### Step 5: Self-Audit
|
|
49
|
+
|
|
50
|
+
Before finalizing the file and returning control to the Orchestrator, review your newly written code against the constraints in Step 3. Fix any violations (like accidental assertions or missing waits) immediately.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Dom Selector Creator
|
|
3
|
+
description: "Create or update dom-selector files with selector constants"
|
|
4
|
+
argument-hint: "<selector gap list from Feature File Analyzer OR recorded selector bundle>"
|
|
5
|
+
user-invocable: false
|
|
6
|
+
tools: ["read", "search", "edit"]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Dom Selector Creator Agent
|
|
10
|
+
|
|
11
|
+
You implement Phase 1: create or update selector files in the module's `dom-selectors/` folder.
|
|
12
|
+
|
|
13
|
+
## Required Pre-reads (Single Source of Truth)
|
|
14
|
+
Before generating or updating any code, you MUST read and strictly follow the coding rules and file patterns defined in:
|
|
15
|
+
|
|
16
|
+
1. `.github/instructions/dom-selectors.instructions.md`
|
|
17
|
+
2. `.github/styleGuides/DomSelectors_README.md` — all selector rules
|
|
18
|
+
|
|
19
|
+
## Inputs
|
|
20
|
+
|
|
21
|
+
- Selector gap list from Feature File Analyzer, or
|
|
22
|
+
- Recorded selector bundle from Playwright MCP recording stage
|
|
23
|
+
- Target module path (e.g., `test-slices/uat/modules/Ticket/`)
|
|
24
|
+
|
|
25
|
+
## Execution Protocol
|
|
26
|
+
|
|
27
|
+
### Step 1: Process Inputs
|
|
28
|
+
|
|
29
|
+
Determine your input mode and process the selectors accordingly:
|
|
30
|
+
|
|
31
|
+
* **Mode A (Analyzer-first):** Use selector gaps from feature analysis as the source.
|
|
32
|
+
* **Mode B (Recorder-first):** Use selector entries captured from the live UI. You must normalize
|
|
33
|
+
|
|
34
|
+
each entry before writing:
|
|
35
|
+
* Dedupe by selector value and semantic key intent.
|
|
36
|
+
* Reject or flag weak selectors that rely on index/order (`nth-child`, `.first()`, `.last()`).
|
|
37
|
+
|
|
38
|
+
### Step 2: Apply Patterns & Rules
|
|
39
|
+
Generate or update the selector file using the exact "File Format" template provided in `dom-selectors.instructions.md`.
|
|
40
|
+
|
|
41
|
+
* **Strict Compliance:** Ensure you follow the specific casing rules (`SCREAMING_SNAKE_CASE` vs `camelCase`) and the stability order preferences defined in the instruction file.
|
|
42
|
+
|
|
43
|
+
* **Append, Don't Overwrite:** If a selector file already exists for this UI responsibility, append new selectors to it. Do NOT create a duplicate file.
|
|
44
|
+
|
|
45
|
+
### Step 3: Output Generation
|
|
46
|
+
1. Save the updated selector file(s) in the module's `dom-selectors/` directory.
|
|
47
|
+
2. Provide a brief summary of added keys, deduped keys, and weak selectors (if any) that required flagging.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Playwright MCP Selector Recorder Agent
|
|
3
|
+
description: "Reuse valid locators from existing dom-selectors first; if missing or stale, use Playwright MCP to inspect the UI and capture stable selector candidates for dom-selectors files"
|
|
4
|
+
argument-hint: "<module path + page list + login mode (fresh|reuse)>"
|
|
5
|
+
user-invocable: false
|
|
6
|
+
tools: [execute/runInTerminal, read, agent, edit, search, web, browser, 'playwright-test/*', todo]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Playwright MCP Selector Recorder Agent
|
|
10
|
+
|
|
11
|
+
You implement the interactive UI selector capture phase. You act as the eyes of the AI pipeline when static code analysis is insufficient.
|
|
12
|
+
|
|
13
|
+
## Required Pre-reads (Single Source of Truth)
|
|
14
|
+
|
|
15
|
+
Before inspecting the UI, you MUST read and understand the selector stability rules defined in:
|
|
16
|
+
|
|
17
|
+
1. `.github/styleGuides/DomSelectors_README.md` (Specifically the Validation Checklist for stable selector types)
|
|
18
|
+
2. `.github/copilot-instructions.md` — project structure and BDD layering
|
|
19
|
+
3. `test-slices/fixtures/auth.setup.js` — auth flow entrypoint
|
|
20
|
+
4. `test-slices/fixtures/accountLogin.js` — credential-based login behavior
|
|
21
|
+
5. `test-slices/**/conf/default/settings.json` — to retrieve the target domain/base URL for the environment.
|
|
22
|
+
|
|
23
|
+
### 🛑 Directory Exclusion Rules
|
|
24
|
+
|
|
25
|
+
When using search tools to analyze the codebase, find existing locators, or map out file structures, you MUST strictly ignore and exclude the `test-results/` and `playwright-report/` directories. These folders contain auto-generated traces and DOM snapshots, not source code. Searching them will cause hallucinations and waste execution time.
|
|
26
|
+
|
|
27
|
+
## Inputs
|
|
28
|
+
- Target module path
|
|
29
|
+
- Target pages/flows to inspect
|
|
30
|
+
- Login mode (Always execute a `fresh` login)
|
|
31
|
+
- Output target path for recorded bundle JSON
|
|
32
|
+
|
|
33
|
+
## Execution Protocol
|
|
34
|
+
|
|
35
|
+
### Step 1: Pre-Check (Avoid Duplication)
|
|
36
|
+
|
|
37
|
+
First, inspect the existing `dom-selectors/` file for the target module/page. Cross-reference the required elements for the feature against the existing selector keys.
|
|
38
|
+
|
|
39
|
+
- **If ALL required locators are found and valid:** Flag them for reuse, completely SKIP Steps 2 and 3, and proceed immediately to Step 4.
|
|
40
|
+
|
|
41
|
+
- **If ANY required locator is missing, stale, or you are unsure:** You MUST immediately proceed to Step 2 to trigger the Playwright MCP for those specific missing elements.
|
|
42
|
+
|
|
43
|
+
### Step 2: Pre-Flight Check (MCP Health & Recovery)
|
|
44
|
+
|
|
45
|
+
If Step 1 dictates that live UI inspection is required, you MUST verify the Playwright MCP server status before proceeding. If your connection attempt fails, times out, or reports that "browser-inspection tooling is not exposed", do NOT fallback to static analysis. Instead, execute the following recovery protocol:
|
|
46
|
+
|
|
47
|
+
1. **Verify Installation:** Use your terminal/shell execution tools to check if the `@playwright/mcp` package is installed and registered in the current environment.
|
|
48
|
+
|
|
49
|
+
2. **If Not Installed:** IMMEDIATELY STOP. Inform the developer that the Playwright MCP tool is missing.Ask Developer to Install the MCP server and ensure it is running before retrying.
|
|
50
|
+
|
|
51
|
+
4. **Resume Execution:** Only once the MCP server is actively running and connected to your toolset, proceed to Step 3.
|
|
52
|
+
|
|
53
|
+
### Step 3: Authentication & Navigation (Only if MCP is needed)
|
|
54
|
+
|
|
55
|
+
1. Read the target domain value from the `settings.json` file.
|
|
56
|
+
2. Utilize the provided login mode and auth fixtures to authenticate the Playwright MCP session against that specific domain.
|
|
57
|
+
3. Navigate to the target pages where the missing selectors live.
|
|
58
|
+
|
|
59
|
+
### Step 4: MCP UI Inspection (Only for missing/stale locators)
|
|
60
|
+
|
|
61
|
+
Invoke Playwright MCP to inspect the live DOM and capture the missing or stale locators identified in Step 1.
|
|
62
|
+
|
|
63
|
+
- You MUST strictly follow the selector priority hierarchy (e.g., `data-test-id` > `data-id`) defined in `DomSelectors_README.md`.
|
|
64
|
+
|
|
65
|
+
- Avoid brittle selectors that depend on DOM order (`nth-child`), position, or deep CSS ancestry.
|
|
66
|
+
|
|
67
|
+
### Step 5: Output Generation
|
|
68
|
+
|
|
69
|
+
Generate a normalized JSON bundle containing the captured context (combining the reused selectors from Step 1 and the freshly captured selectors from Step 4). Use the exact schema below so the Orchestrator can parse it:
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"module": "ModuleName",
|
|
74
|
+
"pages": [
|
|
75
|
+
{
|
|
76
|
+
"pageName": "TargetPageOrPanel",
|
|
77
|
+
"selectors": [
|
|
78
|
+
{
|
|
79
|
+
"semanticPurpose": "submit form button",
|
|
80
|
+
"selectorValue": "[data-test-id=\"submit-btn\"]",
|
|
81
|
+
"selectorType": "static",
|
|
82
|
+
"sourceElementAttributes": ["data-test-id"],
|
|
83
|
+
"confidenceScore": "high"
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Step 6: Handoff to Orchestrator
|
|
92
|
+
|
|
93
|
+
1. Save the JSON bundle to the designated workspace file.
|
|
94
|
+
|
|
95
|
+
2. Return control to the Step Definition Orchestrator.
|
|
96
|
+
|
|
97
|
+
3. Explicitly report any weak selectors (confidenceScore=low) in your return message so the Orchestrator can present them to the developer for Checkpoint A approval.
|
|
98
|
+
|
|
99
|
+
4. DO NOT pass data directly to the Dom Selector Creator.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Step Definition Writer Agent
|
|
3
|
+
description: "Write BDD step definition .spec.js files using Given/When/Then wired to POM factory functions"
|
|
4
|
+
argument-hint: "<BDD wiring plan from the Orchestrator>"
|
|
5
|
+
user-invocable: false
|
|
6
|
+
tools: [read, edit, search]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Step Definition Writer Agent
|
|
10
|
+
|
|
11
|
+
You implement Phase 3: write step definition files in the module's `steps/` folder.
|
|
12
|
+
|
|
13
|
+
## Required Pre-reads (Single Source of Truth)
|
|
14
|
+
Before generating any code, you MUST read and strictly follow the architectural rules and file patterns defined in:
|
|
15
|
+
1. `.github/instructions/step-definitions.instructions.md`
|
|
16
|
+
2. `.github/styleGuides/Steps_README.md` — all step definition rules
|
|
17
|
+
|
|
18
|
+
## Inputs
|
|
19
|
+
|
|
20
|
+
- BDD wiring plan (from the Orchestrator's Checkpoint B)
|
|
21
|
+
- POM method map (step → POM factory → method name)
|
|
22
|
+
- Target module path
|
|
23
|
+
|
|
24
|
+
## Execution Protocol
|
|
25
|
+
|
|
26
|
+
### Step 1: Deduplication Check
|
|
27
|
+
|
|
28
|
+
Before writing a new step, use your search tools to check if the exact Given/When/Then text already exists in the workspace's `steps/` directory.
|
|
29
|
+
|
|
30
|
+
- If the step already exists globally → reuse it. Do NOT write a duplicate.
|
|
31
|
+
- If the step does not exist → proceed to Step 2.
|
|
32
|
+
|
|
33
|
+
### Step 2: Analyze Inputs
|
|
34
|
+
|
|
35
|
+
Map the incoming Gherkin steps to the appropriate POM factory functions and methods provided in the Orchestrator's input map.
|
|
36
|
+
|
|
37
|
+
### Step 3: Apply Patterns & Write
|
|
38
|
+
|
|
39
|
+
Generate the `.spec.js` file using the exact "Standard File Structure" provided in `step-definitions.instructions.md`.
|
|
40
|
+
|
|
41
|
+
### Step 4: Enforce Strict Rules
|
|
42
|
+
|
|
43
|
+
As you write the code, you must strictly adhere to the "Step Rules". Pay special attention to these constraints:
|
|
44
|
+
|
|
45
|
+
- **Central Assertions:** If you write inline assertions inside a `Then` step, you MUST import and use `modules/_assertions/Assertions.js`. Do not use raw Playwright `expect()` unless a central method is missing.
|
|
46
|
+
|
|
47
|
+
- **Action-Free Thens:** Keep `Then` steps strictly for validations. No clicks, fills, or navigations.
|
|
48
|
+
|
|
49
|
+
- **No Branching:** Prevent any branching (`if/else`, `switch`) inside the step bodies.
|
|
50
|
+
|
|
51
|
+
- **Barrel Imports:** Import POMs from the module's barrel `../index`, NOT from deep file paths.
|
|
52
|
+
|
|
53
|
+
### Step 5: Self-Audit
|
|
54
|
+
|
|
55
|
+
Before finalizing the file and returning control to the Orchestrator, review your newly written code against the constraints in Step 4. Fix any violations immediately.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Step Definition Orchestrator
|
|
3
|
+
description: "End-to-end automatic step definition generator — from feature file to validated BDD artifacts"
|
|
4
|
+
argument-hint: "<path to .feature file or module name>"
|
|
5
|
+
user-invocable: true
|
|
6
|
+
tools: [execute, read, agent, edit, search, web, browser, 'playwright-test/*', todo]
|
|
7
|
+
agents:
|
|
8
|
+
[
|
|
9
|
+
"Playwright MCP Selector Recorder Agent",
|
|
10
|
+
"Dom Selector Creator",
|
|
11
|
+
"POM Creator Agent",
|
|
12
|
+
"Step Definition Writer Agent",
|
|
13
|
+
"Assertion Creator Agent",
|
|
14
|
+
"Step Definition Validator Agent"
|
|
15
|
+
]
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Step Definition Orchestrator
|
|
19
|
+
|
|
20
|
+
You are the Lead Coordinator for automatic step definition creation from a Gherkin feature file. You route tasks across 4 layers: dom-selectors → page-object-model → steps → assertions.
|
|
21
|
+
|
|
22
|
+
You operate in a strict **Recorder-first** mode:
|
|
23
|
+
|
|
24
|
+
If UI selectors cannot be found in the existing codebase, you MUST use the Playwright MCP to capture live selectors from the UI before allowing the POM or Step agents to generate code. You are strictly forbidden from guessing or hallucinating UI locators.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## Hard Gates
|
|
28
|
+
|
|
29
|
+
### Gate 1 — Context Discipline
|
|
30
|
+
You are the planner, not the coder. Do NOT load deep coding style guides into your context. Rely on your sub-agents to read their specific `instructions.md` files during their execution phases.
|
|
31
|
+
|
|
32
|
+
### Gate 2 — No File Creation Before Approval
|
|
33
|
+
Stop for developer approval at:
|
|
34
|
+
- **Checkpoint A (The Scope):** End of Stage 1 — confirm missing steps and UI scope.
|
|
35
|
+
- **Checkpoint B (The Blueprint):** End of Stage 2 — confirm file names, POM method names, and selector keys.
|
|
36
|
+
|
|
37
|
+
### Gate 3 — Scope Discipline
|
|
38
|
+
Only plan steps that explicitly exist in the provided feature file. Do not invent extra POM methods or selectors.
|
|
39
|
+
|
|
40
|
+
## Workflow Execution
|
|
41
|
+
|
|
42
|
+
### Stage 1: Analysis & Recording (Checkpoint A)
|
|
43
|
+
|
|
44
|
+
1. Read the provided `.feature` file.
|
|
45
|
+
|
|
46
|
+
2. **Path Resolution:** Use your search tools to quickly locate the exact file paths for the target module's `settings.json`, and the framework's `auth.setup.js` and `accountLogin.js` files.
|
|
47
|
+
|
|
48
|
+
3. Determine if UI selectors can be inferred from existing `dom-selectors` files. If not, invoke the **Playwright MCP Selector Recorder Agent**. You MUST pass it:
|
|
49
|
+
- The target module path.
|
|
50
|
+
- The target page list.
|
|
51
|
+
- The exact file paths you resolved in Step 2.
|
|
52
|
+
- Instructions to explicitly set the `login mode` to `fresh`.
|
|
53
|
+
|
|
54
|
+
4. Present the initial analysis (missing steps, captured selectors) to the developer.
|
|
55
|
+
*🛑 STOP FOR CHECKPOINT A APPROVAL*
|
|
56
|
+
|
|
57
|
+
### Stage 2: Implementation Plan (Checkpoint B)
|
|
58
|
+
Based on the approved Stage 1 analysis, produce a detailed file plan mapping out:
|
|
59
|
+
|
|
60
|
+
- **Step Deduplication:** Search existing `.spec.js` files. If a step already exists globally, flag it for reuse. Do NOT plan to create a duplicate step.
|
|
61
|
+
- Target `dom-selectors/` files and exact keys to add.
|
|
62
|
+
- Target `page-object-model/` files and method signatures.
|
|
63
|
+
- Target `steps/` files and the Given/When/Then orchestrations.
|
|
64
|
+
- Target `assertions/` files (if validations are reused).
|
|
65
|
+
*🛑 STOP FOR CHECKPOINT B APPROVAL*
|
|
66
|
+
|
|
67
|
+
### Stage 3: Execution via Agent Routing
|
|
68
|
+
Once Checkpoint B is approved, invoke your sub-agents strictly in this order, passing them the approved plan for their specific layer:
|
|
69
|
+
1. **Phase 1:** Invoke **Dom Selector Creator** (Pass the selector plan/bundle).
|
|
70
|
+
2. **Phase 2:** Invoke **POM Creator Agent** (Pass the POM method plan).
|
|
71
|
+
3. **Phase 3:** Invoke **Step Definition Writer Agent** (Pass the BDD wiring plan).
|
|
72
|
+
4. **Phase 4:** Invoke **Assertion Creator Agent** (Pass the assertion extraction plan, if any).
|
|
73
|
+
|
|
74
|
+
### Stage 4: Finalization & Audit
|
|
75
|
+
Invoke the **Step Definition Validator Agent** to perform a cross-layer validation on the newly generated files. Present the final go/no-go report and summary to the developer.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Copilot Instructions — Desk Client App Test Automation
|
|
2
|
+
|
|
3
|
+
## Project Overview
|
|
4
|
+
|
|
5
|
+
This is a **BDD test automation** project for Zoho Desk using **Playwright** and a custom Cucumber-based framework (`@zohodesk/testinglibrary`). Tests live under `jsapps/supportapp/test-slices/uat/modules/`.
|
|
6
|
+
|
|
7
|
+
## Core Framework
|
|
8
|
+
|
|
9
|
+
- **Library**: `@zohodesk/testinglibrary` — provides `createBdd()` which returns `{ Given, When, Then, And }`
|
|
10
|
+
- **All steps are async**: every browser interaction must be `await`ed
|
|
11
|
+
- **Page automation**: Playwright `page` object from context
|
|
12
|
+
|
|
13
|
+
## Module Folder Structure (Mandatory)
|
|
14
|
+
|
|
15
|
+
Every module must follow this hierarchy:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
modules/
|
|
19
|
+
<ModuleName>/
|
|
20
|
+
index.js # Barrel exports for the module
|
|
21
|
+
steps/
|
|
22
|
+
<FeatureName>.spec.js # Step definitions
|
|
23
|
+
feature-files/
|
|
24
|
+
<FeatureName>.feature # Gherkin scenarios
|
|
25
|
+
data-generators/
|
|
26
|
+
generators.json # Test data
|
|
27
|
+
page-object-model/
|
|
28
|
+
<PageName>.js # Page objects (factory functions)
|
|
29
|
+
index.js # POM barrel re-exports
|
|
30
|
+
assertions/
|
|
31
|
+
<ModuleName>Assertions.js # Module-specific assertions
|
|
32
|
+
dom-selectors/
|
|
33
|
+
<moduleName>Selectors.js # Centralized selector constants
|
|
34
|
+
utils/
|
|
35
|
+
<moduleName>Utils.js # Helper functions
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## File Naming Conventions
|
|
39
|
+
|
|
40
|
+
| Artifact | Convention | Example |
|
|
41
|
+
|-------------------|---------------------|------------------------------|
|
|
42
|
+
| Module folders | PascalCase | `Ticket/`, `CustomModule/` |
|
|
43
|
+
| Spec files | PascalCase `.spec.js` | `SetupNavigation.spec.js` |
|
|
44
|
+
| Feature files | PascalCase `.feature` | `TicketsCRUD.feature` |
|
|
45
|
+
| POM files | PascalCase `.js` | `TicketDetailView.js` |
|
|
46
|
+
| Assertion files | PascalCase + `Assertions` | `SetupAssertions.js` |
|
|
47
|
+
| Selector files | PascalCase + `Selectors` | `TicketSelectors.js` |
|
|
48
|
+
| Utility files | PascalCase + `Utils` | `TicketUtils.js` |
|
|
49
|
+
| Barrel files | `index.js` | `index.js` |
|
|
50
|
+
|
|
51
|
+
## Step Definition Rules
|
|
52
|
+
|
|
53
|
+
1. **Import pattern**: Always start with `import { createBdd } from '@zohodesk/testinglibrary'`
|
|
54
|
+
2. **Import order**: framework → cross-module → local POM (via barrel) → assertions → constants → BDD destructuring
|
|
55
|
+
3. **Given/When/Then separation**: Given = setup, When = action, Then = assertion only
|
|
56
|
+
4. **No branching logic** (`if/else`, `switch`, ternary) inside step bodies — delegates to POM
|
|
57
|
+
5. **Use `{string}` parameters** for dynamic values
|
|
58
|
+
6. **Context destructuring**: only destructure what you use (`page`, `i18N`, `getMetaInfo`, `cacheLayer`, `context`, `executionContext`, `actorContext`)
|
|
59
|
+
7. **Then steps are assertions only** — no clicks, fills, or navigation
|
|
60
|
+
8. **No hardcoded English strings** — use `i18N()` (async function, always await)
|
|
61
|
+
9. **No hardcoded locators** in step files — all DOM access via POM methods
|
|
62
|
+
10. **Use `cacheLayer`** for data sharing between steps (not globals or `process.env`)
|
|
63
|
+
|
|
64
|
+
## POM Rules
|
|
65
|
+
|
|
66
|
+
1. **Factory functions only** — no classes, `this`, `new`, or `constructor`
|
|
67
|
+
2. **One factory per page/panel** — destructure only needed context properties
|
|
68
|
+
3. **Keep assertions outside POM** — POMs return locators/values, never validate
|
|
69
|
+
4. **Import selectors from `dom-selectors/`** — no raw locators in POM methods
|
|
70
|
+
5. **Validate DOM readiness** with `waitFor()` before every action
|
|
71
|
+
6. **Use `i18N`** for all user-facing strings
|
|
72
|
+
7. **No arbitrary waits** — never use `page.waitForTimeout()`
|
|
73
|
+
8. **Export via barrel** — `page-object-model/index.js` re-exports all POMs
|
|
74
|
+
|
|
75
|
+
## Selector Rules
|
|
76
|
+
|
|
77
|
+
1. **Pure constants only** — no Playwright actions, assertions, or business logic
|
|
78
|
+
2. **SCREAMING_SNAKE_CASE** for static selectors, **camelCase** for builder helpers
|
|
79
|
+
3. **Prefer stable selectors**: `data-test-id` > `data-id` > `id` > `name` > ARIA > labels
|
|
80
|
+
4. **No duplication** of selector strings
|
|
81
|
+
5. **Step files never import selectors directly** — always access via POM
|
|
82
|
+
|
|
83
|
+
## Assertion Rules
|
|
84
|
+
|
|
85
|
+
1. **Use `Assertions` library** from `../../_assertions/Assertions`
|
|
86
|
+
2. **Module-specific assertions** in `assertions/<ModuleName>Assertions.js` when reused across 2+ spec files
|
|
87
|
+
3. **No assertions in POM files** — assertion files receive locators/values from POMs
|
|
88
|
+
4. **Prefer Playwright auto-waiting assertions** over plain JS comparison
|
|
89
|
+
|
|
90
|
+
## Style Guides
|
|
91
|
+
|
|
92
|
+
Detailed rules are in `.github/styleGuides/`:
|
|
93
|
+
- `Steps_README.md` — step definition patterns
|
|
94
|
+
- `POM_README.md` — page object model patterns
|
|
95
|
+
- `DomSelectors_README.md` — selector file patterns
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: "**/test-slices/**/assertions/*.js"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Assertions Layer
|
|
6
|
+
|
|
7
|
+
Module-level assertion files contain reusable validation helpers built by composing methods from the central `Assertion.js` library.
|
|
8
|
+
|
|
9
|
+
## File Pattern
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
// assertions/TicketAssertions.js
|
|
13
|
+
import Assertions from '../../_assertions/Assertions';
|
|
14
|
+
|
|
15
|
+
const TicketAssertions = {
|
|
16
|
+
async verifyTicketSubject(subjectElem, expectedSubject) {
|
|
17
|
+
await Assertions.isElementVisible(subjectElem);
|
|
18
|
+
await Assertions.isElementHaveText(subjectElem, expectedSubject);
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
async verifyCommentAuthored(authorElem, expectedName) {
|
|
22
|
+
await Assertions.isElementVisible(authorElem);
|
|
23
|
+
await Assertions.isElementContainText(authorElem, expectedName);
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default TicketAssertions;
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Strict Rules
|
|
31
|
+
|
|
32
|
+
- **No Actions:** Assertion files must never click, fill, or navigate.
|
|
33
|
+
|
|
34
|
+
- **No POM Imports:** Assertion files must never import POMs. They receive locators as arguments.
|
|
35
|
+
|
|
36
|
+
- **Central First:** Always prefer Assertions.* over raw expect().
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: "**/test-slices/**/dom-selectors/*.js"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Dom Selectors Layer
|
|
6
|
+
|
|
7
|
+
Selector files are the single source of truth for all raw locator strings. Nothing else.
|
|
8
|
+
|
|
9
|
+
## File Format
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
// dom-selectors/TicketSelectors.js
|
|
13
|
+
|
|
14
|
+
export const TicketSelectors = {
|
|
15
|
+
// Static — SCREAMING_SNAKE_CASE
|
|
16
|
+
COMMENT_INPUT: '[data-test-id="comment-input"]',
|
|
17
|
+
SAVE_COMMENT: '[data-test-id="save-comment-btn"]',
|
|
18
|
+
TICKET_ROW: '[data-id^="ticket_"]',
|
|
19
|
+
|
|
20
|
+
// Dynamic builder — camelCase arrow function
|
|
21
|
+
ticketRowById: (ticketId) => `[data-id="table_${ticketId}"]`,
|
|
22
|
+
ticketsByStatus: (status) => `[data-test-id="ticket-${status}"]`,
|
|
23
|
+
};
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Rules
|
|
27
|
+
|
|
28
|
+
- **Pure constants only** — no Playwright actions, assertions, waits, or business logic
|
|
29
|
+
- **SCREAMING_SNAKE_CASE** for static selector keys
|
|
30
|
+
- **camelCase** for dynamic builder helper functions
|
|
31
|
+
- **No duplication** of selector strings
|
|
32
|
+
- **Prefer stable selectors**: `data-test-id` > `data-id` > `id` > `name` > ARIA > labels
|
|
33
|
+
- **Step files never import selectors** — only POMs consume these files
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: "**/test-slices/**/page-object-model/*.js"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Page Object Model Layer
|
|
6
|
+
|
|
7
|
+
POM files contain all reusable UI interaction logic. Each file exports a single **factory function** (never a class).
|
|
8
|
+
|
|
9
|
+
## Factory Function Pattern
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
import { MySelectors } from '../dom-selectors/MySelectors';
|
|
13
|
+
|
|
14
|
+
const MyPagePOM = ({ page, i18N, getMetaInfo }) => {
|
|
15
|
+
// Getter — synchronous, returns Locator
|
|
16
|
+
const getSubmitButton = () => page.locator(MySelectors.SUBMIT_BTN);
|
|
17
|
+
|
|
18
|
+
// Action — async, waitFor() before every interaction
|
|
19
|
+
const clickSubmit = async () => {
|
|
20
|
+
const btn = getSubmitButton();
|
|
21
|
+
await btn.waitFor();
|
|
22
|
+
await btn.click();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// i18N usage
|
|
26
|
+
const getElementByLabel = async (labelKey) => {
|
|
27
|
+
const label = await i18N(labelKey);
|
|
28
|
+
return page.getByText(label, { exact: true });
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return { getSubmitButton, clickSubmit, getElementByLabel };
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { MyPagePOM };
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Rules
|
|
38
|
+
|
|
39
|
+
- **Factory functions only** — no classes, `this`, `new`, `constructor`
|
|
40
|
+
- **Destructure only needed context** from `({ page, i18N, getMetaInfo, cacheLayer, executionContext, actorContext })`
|
|
41
|
+
- **Import selectors** from `../dom-selectors/` — no raw locator strings
|
|
42
|
+
- **Getter methods** return Playwright Locators (synchronous, no `await`)
|
|
43
|
+
- **Action methods** are async with `await` on Playwright actions
|
|
44
|
+
- **DOM readiness**: call `element.waitFor()` before every action
|
|
45
|
+
- **Use `await i18N('key')`** for all user-facing strings
|
|
46
|
+
- **No assertions** — POMs return locators/values, never validate
|
|
47
|
+
- **No `page.waitForTimeout()`** — use element-based waits only
|
|
48
|
+
- **No `.first()` or `.last()`** for ambiguity — use unique identifiers
|