Added MSW handlers, mock fixtures, and Vitest+Playwright test harness for functional test migration#1532
Added MSW handlers, mock fixtures, and Vitest+Playwright test harness for functional test migration#1532carterworks wants to merge 8 commits into
Conversation
|
|
| Filename | Overview |
|---|---|
| packages/browser/test/integration/helpers/testsSetup/extend.js | Cookie cleanup added but misses s_ecid, which will leak between tests that call the new setSecidCookie() utility |
| packages/browser/test/integration/helpers/mswjs/handlers.js | Added acquireHandler for identity/acquire endpoint and updated sendEventHandler/setConsentHandler to support configId override suffix; consent response now reflects actual consent state passed in the request body |
| packages/browser/test/integration/helpers/utils/legacyCookies.js | New AMCV/s_ecid cookie helpers for ID-migration tests; getCookie handles both encoded and unencoded cookie names correctly |
| packages/browser/test/integration/helpers/alloy/clean.js | Added click-listener teardown to flush __alloyClickListeners tracked by the setupBaseCode monkeypatch |
| packages/browser/test/integration/helpers/alloy/setupBaseCode.js | Monkeypatches document.addEventListener once per page lifetime to record click listeners in __alloyClickListeners for cleanup; only tracks document-level handlers |
| packages/browser/test/integration/helpers/constants/consent.js | New constants for Adobe 1.0/2.0 and IAB TCF consent payloads used across consent integration tests |
| packages/browser/test/functional/specs/Personalization/C17409728.js | Fixed broken import paths for createDecorateProposition.js and initDomActionsModules.js after the Personalization component moved from core/src to browser/src |
| packages/browser/test/FUNCTIONAL_MIGRATION_PLAN.md | New migration plan document outlining TestCafe to Vitest+Playwright+MSW strategy, parity matrix, helper translation layer, and execution sequence |
Sequence Diagram
sequenceDiagram
participant Test as Integration Test
participant Ext as extend.js (alloy fixture)
participant SBC as setupBaseCode.js
participant MSW as MSW Worker
participant Handler as handlers.js
participant Edge as Edge Network (mocked)
Test->>Ext: fixture setup
Ext->>Ext: delete kndctr_/AMCV_ cookies
Ext->>SBC: setupBaseCode()
SBC->>SBC: monkeypatch document.addEventListener (once)
Ext->>Edge: setupAlloy() - identity/acquire
MSW->>Handler: acquireHandler intercepts
Handler-->>Edge: acquireResponse.json
Edge-->>Ext: alloy instance ready
Ext->>Test: use(alloy)
Test->>Edge: alloy commands
MSW->>Handler: sendEventHandler / setConsentHandler
Handler-->>Edge: fixture JSON
Edge-->>Test: response
Test->>Ext: teardown
Ext->>SBC: cleanAlloy()
Ext->>MSW: worker.resetHandlers()
Reviews (2): Last reviewed commit: "test(integration): add MSW handlers, moc..." | Re-trigger Greptile
…helpers for functional test migration
ba71e37 to
ee32880
Compare
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
carterworks has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
… CodeQL alert Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace the kndctr_/AMCV_ prefix allowlist with a generic clear-all so new cookie helpers (e.g. setSecidCookie) don't leak identity state into subsequent tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace document.cookie reads/writes in the integration test helpers with the async CookieStore API (cookieStore.set/get/getAll/delete). The set/get helpers and per-test cleanup are now async; delete-by-path removes the prior path-matching caveat. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Changed Packages
Description
Adds the shared infrastructure required by all subsequent integration test migration PRs: MSW request handlers, JSON mock response fixtures, updated test fixtures (
extend.js),legacyCookies.jsutility,consent.jsconstants, and the functional migration plan document. No functional test files are replaced by this PR — it is the foundation.Related Issue
Part of the functional test → integration test migration. See
packages/browser/test/FUNCTIONAL_MIGRATION_PLAN.md.Motivation and Context
The existing TestCafe functional test suite is being migrated to Vitest+Playwright+MSW to enable faster, more reliable CI testing without a running server. This PR is part of a stacked series — each PR migrates one test file.
Functional tests replaced:
Types of changes
Checklist:
Stack