-
Notifications
You must be signed in to change notification settings - Fork 58
Migrated Location Hints functional tests to Vitest+Playwright+MSW #1537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
carterworks
wants to merge
8
commits into
migrate-integration/00-infra
Choose a base branch
from
migrate-integration/05-location-hints
base: migrate-integration/00-infra
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
988112d
test(integration): migrate location hints functional specs to Vitest+…
carterworks c372157
Use beforeEach/afterEach instead of calls
carterworks d271596
delete redundent deleteCookies
carterworks e104e56
Use the cookiestore api
carterworks 5746c5d
test(integration): harden location hints spec with configId guard and…
carterworks 50fee2b
Remove slop comments
carterworks 04be6b9
remove migrated functional tests
carterworks a20f511
test(functional): restore migrated functional specs as review signal
carterworks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
130 changes: 130 additions & 0 deletions
130
packages/browser/test/integration/specs/Location Hints/locationHints.spec.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| /* | ||
| Copyright 2026 Adobe. All rights reserved. | ||
| This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. You may obtain a copy | ||
| of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software distributed under | ||
| the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
| OF ANY KIND, either express or implied. See the License for the specific language | ||
| governing permissions and limitations under the License. | ||
| */ | ||
| import { http, HttpResponse } from "msw"; | ||
| import { test, expect, describe } from "../../helpers/testsSetup/extend.js"; | ||
| import { sendEventHandler } from "../../helpers/mswjs/handlers.js"; | ||
| import alloyConfig from "../../helpers/alloy/config.js"; | ||
| import { MAIN_CLUSTER_COOKIE_NAME } from "../../helpers/constants/cookies.js"; | ||
|
|
||
| // Simulates the edge response when routed via the Singapore cluster: | ||
| // mboxEdgeCluster=38 maps to sgp3 in Konductor. | ||
| const sgp3LocationHintHandler = http.post( | ||
| /https:\/\/edge.adobedc.net\/ee\/.*\/?v1\/interact/, | ||
| async (req) => { | ||
| const url = new URL(req.request.url); | ||
| const configId = url.searchParams.get("configId"); | ||
|
|
||
| if (configId === alloyConfig.datastreamId) { | ||
| return HttpResponse.json({ | ||
| requestId: "sgp3-location-hint-test", | ||
| handle: [ | ||
| { | ||
| payload: [ | ||
| { | ||
| id: "41861666193140161934276845651148876988", | ||
| namespace: { code: "ECID" }, | ||
| }, | ||
| ], | ||
| type: "identity:result", | ||
| }, | ||
| { | ||
| payload: [ | ||
| { scope: "Target", hint: "38", ttlSeconds: 1800 }, | ||
| { scope: "AAM", hint: "3", ttlSeconds: 1800 }, | ||
| { scope: "EdgeNetwork", hint: "sgp3", ttlSeconds: 1800 }, | ||
| ], | ||
| type: "locationHint:result", | ||
| }, | ||
| { | ||
| payload: [ | ||
| { | ||
| key: MAIN_CLUSTER_COOKIE_NAME, | ||
| value: "sgp3", | ||
| maxAge: 1800, | ||
| }, | ||
| ], | ||
| type: "state:store", | ||
| }, | ||
| ], | ||
| }); | ||
| } | ||
|
|
||
| throw new Error("Handler not configured properly"); | ||
| }, | ||
| ); | ||
|
|
||
| describe("Location Hints", () => { | ||
| test("C6589015 - location hint from first response is included in second request URL", async ({ | ||
| alloy, | ||
| worker, | ||
| networkRecorder, | ||
| }) => { | ||
| worker.use(sendEventHandler); | ||
|
|
||
| await alloy("configure", { | ||
| ...alloyConfig, | ||
| thirdPartyCookiesEnabled: false, | ||
| debugEnabled: false, | ||
| }); | ||
| await alloy("sendEvent", {}); | ||
|
|
||
| const clusterCookie = await cookieStore.get(MAIN_CLUSTER_COOKIE_NAME); | ||
| const locationHint = clusterCookie?.value; | ||
| expect(locationHint).toBeTruthy(); | ||
|
|
||
| await alloy("sendEvent", {}); | ||
|
|
||
| const calls = await networkRecorder.findCalls(/edge\.adobedc\.net/, { | ||
| minCalls: 2, | ||
| }); | ||
| expect(calls.length).toBe(2); | ||
|
|
||
| // no hint | ||
| expect(calls[0].request.url).toMatch( | ||
| /^https:\/\/[^/]+\/[^/]+\/v1\/interact/, | ||
| ); | ||
| // yes hint | ||
| expect(calls[1].request.url).toMatch( | ||
| new RegExp(`edge\\.adobedc\\.net/ee/${locationHint}/v1/interact`), | ||
| ); | ||
| }); | ||
|
|
||
| test("C6944931 - legacy mboxEdgeCluster cookie is translated to a location hint on the first request", async ({ | ||
| alloy, | ||
| worker, | ||
| networkRecorder, | ||
| }) => { | ||
| await cookieStore.set({ name: "mboxEdgeCluster", value: "38", path: "/" }); | ||
|
|
||
| worker.use(sgp3LocationHintHandler); | ||
|
|
||
| await alloy("configure", { | ||
| ...alloyConfig, | ||
| thirdPartyCookiesEnabled: false, | ||
| debugEnabled: false, | ||
| }); | ||
| await alloy("sendEvent", {}); | ||
|
|
||
| const clusterCookie = await cookieStore.get(MAIN_CLUSTER_COOKIE_NAME); | ||
| expect(clusterCookie?.value).toBe("sgp3"); | ||
|
|
||
| await alloy("sendEvent", {}); | ||
|
|
||
| const calls = await networkRecorder.findCalls(/edge\.adobedc\.net/, { | ||
| minCalls: 2, | ||
| }); | ||
| expect(calls.length).toBe(2); | ||
|
|
||
| expect(calls[0].request.url).toMatch(/edge\.adobedc\.net\/ee\/t38\//); | ||
| expect(calls[1].request.url).toMatch(/edge\.adobedc\.net\/ee\/sgp3\//); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original
C6944931.js(line 56) explicitly verified that after the firstsendEventthe cluster cookie was set to"sgp3". The new test drops this assertion and jumps straight to URL-pattern checks. If thestate:storeresponse were mishandled (cookie name mismatch, wrong key, alloy bug in storing location hints), the second URL would silently fall back to thet38path and the second assertion would fail — but the reason (the cookie was never set) would not be surfaced clearly. Adding the explicit cookie check before the secondsendEventpreserves the diagnostic value of the original test.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!