Migrated Media Collection functional tests to Vitest+Playwright+MSW#1548
Migrated Media Collection functional tests to Vitest+Playwright+MSW#1548carterworks wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: 4366224 The changes in this PR will be included in the next version bump. This PR includes no changesetsWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
| Filename | Overview |
|---|---|
| packages/browser/test/integration/specs/MediaCollection/mediaCollection.spec.js | New Vitest+Playwright+MSW integration test replacing MA1/MA2/MA3 functional tests; MA1 correctly skipped, but MA3 drops media.chapterSkip coverage (swapped for media.sessionComplete) and the MA2 count assertion uses a broad URL pattern that could spuriously fail. |
Sequence Diagram
sequenceDiagram
participant Test
participant Alloy
participant MSW_interact as MSW /v1/interact (mediaSessionHandler)
participant MSW_va as MSW /va/v1/* (mediaEventHandler)
participant NetworkRecorder
Note over Test,NetworkRecorder: MA3 — non-automatic mode
Test->>Alloy: configure(streamingMediaConfig)
Test->>Alloy: createMediaSession(xdm)
Alloy->>MSW_interact: POST /ee/.../v1/interact (media.sessionStart)
MSW_interact-->>Alloy: 200 mediaSessionResponse.json (sessionId)
MSW_interact-->>NetworkRecorder: captureRequest / captureResponse
Alloy-->>Test: "{ sessionId }"
loop 14 sendMediaEvent calls
Test->>Alloy: sendMediaEvent(xdm)
Alloy->>MSW_va: "POST /ee/.../va/v1/<eventType>"
MSW_va-->>Alloy: 204
MSW_va-->>NetworkRecorder: captureRequest / captureResponse
end
Test->>NetworkRecorder: "findCalls(/\/va\//, { minCalls: 14 })"
NetworkRecorder-->>Test: 14 va calls
Note over Test,NetworkRecorder: MA2 — legacy getMediaAnalyticsTracker
Test->>Alloy: configure(streamingMediaConfig)
Test->>Alloy: getMediaAnalyticsTracker()
Alloy-->>Test: Media object
Test->>Alloy: tracker.trackSessionStart(mediaInfo, ctx)
Alloy->>MSW_interact: POST /ee/.../v1/interact (media.sessionStart)
MSW_interact-->>NetworkRecorder: captureRequest / captureResponse
Test->>NetworkRecorder: "findCalls(/edge\.adobedc\.net/) — expects length == 1"
Test->>Alloy: trackPlay() / trackPause() / trackComplete()
Alloy->>MSW_va: POST /va/ x3
MSW_va-->>NetworkRecorder: captureRequest / captureResponse
Test->>NetworkRecorder: "findCalls(/\/va\//, { minCalls: 3 })"
NetworkRecorder-->>Test: 3 va calls
Reviews (1): Last reviewed commit: "test(integration): migrate media collect..." | Re-trigger Greptile
| }, | ||
| }, | ||
| }); | ||
|
|
||
| // buffer start | ||
| await alloy("sendMediaEvent", { | ||
| xdm: { | ||
| eventType: "media.bufferStart", | ||
| mediaCollection: { playhead: 7, sessionID: sessionId }, | ||
| }, | ||
| }); | ||
|
|
||
| // bitrate change | ||
| await alloy("sendMediaEvent", { | ||
| xdm: { | ||
| eventType: "media.bitrateChange", | ||
| mediaCollection: { | ||
| playhead: 8, | ||
| sessionID: sessionId, | ||
| qoeDataDetails: { | ||
| framesPerSecond: 1, |
There was a problem hiding this comment.
media.chapterSkip event type missing from MA3 coverage
Both the original MA3 and MA1 functional tests explicitly covered media.chapterSkip. The new test swaps it out for media.sessionComplete, keeping the count at 14 and making the expect(vaCalls.length).toBe(14) assertion pass silently. A regression where media.chapterSkip fails to route to the /va/ endpoint would now go undetected — none of the non-skipped tests exercise it.
| "media.adBreakComplete", | ||
| "media.adSkip", | ||
| "media.error", | ||
| "media.bufferStart", | ||
| "media.bitrateChange", | ||
| "media.statesUpdate", | ||
| "media.sessionComplete", | ||
| ]; | ||
|
|
||
| for (const eventType of expectedEventTypes) { | ||
| const event = getEventFromCalls(vaCalls, eventType); |
There was a problem hiding this comment.
Broad URL pattern makes exact-count assertion fragile in MA2
findCalls(/edge\.adobedc\.net/) matches any call to the edge domain, not only the session-start /interact call. If Alloy ever emits an additional edge call between configure and trackSessionStart (e.g., an identity/acquire or collect call), sessionCalls.length would exceed 1 and the assertion would fail with an opaque message. Scoping the pattern to /v1/interact would make the intent explicit and shield the count check from unrelated edge traffic.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
3a08690 to
c919672
Compare
9ef9711 to
cdde625
Compare
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.
c919672 to
38ec073
Compare
cdde625 to
7ef7079
Compare
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.
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.
0b09255 to
3d67897
Compare
3d67897 to
8abb1ef
Compare
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
8abb1ef to
4366224
Compare
Integration Test Migration Review — MediaCollection (#16)Verdict: 🟡 Comment / Request Changes — two non-trivial assertion weakenings and a structural gap (no-ping invariant never migrated) need resolution before the functional files can be retired. Parity Matrix
1. Parity (🔴🟡)1a. MA3 —
|
| # | Finding | Severity | Blocking? |
|---|---|---|---|
| 1 | MA3 drops per-event sessionID assertion (non-env-forced) |
🔴 | Recommend fix |
| 2 | MA3 no-ping-automatic invariant entirely absent | 🔴 | Recommend fix or tracking issue |
| 3 | MA2 coverage drops from 17 to 3 event assertions | 🔴 | Recommend fix |
| 4 | media.chapterSkip dropped without comment |
🟡 | Restore or document |
| 5 | MA2 session findCalls missing minCalls: 1 (flake risk) |
🟡 | Easy fix |
| 6 | MA1 skip justification overreaches on coverage claim | 🟡 | Update comment |
| 7 | Functional files MA1–MA3 should not be deleted yet | 🟡 | Hold |
| 8 | Copyright 2026 vs. 2025 in helpers |
info | No action needed |
| 9 | MA2.js ID:"MA3" meta collision (pre-existing) |
info | Follow-on cleanup |
The two functional tests that can be retired now are none — MA1's auto-ping path and the full MA2 legacy tracker exercise are both uncovered. The MA3 non-automatic path is migrated but with weakened assertions that should be tightened.
Changed Packages
Description
Migrates the Media Collection functional tests to the new Vitest+Playwright+MSW harness. MA1 (auto-ping mode) is preserved as test.skip — ping timing assertions require 11s sleep, impractical in CI. MA2 uses getMediaAnalyticsTracker directly in browser mode.
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:
packages/browser/test/functional/specs/MediaCollection/MA1.jspackages/browser/test/functional/specs/MediaCollection/MA2.jspackages/browser/test/functional/specs/MediaCollection/MA3.jsTypes of changes
Checklist:
Stack