Skip to content

test(calling): add Playwright E2E tests for SDK init and device registration#4799

Merged
eigengravy merged 6 commits intowebex:nextfrom
eigengravy:calling-sdk-e2e-tests-device-registration
Apr 16, 2026
Merged

test(calling): add Playwright E2E tests for SDK init and device registration#4799
eigengravy merged 6 commits intowebex:nextfrom
eigengravy:calling-sdk-e2e-tests-device-registration

Conversation

@eigengravy
Copy link
Copy Markdown
Member

@eigengravy eigengravy commented Mar 24, 2026

COMPLETES https://jira-eng-sjc12.cisco.com/jira/browse/CAI-7737

COMPLETES https://jira-eng-sjc12.cisco.com/jira/browse/CAI-7738

This pull request addresses

Playwright E2E tests for the Calling SDK covering SDK initialization and device registration flows, using a phased parallel execution architecture that runs 3 accounts across 3 parallel workers.

Architecture: Phased Parallel Execution

The test suite uses a phased parallel execution model to work within the constraint that the same Webex account must never be in two browsers simultaneously:

  • Phase 1 — OAuth: Fetch tokens for USER_1, USER_2, USER_3 accounts (dependency project, PROD + INT)
  • Phase 2 — Test Sets: 3 parallel workers (SET_1, SET_2, SET_3), each owning one account and running a subset of tests

Each phase fully completes before the next starts. Playwright project dependencies enforce ordering. Projects are generated dynamically from a USER_SETS config — each set gets a PROD and INT variant automatically.

Test Distribution Across Workers

Worker (Suite) Tests Pattern
SET_1 (set-1.spec.ts) SDK init (5 tests) + REG-001, 003, 008, 010, 011 SDK initialization, registration lifecycle, error flows
SET_2 (set-2.spec.ts) REG-006, 017, 007 Primary/backup failover & failback (chained shared context)
SET_3 (set-3.spec.ts) REG-004, 005, 015, 016 Keepalive & 429 retry flows (fresh context per test)

Changes

New test infrastructure

  • playwright.config.ts — Config with dynamic project generation from USER_SETS and phased dependencies
  • playwright/test-manager.ts — TestManager pattern (modeled after widgets) for shared browser context lifecycle
  • playwright/test-data.ts — Account/set definitions, token helpers, project name utilities
  • playwright/utils/registration.ts — Registration action helpers (register, unregister, status checks)
  • playwright/utils/setup.ts — SDK init helpers (navigation, init, discovery capture)
  • playwright/constants/ — Selectors, timeouts, Mobius URL constants

Test groups (shared logic, not spec files)

  • sdk-init.ts — SDK initialization: normal calling, contact center, guest calling, explicit region/country, negative case
  • registration-lifecycle.ts — Serial tests with shared browser via TestManager (REG-001, 003, 008, 010)
  • registration-failover.ts — Serial chained tests for failover/failback (REG-006 → REG-017 → REG-007)
  • registration-keepalive.ts — Fresh context per test for keepalive and 429 retry flows (REG-004, 005, 015, 016)
  • registration-errors.ts — Invalid token registration (REG-011)

Suite entry points (thin spec files)

  • suites/set-1.spec.ts — SDK init + registration lifecycle + errors
  • suites/set-2.spec.ts — Failover & failback
  • suites/set-3.spec.ts — Keepalive flows

OAuth setup

  • utils/oauth.setup.ts — Data-driven OAuth for all unique roles derived from USER_SETS

Techniques used

  • Playwright route interception to count/mock Mobius registration, keepalive, and delete requests
  • Response modification to shorten keepaliveInterval and rehomingInterval for faster test execution
  • context.setOffline(true/false) for network disruption simulation (REG-008)
  • page.evaluate() to read SDK internals (registration status, active Mobius URL, device info)
  • Route-based request counting to assert negative cases (no requests made) instead of long hard sleeps
  • Timestamp tracking to verify Retry-After backoff timing (REG-005, REG-015)

Test Cases

SET_1 — SDK Init + Registration Lifecycle + Errors (~8 min)

Test Approx Time Description
Normal Calling ~30s Init with calling service indicator, verify auto-discovery
Contact Center ~20s Init with contactcenter indicator and service domain
Guest Calling ~20s Generate guest token and init (prod-only, skipped on INT)
Region/Country ~30s Init with explicit region, verify discovery params and server regions
Negative (empty token) ~15s Empty token init blocked, no Mobius requests made, buttons stay disabled
REG-001 ~30s Initial registration success with primary Mobius server
REG-003 ~25s Keepalive requests sent after registration
REG-008 ~3 min Connection restoration re-registers when no active calls
REG-010 ~20s Deregistration success and cleanup
REG-011 ~30s Registration fails with invalid token (401)

SET_2 — Failover & Failback (~10 min)

Test Approx Time Description
REG-006 ~4 min Primary-to-backup failover on repeated 503 failure
REG-017 ~4 min 429 during failback exhausts retry budget, stays on backup
REG-007 ~2 min Failback to primary from backup

SET_3 — Keepalive & 429 Retry Flows (~12 min)

Test Approx Time Description
REG-004 ~3 min Keepalive 404 triggers deregister→register cycle, keepalive resumes
REG-005 ~2 min 429 Retry-After honored on keepalive (timing gap verified)
REG-015 ~3 min 429 on initial registration honors Retry-After before retrying
REG-016 ~4 min 429 with high Retry-After triggers immediate backup failover

Deferred

ID Description Reason
REG-009 Connection restoration deferred when active calls exist Blocked on CAI-7739 (call tests)

Total: 17 tests (5 SDK init + 12 registration) across 3 parallel workers. All 3 sets run concurrently, so wall-clock time is ~12 min (longest set).

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 - Claude Code
  • This PR is related to
    • Feature
    • Defect fix
    • Tech Debt
    • Automation

I certified that

  • I have read and followed contributing guidelines
  • I discussed changes with code owners prior to submitting this pull request
  • I have not skipped any automated checks
  • All existing and new tests passed
  • I have updated the documentation accordingly

@eigengravy eigengravy marked this pull request as ready for review March 30, 2026 11:43
@eigengravy eigengravy requested a review from a team as a code owner March 30, 2026 11:43
Copy link
Copy Markdown

@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: 7e077b36be

ℹ️ 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".

Comment thread playwright/tests/calling/01-sdk-initialization.spec.ts Outdated
Comment thread package.json Outdated
@eigengravy eigengravy force-pushed the calling-sdk-e2e-tests-device-registration branch from 7e077b3 to 3d3c22e Compare March 30, 2026 13:05
@eigengravy eigengravy changed the title test(calling): add device registration Playwright E2E tests (REG-001 to REG-014) test(calling): add device registration Playwright E2E tests (REG-001 to REG-013) Mar 30, 2026
Copy link
Copy Markdown

@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: 5da3dd4982

ℹ️ 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".

Comment thread packages/calling/playwright/test-data.ts
Copy link
Copy Markdown
Contributor

@Kesari3008 Kesari3008 left a comment

Choose a reason for hiding this comment

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

Partial review done, will finish rest tomorrow

Comment thread playwright/calling/suites/sdk-init.spec.ts Outdated
Comment thread playwright/calling/suites/set-transfer.spec.ts Outdated
Comment thread playwright/calling/test-groups/registration-lifecycle.ts Outdated
Comment thread packages/calling/playwright/test-groups/registration-lifecycle.ts
Comment thread playwright/calling/test-groups/registration-lifecycle.ts Outdated
Comment thread playwright/calling/test-groups/registration-lifecycle.ts Outdated
Comment thread packages/calling/playwright/test-groups/registration-lifecycle.ts Outdated
Comment thread playwright/calling/test-groups/registration-lifecycle.ts Outdated
Copy link
Copy Markdown

@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: d48b687df7

ℹ️ 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".

Comment thread packages/calling/playwright/test-groups/registration-errors.ts
Comment thread playwright/calling/utils/oauth.setup.ts Outdated
Copy link
Copy Markdown

@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: 38b3a1356f

ℹ️ 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".

Comment thread packages/calling/playwright/test-groups/registration-failover.ts
Comment thread packages/calling/playwright/test-groups/registration-errors.ts Outdated
Copy link
Copy Markdown

@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: 65bd83cd44

ℹ️ 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".

Comment thread playwright/calling/test-groups/registration-lifecycle.ts Outdated
Comment thread playwright/calling/test-groups/sdk-init.ts Outdated
Comment thread playwright/calling/suites/sdk-init.spec.ts Outdated
Comment thread packages/calling/playwright/test-groups/registration-failover.ts
Comment thread playwright/calling/utils/oauth.setup.ts Outdated
@eigengravy eigengravy force-pushed the calling-sdk-e2e-tests-device-registration branch from 65bd83c to 58cbe58 Compare April 9, 2026 03:27
@eigengravy eigengravy requested a review from a team as a code owner April 9, 2026 03:27
@eigengravy eigengravy changed the base branch from calling-sdk-e2e-tests to next April 9, 2026 03:27
@chatgpt-codex-connector
Copy link
Copy Markdown

💡 Codex Review

if (Object.values(CC_TASK_EVENTS).includes(payload.data.type || payload.type)) {

P1 Badge Avoid dereferencing payload.data for top-level socket events

registerTaskListeners now enters this block when payload.type is present, but it still reads payload.data.type directly. WebSocket messages like {"type":"AGENT_MULTI_LOGIN"} are valid in this codebase (see the WebSocketManager test fixture), so this path throws a TypeError when data is missing. Because WebSocketManager emits 'message' before running its own AGENT_MULTI_LOGIN close handling, this exception can short-circuit multi-login shutdown/cleanup instead of gracefully processing the event.


"test:e2e:prod": "npx playwright test --config=playwright.config.ts --project='Calling SDK E2E - PROD'",
"test:e2e:int": "npx playwright test --config=playwright.config.ts --project='Calling SDK E2E - INT'",

P2 Badge Point e2e scripts to existing Playwright project names

These new scripts reference --project='Calling SDK E2E - PROD' and --project='Calling SDK E2E - INT', but packages/calling/playwright.config.ts defines projects as OAuth, SET_1, SET_2, SET_3 and their - INT variants. As written, the prod/int convenience scripts won’t match any configured project and fail instead of running the intended subsets.

ℹ️ 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".

@eigengravy eigengravy force-pushed the calling-sdk-e2e-tests-device-registration branch from 58cbe58 to c14ff25 Compare April 9, 2026 03:43
Copy link
Copy Markdown

@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: c14ff25373

ℹ️ 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".

Comment thread packages/calling/playwright.config.ts Outdated
Comment thread packages/calling/playwright/test-groups/registration-errors.ts
Copy link
Copy Markdown
Contributor

@Kesari3008 Kesari3008 left a comment

Choose a reason for hiding this comment

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

Update to the latest branch

Comment thread packages/calling/playwright/test-groups/registration-lifecycle.ts Outdated
Comment thread packages/calling/playwright/test-groups/registration-lifecycle.ts Outdated
Comment thread packages/calling/playwright/suites/set-3.spec.ts
Comment thread packages/calling/playwright/test-groups/registration-errors.ts Outdated
Comment thread packages/calling/playwright/test-groups/registration-errors.ts Outdated
Comment thread packages/calling/playwright/test-groups/registration-failover.ts
Comment thread packages/calling/playwright/test-groups/sdk-init.ts
Comment thread packages/calling/playwright/test-groups/sdk-init.ts
- Add test-manager pattern with phased parallel execution
- Add registration lifecycle, failover, keepalive, and error test groups
- Add suite entry points (set-1, set-2, set-3) for parallel workers
- Add test-data with registration test case definitions
- Update playwright config for multi-project device registration testing
- Update oauth setup and registration utils for multi-account support
…neralize OAuth setup

- Replace hardcoded SET_1/2/3 and INT mirror projects with dynamic generation from USER_SETS
- Refactor OAuth setup to iterate unique account roles instead of hardcoded USER_1/2/3
- Update env separator logic to handle both PROD and INT suffixes
- Fix REG-001 assertion to use toBeGreaterThanOrEqual for registration count
- Add retry logic for isLineRegistered check in REG-010
…tration assertions

Move REG-012/013 negative cases into sdk-init as a single combined test,
remove REG-002 idempotent register test, and strengthen REG-001 to assert
exactly one registration POST.
@eigengravy eigengravy force-pushed the calling-sdk-e2e-tests-device-registration branch from 89da77b to 51a2db1 Compare April 13, 2026 05:49
@eigengravy eigengravy changed the title test(calling): add device registration Playwright E2E tests (REG-001 to REG-013) test(calling): add Playwright E2E tests for SDK init and device registration Apr 15, 2026
Copy link
Copy Markdown

@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: ff784e36c9

ℹ️ 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".

.locator('option:not([disabled])')
.evaluateAll((opts) => (opts as HTMLOptionElement[]).map((o) => o.value));

expect(optionValues).toEqual(['calling', 'contactcenter', 'guestcalling']);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Relax service indicator option assertion

setServiceIndicator() now fails unless the dropdown’s non-disabled options are exactly ['calling','contactcenter','guestcalling']. This makes every test that uses this helper break on benign UI changes (option reorder, new option, or feature-flagged extra option) even when selecting the requested service would still work, so the suite becomes brittle to unrelated sample-app updates.

Useful? React with 👍 / 👎.

const HIGH_RETRY_AFTER = 120; // Above RETRY_TIMER_UPPER_LIMIT (60s)
let primaryAttempts = 0;
let backupAttempts = 0;
const testStartTime = Date.now();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Measure REG-016 elapsed time from registration trigger

testStartTime is recorded before navigation and SDK initialization, but the final assertion compares total elapsed time against Retry-After (120s) to validate failover speed. In slower CI runs, page load/init overhead can consume most of that window and fail the test even if failover after the register click is immediate, creating false negatives unrelated to 429 handling.

Useful? React with 👍 / 👎.

@Kesari3008 Kesari3008 added the validated If the pull request is validated for automation. label Apr 15, 2026
Comment thread packages/calling/playwright/test-groups/sdk-init.ts Outdated
@Kesari3008
Copy link
Copy Markdown
Contributor

Ensure to add validated label in each PR else pipeline checks won't run

Copy link
Copy Markdown

@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: d4530671f0

ℹ️ 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".

Comment on lines +142 to +144
if (role === uniqueRoles[0]) {
throw new Error(
`${role}${envPrefix}_EMAIL and ${role}${envPrefix}_PASSWORD must be set in .env`
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Scope required OAuth credentials to selected projects

The OAuth setup hard-fails only on uniqueRoles[0] (currently USER_1) regardless of which Playwright project is being run, so targeted runs like --project='SET_2 - PROD' can fail before fetching USER_2 tokens if USER_1_* credentials are absent. This is a regression for project-level execution because SET_2/SET_3 are mapped to other roles in USER_SETS, yet the dependency gate still forces unrelated account credentials.

Useful? React with 👍 / 👎.

@eigengravy eigengravy merged commit 56c7775 into webex:next Apr 16, 2026
11 checks passed
@github-actions
Copy link
Copy Markdown

🎉 Your changes are now available!
Released in: v3.12.0-next.30
📖 View full changelog →
Packages Updated Version
webex 3.12.0-next.30
@webex/calling 3.12.0-next.16
@webex/contact-center 3.12.0-next.21

Thank you for your contribution!
🤖 This is an automated message. For queries, please contact support.

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

Labels

validated If the pull request is validated for automation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants