Skip to content

Commit ba1af4e

Browse files
authored
docs(ai-docs): playwright ai docs added (#623)
1 parent 7abee6e commit ba1af4e

11 files changed

Lines changed: 830 additions & 5 deletions

File tree

AGENTS.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
This is the main orchestrator for AI assistants working on this repository. It routes you to the correct templates and documentation based on the developer's task.
66

7-
**For every developer request:** (1) Identify task type (A–E below). (2) If the work is in an existing package or widget, load that scope's ai-docs (see [Package and widget ai-docs reference](#package-and-widget-ai-docs-reference)) and follow its AGENTS.md. (3) Open the template for that type and complete its mandatory pre-steps (see [Mandatory pre-steps by task type](#mandatory-pre-steps-by-task-type)). (4) Then follow the rest of this guide and the template.
7+
**For every developer request:** (1) Identify task type (A–F below). (2) If the work is in an existing package, widget, or test framework scope, load that scope's ai-docs (see [Package and widget ai-docs reference](#package-and-widget-ai-docs-reference)) and follow its AGENTS.md. (3) Open the template for that type and complete its mandatory pre-steps (see [Mandatory pre-steps by task type](#mandatory-pre-steps-by-task-type)). (4) Then follow the rest of this guide and the template.
88

99
---
1010

@@ -55,7 +55,13 @@ If the developer's message contains multiple distinct task types (for example, "
5555
**E. Understanding Architecture**
5656
- Developer needs to understand how something works
5757
- **Read:** That scope's `ai-docs/AGENTS.md` (usage) and `ai-docs/ARCHITECTURE.md` (technical details); use [Package and widget ai-docs reference](#package-and-widget-ai-docs-reference) to find the path.
58-
- **Available for:** station-login, user-state, store, cc-components, cc-widgets, ui-logging, test-fixtures; for task package use per-widget ai-docs (CallControl, IncomingTask, OutdialCall, TaskList).
58+
- **Available for:** station-login, user-state, store, cc-components, cc-widgets, ui-logging, test-fixtures, playwright; for task package use per-widget ai-docs (CallControl, IncomingTask, OutdialCall, TaskList).
59+
60+
**F. Playwright E2E Test Work**
61+
- Developer wants to add/update/stabilize Playwright tests, suites, sets, or test framework docs
62+
- **Route to:** [templates/playwright/00-master.md](./ai-docs/templates/playwright/00-master.md)
63+
- **Follow:** Playwright template workflow (pre-questions → implementation → validation)
64+
- **⚠️ MANDATORY FIRST STEP:** Complete pre-questions in [templates/playwright/01-pre-questions.md](./ai-docs/templates/playwright/01-pre-questions.md)
5965

6066
---
6167

@@ -169,6 +175,7 @@ Before generating or changing any code, you MUST complete the **pre-step section
169175
| **C. Add Feature** | [existing-widget/feature-enhancement.md](./ai-docs/templates/existing-widget/feature-enhancement.md) | [Pre-Enhancement Questions](./ai-docs/templates/existing-widget/feature-enhancement.md) (feature info, requirements, compatibility, design input) |
170176
| **D. Documentation only** | documentation templates | Optional: confirm scope with developer (no code change) |
171177
| **E. Understanding** | Package ai-docs | None (read-only) |
178+
| **F. Playwright E2E Test Work** | [playwright/00-master.md](./ai-docs/templates/playwright/00-master.md) | [Pre-Questions](./ai-docs/templates/playwright/01-pre-questions.md) (scope, scenarios, setup/utilities, stability expectations) |
172179

173180
---
174181

@@ -202,6 +209,7 @@ Before generating or changing any code, you MUST complete the **pre-step section
202209
| **cc-widgets** | [packages/contact-center/cc-widgets/ai-docs/AGENTS.md](packages/contact-center/cc-widgets/ai-docs/AGENTS.md) | Same folder |
203210
| **ui-logging** | [packages/contact-center/ui-logging/ai-docs/AGENTS.md](packages/contact-center/ui-logging/ai-docs/AGENTS.md) | Same folder |
204211
| **samples-cc-react-app** | [widgets-samples/cc/samples-cc-react-app/ai-docs/AGENTS.md](widgets-samples/cc/samples-cc-react-app/ai-docs/AGENTS.md) | Same folder if present |
212+
| **playwright framework** | [playwright/ai-docs/AGENTS.md](playwright/ai-docs/AGENTS.md) | [playwright/ai-docs/ARCHITECTURE.md](playwright/ai-docs/ARCHITECTURE.md) |
205213

206214
**Task package note:** The task package has multiple widgets (CallControl, IncomingTask, OutdialCall, TaskList). When working on one of them, use that widget's ai-docs path above, not a generic task path.
207215

@@ -212,6 +220,11 @@ Before generating or changing any code, you MUST complete the **pre-step section
212220
- Find available methods, events, types
213221
- Check method signatures before using
214222

223+
**If working on Playwright tests/framework:**
224+
- Read: `playwright/ai-docs/AGENTS.md`
225+
- Read: `playwright/ai-docs/ARCHITECTURE.md`
226+
- Use: `ai-docs/templates/playwright/00-master.md` and complete `01-pre-questions.md` before implementation
227+
215228
---
216229

217230
## Step 3: SDK API Consultation (Before Code Generation)
@@ -479,6 +492,11 @@ yarn build
479492
**If architecture changed:**
480493
- Update: Relevant architecture documentation as needed
481494

495+
**If Playwright E2E framework/docs changed:**
496+
- Update: `playwright/ai-docs/AGENTS.md`
497+
- Update: `playwright/ai-docs/ARCHITECTURE.md`
498+
- Update relevant modules in: `ai-docs/templates/playwright/`
499+
482500
---
483501

484502
## Step 7: Validation & Review

ai-docs/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ Widget (Observer) → Custom Hook (Business Logic) → Component (UI) → Store
176176

177177
**Repository Patterns:**
178178
- `ai-docs/patterns/` - TypeScript, MobX, React, Web Components, Testing patterns
179+
- `ai-docs/templates/` - Task templates (new widget, bug fix, feature enhancement, documentation, Playwright)
179180

180181
**Component Documentation:**
181182
- `packages/*/ai-docs/README.md` - API and usage
@@ -199,4 +200,4 @@ See [AGENTS.md](./AGENTS.md) for AI navigation guidance, task-based workflows, a
199200

200201
---
201202

202-
_Last Updated: 2025-11-23_
203+
_Last Updated: 2026-03-04_

ai-docs/templates/README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ Templates for generating and maintaining contact center widgets and components.
1010
templates/
1111
├── new-widget/ # Widget generation (7 modules)
1212
├── existing-widget/ # Bug fixes, features (2 modules)
13-
└── documentation/ # Documentation generation (2 modules, reusable for all packages)
13+
├── documentation/ # Documentation generation (2 modules, reusable for all packages)
14+
└── playwright/ # Playwright E2E templates
1415
```
1516

1617
## Templates
@@ -46,6 +47,17 @@ templates/
4647
- [create-agent-md.md](./documentation/create-agent-md.md) - Generate AGENTS.md
4748
- [create-architecture-md.md](./documentation/create-architecture-md.md) - Generate ARCHITECTURE.md
4849

50+
### 4. Playwright E2E Work
51+
52+
**Directory:** [playwright/](./playwright/)
53+
54+
**Modules:**
55+
- [00-master.md](./playwright/00-master.md) - Orchestrator and workflow
56+
- [01-pre-questions.md](./playwright/01-pre-questions.md) - Mandatory intake
57+
- [02-test-implementation.md](./playwright/02-test-implementation.md) - Suites/tests/sets implementation
58+
- [03-framework-and-doc-updates.md](./playwright/03-framework-and-doc-updates.md) - Shared framework/docs updates
59+
- [04-validation.md](./playwright/04-validation.md) - Validation checklist
60+
4961
---
5062

5163
## Usage
@@ -58,6 +70,8 @@ templates/
5870

5971
**Documentation Only:** Use [documentation/](./documentation/) templates
6072

73+
**Playwright E2E Work:** Start with [playwright/00-master.md](./playwright/00-master.md)
74+
6175
## Pattern References
6276

6377
- [TypeScript Patterns](../patterns/typescript-patterns.md)
@@ -68,4 +82,4 @@ templates/
6882

6983
---
7084

71-
_Last Updated: 2025-11-26_
85+
_Last Updated: 2026-03-04_
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Playwright Test Work - Master Template
2+
3+
## Purpose
4+
5+
Orchestrator for Playwright E2E work in this repository.
6+
7+
---
8+
9+
## Workflow
10+
11+
1. Gather complete requirements -> [01-pre-questions.md](./01-pre-questions.md)
12+
2. Implement tests/suites/sets -> [02-test-implementation.md](./02-test-implementation.md)
13+
3. Apply framework updates and documentation alignment -> [03-framework-and-doc-updates.md](./03-framework-and-doc-updates.md)
14+
4. Validate before completion -> [04-validation.md](./04-validation.md)
15+
16+
Doc alignment is mandatory when any suite/test/set/framework behavior changes.
17+
18+
---
19+
20+
## Task Types
21+
22+
Use one or more values from:
23+
24+
- `new_test_suite`
25+
- `new_test_file`
26+
- `add_scenarios_to_existing_test`
27+
- `update_existing_test_logic`
28+
- `stabilize_flaky_tests`
29+
- `add_or_update_user_set`
30+
- `add_or_update_utils`
31+
- `add_or_update_test_manager`
32+
- `add_or_update_constants`
33+
- `add_or_update_global_setup`
34+
- `update_playwright_docs`
35+
36+
---
37+
38+
## Current Set-to-Suite Mapping
39+
40+
Use `playwright/test-data.ts` as the source of truth for current set/suite mappings.
41+
42+
Guidance:
43+
- Read existing `USER_SETS` entries before proposing changes
44+
- Reuse an existing set when possible
45+
- Create a new set only when required by scenario isolation, credentials, or participant count
46+
- Keep set design generic so any scenario can be added via requirements intake
47+
48+
---
49+
50+
## Execution Guidance
51+
52+
- Always start with [01-pre-questions.md](./01-pre-questions.md).
53+
- Keep implementations aligned with current framework files (`playwright/suites`, `playwright/tests`, `playwright/Utils`, `playwright/test-manager.ts`, `playwright/test-data.ts`, `playwright/constants.ts`, `playwright/global.setup.ts`, `playwright.config.ts`).
54+
- For all test/suite/set/framework changes, update `playwright/ai-docs/AGENTS.md` and/or `playwright/ai-docs/ARCHITECTURE.md` as part of the same task.
55+
- End with [04-validation.md](./04-validation.md).
56+
57+
---
58+
59+
_Last Updated: 2026-03-05_
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Playwright Pre-Questions
2+
3+
## Purpose
4+
5+
Mandatory intake checklist to ensure the user provides complete implementation details before Playwright changes.
6+
7+
---
8+
9+
## Core Principles
10+
11+
### 1. Root Cause Analysis Over Symptomatic Fixes
12+
- **NEVER** increase timeouts as a first response to flaky tests
13+
- **ALWAYS** investigate WHY a test is failing before applying fixes
14+
- Timeouts mask underlying issues (race conditions, incorrect selectors, state leakage)
15+
- Document the specific reason if timeout increases are necessary
16+
17+
### 2. No Lazy Reasoning
18+
- **NEVER** assume "it probably works this way" - verify by reading code or testing
19+
- **NEVER** copy-paste patterns without understanding them
20+
- **NEVER** skip edge cases or error handling
21+
- **ALWAYS** ask clarifying questions when requirements are unclear
22+
23+
### 3. Timeout Justification Required
24+
- Default timeouts should be sufficient for most operations
25+
- When increasing timeouts, document:
26+
- What specific operation needs more time
27+
- Why this operation requires more time (measured/observed duration)
28+
- Why the operation cannot be optimized instead
29+
- Example GOOD reason: "Widget initialization requires loading external config (observed 15-20s in production)"
30+
- Example BAD reason: "Test was flaky, increased timeout to make it pass"
31+
32+
### 4. Requirements Gathering First
33+
- Use questionnaire-driven approach
34+
- Understand full scope before implementation
35+
- Identify edge cases and error scenarios upfront
36+
- Don't start coding until requirements are clear
37+
38+
---
39+
40+
## Required Questions
41+
42+
### 1. Task Scope
43+
44+
- What exactly should be changed? (one sentence)
45+
- Is this a new suite, new test, update, or flaky-test stabilization?
46+
- Which current suite is impacted? (`playwright/suites/*.spec.ts`)
47+
48+
### 2. Coverage Details
49+
50+
- Exact scenarios to add/update (list each scenario title)
51+
- Expected assertions for each scenario
52+
- Out-of-scope scenarios
53+
54+
### 3. Execution Target
55+
56+
- Which set(s) should run this? (`SET_1`..`SET_N` or new set)
57+
- If new set is needed:
58+
- What suite filename should `TEST_SUITE` map to?
59+
- How many agents are required? (1-4)
60+
- What entry points/queues/URLs are needed?
61+
62+
### 4. Data and Environment
63+
64+
- Required env keys (entry points, queue, chat URL, dial number, etc.)
65+
- How many agents are needed? (1-4)
66+
- Which roles are needed? (Agent1/Agent2/Agent3/Agent4/caller/extension/multi-session)
67+
- Any OAuth or token-related constraints?
68+
- Are there specific user credentials or permissions required?
69+
70+
### 5. Setup and Utilities
71+
72+
- Preferred `TestManager` setup method (if known)
73+
- Can existing `Utils/*` be reused, or is a new helper needed?
74+
75+
### 6. Stability Expectations
76+
77+
- Known flaky points today and their root causes (if known)
78+
- Have existing flaky tests been investigated for root cause?
79+
- Are there specific operations that legitimately require longer timeouts? (with justification)
80+
- What cleanup is required? (wrapup/end-state/agent cleanup)
81+
- Are there race conditions or state dependencies to address?
82+
83+
**Important:** If user mentions timeout issues:
84+
1. First investigate: console logs, network traces, application state
85+
2. Identify root cause: race condition? slow operation? incorrect selector?
86+
3. Fix root cause: add proper state checks, optimize operation, fix selector
87+
4. Only increase timeout if justified and documented
88+
89+
### 7. Documentation Expectations
90+
91+
- Should `playwright/ai-docs/AGENTS.md` be updated?
92+
- Should `playwright/ai-docs/ARCHITECTURE.md` be updated?
93+
94+
---
95+
96+
## Completion Gate
97+
98+
Do not start implementation until required questions are answered or explicitly assumed and documented.
99+
100+
---
101+
102+
_Last Updated: 2026-03-04_
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Playwright Test Implementation
2+
3+
## Purpose
4+
5+
Implement new or updated Playwright suites/tests/sets using current framework conventions.
6+
7+
---
8+
9+
## Implementation Paths
10+
11+
### A. New Suite
12+
13+
- Add `playwright/suites/<name>-tests.spec.ts`
14+
- Import one or more test factories from `playwright/tests/`
15+
- Wire `TEST_SUITE` in `playwright/test-data.ts`
16+
17+
### B. New Test File
18+
19+
- Add `playwright/tests/<feature>-test.spec.ts`
20+
- Export default factory: `create...Tests`
21+
- Register factory in target suite with `test.describe(...)`
22+
23+
### C. Update Existing Tests
24+
25+
- Update scenario logic in `playwright/tests/*.spec.ts`
26+
- Preserve existing factory export shape
27+
- Keep deterministic setup and cleanup
28+
29+
### D. Add/Update User Set
30+
31+
- Update `USER_SETS` in `playwright/test-data.ts`
32+
- Provide required set fields:
33+
- `AGENTS`
34+
- `QUEUE_NAME`
35+
- `CHAT_URL`
36+
- `EMAIL_ENTRY_POINT`
37+
- `ENTRY_POINT`
38+
- `TEST_SUITE`
39+
40+
---
41+
42+
## Required Patterns
43+
44+
- Use `TestManager` convenience setup methods when possible
45+
- Reuse `playwright/Utils/*.ts` before adding new helper logic
46+
- Use shared constants from `playwright/constants.ts`
47+
- Keep set-scoped env access via `${testManager.projectName}_...`
48+
- For flaky test fixes, record root cause and update docs if behavior/expectations changed
49+
50+
---
51+
52+
## Done Criteria
53+
54+
- [ ] Suite/test wiring complete
55+
- [ ] Set mapping correct (if changed)
56+
- [ ] Cleanup path present for new/changed scenarios
57+
- [ ] `playwright/ai-docs/AGENTS.md` baseline updated (if suites/sets/workflow changed)
58+
- [ ] `playwright/ai-docs/ARCHITECTURE.md` topology/mapping/runtime docs updated (if files/sets/framework behavior changed)
59+
- [ ] Fix/stabilization changes include a doc update loop when behavior or constraints changed
60+
61+
---
62+
63+
_Last Updated: 2026-03-05_
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Playwright Framework and Docs Updates
2+
3+
## Purpose
4+
5+
Apply shared framework updates and keep Playwright docs aligned in the same task.
6+
7+
---
8+
9+
## Framework Files
10+
11+
Update these as needed for reusable behavior changes:
12+
13+
- `playwright/Utils/*.ts`
14+
- `playwright/test-manager.ts`
15+
- `playwright/constants.ts`
16+
- `playwright/global.setup.ts`
17+
- `playwright.config.ts`
18+
19+
---
20+
21+
## Doc Files (Required Alignment)
22+
23+
- `playwright/ai-docs/AGENTS.md`
24+
- `playwright/ai-docs/ARCHITECTURE.md`
25+
26+
`playwright/ai-docs/ARCHITECTURE.md` is the single source of truth for framework internals and scenario-level technical reference.
27+
28+
If a task adds/changes suites, tests, sets, setup flows, runtime flags, or stability constraints, doc updates are mandatory.
29+
30+
---
31+
32+
## Checklist
33+
34+
- [ ] Shared changes are reusable and not test-case specific
35+
- [ ] Existing tests remain backward compatible or intentionally migrated
36+
- [ ] AGENTS baseline reflects current suites/sets/workflow
37+
- [ ] ARCHITECTURE topology/mapping/runtime sections match current code
38+
- [ ] No references to non-existent files/suites/sets
39+
40+
---
41+
42+
_Last Updated: 2026-03-05_

0 commit comments

Comments
 (0)