Skip to content

docs(ai-docs): playwright ai docs added#623

Open
rsarika wants to merge 12 commits intowebex:nextfrom
rsarika:playright-spec
Open

docs(ai-docs): playwright ai docs added#623
rsarika wants to merge 12 commits intowebex:nextfrom
rsarika:playright-spec

Conversation

@rsarika
Copy link
Contributor

@rsarika rsarika commented Feb 17, 2026

COMPLETES #N/A (documentation update)

This pull request addresses

Playwright E2E documentation and agent routing were incomplete for contributors working in this monorepo. Specifically, root-level guidance did not consistently route developers/agents to Playwright ai-docs.

by making the following changes

  • Updated root /AGENTS.md to explicitly include Playwright in architecture understanding and documentation update flows.
  • Updated playwright/ai-docs/AGENTS.md with Playwright framework usage, setup patterns, utility guidance, and contributor-facing references.
  • Updated ai-docs/templates/Playright/playright-test-spec-generator.md to align with current framework constraints and conventions (including SET_7, current TestManager capacity, heading/style rules, and routing-sensitive naming guidance).

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling change
  • Internal code refactor

The following scenarios were tested

  • The testing is done with the amplify link
  • Executed yarn
  • Executed yarn run build
  • Pre-commit automated test hooks executed successfully during commit

The GAI Coding Policy And Copyright Annotation Best Practices

  • GAI was not used (or, no additional notation is required)
  • Code was generated entirely by GAI
  • GAI was used to create a draft that was subsequently customized or modified
  • Coder created a draft manually that was non-substantively modified by GAI (e.g., refactoring was performed by GAI on manually written code)
  • Tool used for AI assistance (GitHub Copilot / Other - specify)
    • Github Copilot
    • Other - Please Specify
  • This PR is related to
    • Feature
    • Defect fix
    • Tech Debt
    • Automation

Checklist before merging

  • I have not skipped any automated checks
  • All existing and new tests passed
  • I have updated the testing document
  • I have tested the functionality with amplify link

Make sure to have followed the contributing guidelines before submitting.

@rsarika rsarika changed the title docs(ai-docs): play right agents.md and spec generator added docs(ai-docs): playright agents.md and spec generator added Feb 17, 2026
@aws-amplify-us-east-2
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-623.d1b38q61t1z947.amplifyapp.com

@Shreyas281299
Copy link
Contributor

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. 👍

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Shreyas281299 Shreyas281299 added the validated Indicates that the PR is ready for actions label Mar 2, 2026
@rsarika rsarika requested a review from a team as a code owner March 4, 2026 04:56
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8b7aec5e5e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

}
```

All convenience methods (`basicSetup`, `setupForAdvancedTaskControls`, etc.) internally call `setup()` with pre-configured options.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Correct the claim that all setup helpers route through setup()

This statement is inaccurate for at least setupForStationLogin, which performs its own context/page initialization and does not call setup() in playwright/test-manager.ts. Contributors following this guidance may assume SetupConfig options and shared setup behavior apply uniformly to every helper, leading to incorrectly structured tests or missing setup/cleanup steps when using station-login flows.

Useful? React with 👍 / 👎.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2a910fbc16

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

CHAT_URL: `${env.PW_CHAT_URL}-e2e-7.html`,
EMAIL_ENTRY_POINT: `${env.PW_SANDBOX}.e2e7@gmail.com`,
ENTRY_POINT: env.PW_ENTRY_POINT7,
TEST_SUITE: 'conference-tests1.spec.ts',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Point conference sets to existing suite files

SET_7/SET_8/SET_9 are mapped to conference-tests1.spec.ts, conference-tests2.spec.ts, and conference-tests3.spec.ts, but there are no matching files under playwright/suites (repo-wide filename search returns none), so these projects will run with zero matched tests and silently skip the intended conference coverage while still incurring OAuth/setup work for those sets.

Useful? React with 👍 / 👎.

Copy link
Contributor

@ciscoRankush ciscoRankush left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of Playwright SDD docs — 8 items (M1–M8). All comments are inline on the relevant files.

The PR provides a decent template/workflow structure (the "how to work" part), but is very thin on actual framework documentation (the "how it works" part). An AI agent following this documentation would know the file layout and process to follow, but would not be able to write or modify tests without the missing technical reference.

The single playwright/ai-docs/ARCHITECTURE.md is the right place for all technical reference (M1–M7). The file would grow from ~140 to ~325 lines — reasonable for this scope.

- Runtime setup/teardown: `playwright/test-manager.ts`
- Shared operations: `playwright/Utils/*.ts`
- Shared constants/types/timeouts: `playwright/constants.ts`
- OAuth + env expansion: `playwright/global.setup.ts`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

M1: TestManager Class Documentation Missing

TestManager is 627 lines and is the single class every test file depends on. It gets one bullet here and one line in the data flow section. This is insufficient — an AI agent cannot write or modify tests without this.

Needs a dedicated ## TestManager section documenting:

1. Constructor:
new TestManager(projectName: string, maxRetries?: number)projectName is the SET key (e.g., 'SET_1'), used to resolve set-scoped env vars like ${projectName}_AGENT1_ACCESS_TOKEN.

2. SetupConfig interface — all 10 options and defaults:

interface SetupConfig {
  needsAgent1?: boolean;        // default: true
  needsAgent2?: boolean;        // default: false
  needsCaller?: boolean;        // default: false
  needsExtension?: boolean;     // default: false
  needsChat?: boolean;          // default: false
  needsMultiSession?: boolean;  // default: false
  agent1LoginMode?: LoginMode;  // default: 'Desktop'
  enableConsoleLogging?: boolean;  // default: true
  enableAdvancedLogging?: boolean; // default: false
  needDialNumberLogin?: boolean;   // default: false
}

3. Seven page properties available after setup:
agent1Page, agent2Page, callerPage, agent1ExtensionPage, chatPage, multiSessionAgent1Page, dialNumberPage

4. Convenience methods (method → config preset):
basicSetup(), setupForAdvancedTaskControls(), setupForAdvancedCombinations(), setupForDialNumber(), setupForStationLogin(), setupForIncomingTaskDesktop(), setupForIncomingTaskExtension(), setupForIncomingTaskMultiSession()

5. Cleanup:

  • softCleanup() — handles stray tasks only (between test files via afterAll)
  • cleanup() — full logout + close all pages/contexts (end of entire suite)

6. 3-phase parallel setup:
Phase 1: Create all browser contexts in parallel → Phase 2: Login + widget init in parallel for independent pages → Phase 3: Console logging setup

- Shared operations: `playwright/Utils/*.ts`
- Shared constants/types/timeouts: `playwright/constants.ts`
- OAuth + env expansion: `playwright/global.setup.ts`

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

M2: Utils Layer Documentation Missing

8 utility files with 50+ exported functions — none documented. This line says only playwright/Utils/*.ts.

Needs a ## Utils Reference section with at minimum:

File Key Exports Purpose
initUtils.ts loginViaAccessToken, oauthLogin, enableAllWidgets, initialiseWidgets, agentRelogin, setupMultiLoginPage Page bootstrap, widget initialization
stationLoginUtils.ts desktopLogin, extensionLogin, dialLogin, telephonyLogin, stationLogout, verifyLoginMode, ensureUserStateVisible Station login/logout for 3 modes (Desktop, Extension, Dial Number)
userStateUtils.ts changeUserState, getCurrentState, verifyCurrentState, getStateElapsedTime, validateConsoleStateChange, checkCallbackSequence Agent state management and verification
taskControlUtils.ts holdCallToggle, recordCallToggle, endTask, verifyHoldTimer, verifyHoldButtonIcon, verifyRecordButtonIcon, setupConsoleLogging, verifyHoldLogs, verifyRecordingLogs, verifyEndLogs, verifyRemoteAudioTracks Basic call controls + callback log verification
advancedTaskControlUtils.ts consultOrTransfer, cancelConsult, setupAdvancedConsoleLogging, verifyTransferSuccessLogs, verifyConsultStartSuccessLogs, verifyConsultEndSuccessLogs Transfer and consult operations
incomingTaskUtils.ts createCallTask, createChatTask, createEmailTask, acceptIncomingTask, declineIncomingTask, acceptExtensionCall, loginExtension, submitRonaPopup, waitForIncomingTask Task creation (call/chat/email), acceptance, RONA handling
wrapupUtils.ts submitWrapup Wrapup submission flow
helperUtils.ts handleStrayTasks, pageSetup, waitForState, waitForStateLogs, waitForWebSocketDisconnection, waitForWebSocketReconnection, clearPendingCallAndWrapup, dismissOverlays Cleanup, state polling, network monitoring, overlay dismissal

Without this, an AI agent will either duplicate existing logic or fabricate non-existent functions.

- Shared constants/types/timeouts: `playwright/constants.ts`
- OAuth + env expansion: `playwright/global.setup.ts`

---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

M3: Constants Documentation Missing

constants.ts defines every enum, type, and timeout used across tests — currently undocumented.

Key enums:

Constant Values Used For
USER_STATES MEETING, AVAILABLE, LUNCH (Lunch Break), RONA, ENGAGED, AGENT_DECLINED State change operations
LOGIN_MODE DESKTOP, EXTENSION, DIAL_NUMBER (Dial Number) Station login mode selection
PAGE_TYPES AGENT1, AGENT2, CALLER, EXTENSION, CHAT, MULTI_SESSION, DIAL_NUMBER TestManager page identification
TASK_TYPES CALL, CHAT, EMAIL, SOCIAL Incoming task type identification
WRAPUP_REASONS SALE, RESOLVED Wrapup submission
RONA_OPTIONS AVAILABLE, IDLE RONA popup state selection
CONSOLE_PATTERNS SDK_STATE_CHANGE_SUCCESS, ON_STATE_CHANGE_REGEX, ON_STATE_CHANGE_KEYWORDS Console log verification (see M4)

Timeout hierarchy (critical for choosing correct timeout per operation):

Constant Value Use Case
DROPDOWN_SETTLE_TIMEOUT 200ms Dropdown animation settle
UI_SETTLE_TIMEOUT 2s General UI settle after actions
DEFAULT_TIMEOUT 5s Default retry/check timeout
AWAIT_TIMEOUT 10s Standard element interaction
WRAPUP_TIMEOUT 15s Wrapup box visibility
FORM_FIELD_TIMEOUT 20s Form field / popover loading
OPERATION_TIMEOUT 30s Longer operations (logout verify)
EXTENSION_REGISTRATION_TIMEOUT 40s WebRTC extension registration
NETWORK_OPERATION_TIMEOUT 40s Network-dependent operations
WIDGET_INIT_TIMEOUT 50s Widget initialization
CHAT_LAUNCHER_TIMEOUT 60s Chat launcher iframe loading
ACCEPT_TASK_TIMEOUT 60s Waiting for incoming task

Without this, an agent will use arbitrary timeout values or wrong enum names.

Avoid documenting future sets or files before they exist.

---

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

M4: Console Log Verification Pattern Undocumented

The framework's primary assertion mechanism for verifying SDK behavior is console log monitoring — used across nearly every test file. Not documented anywhere.

How it works:

  1. Setup: setupConsoleLogging(page) or setupAdvancedConsoleLogging(page) registers a page.on('console', ...) handler that filters for specific SDK event strings.

  2. Captured events (basic controls):

    • WXCC_SDK_TASK_HOLD_SUCCESS / WXCC_SDK_TASK_RESUME_SUCCESS
    • WXCC_SDK_TASK_PAUSE_RECORDING_SUCCESS / WXCC_SDK_TASK_RESUME_RECORDING_SUCCESS
    • onHoldResume invoked / onRecordingToggle invoked / onEnd invoked
  3. Captured events (advanced controls):

    • WXCC_SDK_TASK_TRANSFER_SUCCESS / WXCC_SDK_TASK_CONSULT_START_SUCCESS / WXCC_SDK_TASK_CONSULT_END_SUCCESS
    • AgentConsultTransferred / onTransfer invoked / onConsult invoked
  4. Captured events (state changes):

    • WXCC_SDK_AGENT_STATE_CHANGE_SUCCESS
    • onStateChange invoked with state name: <stateName> (matched via CONSOLE_PATTERNS.ON_STATE_CHANGE_REGEX)
  5. Verification functions: verifyHoldLogs(), verifyRecordingLogs(), verifyEndLogs(), verifyTransferSuccessLogs(), verifyConsultStartSuccessLogs(), validateConsoleStateChange(), checkCallbackSequence()

  6. Sequence validation: checkCallbackSequence() verifies that SDK API success event appears in logs before the onStateChange callback.

This section should be added under a ## Console Log Verification Pattern heading. Without it, an AI agent writing new tests would not know how to verify SDK behavior and would write incomplete assertions.

├── test-data.ts
├── constants.ts
├── global.setup.ts
└── ai-docs/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

M5: Set → Suite → Test File Mapping Missing

The file topology lists suites and tests separately but doesn't show which test factories each suite imports. This is the critical wiring an agent needs to know where to add a new test.

Add a ## Set → Suite → Test Mapping section:

Set Suite File Test Files Imported
SET_1 digital-incoming-task-tests digital-incoming-task-and-task-controls + dial-number-task-control-test
SET_2 task-list-multi-session-tests incoming-task-and-controls-multi-session + tasklist-test
SET_3 station-login-user-state-tests station-login-test + user-state-test + incoming-telephony-task-test
SET_4 basic-advanced-task-controls-tests basic-task-controls-test + advance-task-control-combinations-test
SET_5 advanced-task-controls-tests advanced-task-controls-test
SET_6 dial-number-tests dial-number-task-control-test

Without this, an agent asked to 'add a new incoming task test' won't know it should go in SET_1's suite.

- workers: `Object.keys(USER_SETS).length`
- global timeout: `180000`
- per-project retries: `1`

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

M6: Sample App (SUT) Context Missing

The tests are testing CC widgets running inside samples-cc-react-app at localhost:3000. playwright.config.ts starts it via:

webServer: {
  command: 'yarn workspace samples-cc-react-app serve',
  url: 'http://localhost:3000',
}

This context is completely absent. An agent wouldn't know what the system under test actually is. Also missing: the Chrome launch flags critical for WebRTC testing:

  • --use-fake-ui-for-media-stream / --use-fake-device-for-media-stream — allows media access without real devices
  • --use-file-for-fake-audio-capture=dummyAudio.wav — provides fake audio input
  • --remote-debugging-port=${9221 + index} — unique debug port per set

Add a ## System Under Test paragraph in the Dynamic Project Generation section explaining what is actually being tested and how the browser is configured.


1. reads set-scoped env values using `testInfo.project.name`
2. creates required pages/contexts per setup config
3. performs login/widget initialization
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

M7: Factual Error — testInfo.project.name

This line says TestManager "reads set-scoped env values using testInfo.project.name".

Actually, TestManager constructor takes projectName: string directly:

constructor(projectName: string, maxRetries: number = DEFAULT_MAX_RETRIES)

Tests instantiate it as: new TestManager(test.info().project.name). The distinction matters — TestManager doesn't access testInfo at all; it receives the project name as a constructor argument.

Fix to: "TestManager receives the project name (SET key) via its constructor, which tests pass from test.info().project.name."


## Done Criteria

- [ ] Suite/test wiring complete
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

M8: Governance Gap — Doc Updates Not Enforced

This Done Criteria is missing mandatory doc update steps. Currently has 3 items, none mention AGENTS.md or ARCHITECTURE.md.

Should include:

  • - [ ] playwright/ai-docs/AGENTS.md baseline updated (if new suite/set added)
  • - [ ] playwright/ai-docs/ARCHITECTURE.md file topology and set mapping updated (if new files/sets added)

Also:

  • 03-framework-and-doc-updates.md says "update only if required" — should be mandatory in the 00-master workflow when adding new tests/suites/sets
  • 04-validation.md should explicitly check: - [ ] AGENTS.md baseline matches actual suites and - [ ] ARCHITECTURE.md file topology matches actual files
  • The PR description claims playwright/ai-docs/specs/multiparty-conference.spec.md was added — but this file is not in the diff. Either implement the specs/ concept or remove the claim.
  • When fixing/stabilizing tests, there's no guidance to update docs to reflect what changed — add a fix → doc-update loop.

@rsarika rsarika changed the title docs(ai-docs): playright agents.md and spec generator added docs(ai-docs): playwright ai docs added Mar 5, 2026
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 058e6ba657

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".


| Set | Suite File (`TEST_SUITE`) | Test Files Imported By Suite |
| --- | --- | --- |
| `SET_1` | `digital-incoming-task-tests.spec.ts` | `digital-incoming-task-and-task-controls.spec.ts`, `dial-number-task-control-test.spec.ts` |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Map SET_1 to actually wired test factories

This mapping lists dial-number-task-control-test.spec.ts under SET_1, but playwright/suites/digital-incoming-task-tests.spec.ts only registers createDigitalIncomingTaskAndTaskControlsTests via test.describe(...) and never wires the dial-number factory, so contributors using this table can add scenarios in the wrong file and silently miss coverage in SET_1. Please document the factories that are actually executed (or explicitly call out imported-but-unwired files).

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

validated Indicates that the PR is ready for actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants