Skip to content

Commit 366cc96

Browse files
Fixed broken integration tests (#1446)
* Fix these int tests * Add empty changeset * Remove unnecessary artifacts of earlier test changes
1 parent 8474bdd commit 366cc96

File tree

7 files changed

+25
-11
lines changed

7 files changed

+25
-11
lines changed

.changeset/wide-papers-kneel.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/core/src/core/network/injectSendNetworkRequest.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default ({
2929
// not recursive (it doesn't call toJSON() on the event objects).
3030
// Parsing the result of JSON.stringify(), however, gives the
3131
// fully recursive raw data.
32+
3233
const stringifiedPayload = JSON.stringify(payload);
3334
const parsedPayload = JSON.parse(stringifiedPayload);
3435

packages/core/test/integration/helpers/alloy/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ export default {
1717
edgeDomain: import.meta.env.VITE_EDGE_DOMAIN || "edge.adobedc.net",
1818
edgeBasePath: import.meta.env.VITE_EDGE_BASE_PATH || "ee",
1919
thirdPartyCookiesEnabled: false,
20+
debugEnabled: false,
2021
};

packages/core/test/integration/helpers/alloy/setup.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ export default async () => {
3030
alloyScriptTag.setAttribute("async", true);
3131
alloyScriptTag.src = "/dist/alloy.js";
3232

33-
document.body.appendChild(alloyScriptTag);
33+
await new Promise((resolve, reject) => {
34+
alloyScriptTag.onload = () => resolve();
35+
alloyScriptTag.onerror = () =>
36+
reject(new Error("Failed to load /dist/alloy.js"));
37+
document.body.appendChild(alloyScriptTag);
38+
});
39+
3440
return window.alloy;
3541
};

packages/core/test/integration/helpers/mocks/mediaSessionResponse.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"payload": [
66
{
7-
"sessionId": "test-session-id-12345"
7+
"sessionId": "test-session-id-123456789012345678901234"
88
}
99
],
1010
"type": "media-analytics:new-session"

packages/core/test/integration/helpers/testsSetup/extend.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const test = baseTest.extend({
4343
alloy: [
4444
async ({}, use) => {
4545
await setupBaseCode();
46-
const alloy = setupAlloy();
46+
const alloy = await setupAlloy();
4747

4848
// Make alloy available in the test context
4949
await use(alloy);

packages/core/test/integration/specs/Advertising/consent_gate.spec.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
/*
22
Copyright 2025 Adobe. All rights reserved.
33
This file is licensed to you under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License. You may obtain a copy
5+
of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
Unless required by applicable law or agreed to in writing, software distributed under
8+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9+
OF ANY KIND, either express or implied. See the License for the specific language
10+
governing permissions and limitations under the License.
411
*/
12+
513
import { http, HttpResponse } from "msw";
614
import { test, describe, expect } from "../../helpers/testsSetup/extend.js";
715
import { sendEventHandler } from "../../helpers/mswjs/handlers.js";
@@ -45,7 +53,7 @@ const cleanupAll = () => {
4553
* matching what the real Edge Network returns.
4654
*/
4755
const setConsentAcceptHandler = http.post(
48-
/https:\/\/edge\.adobedc\.net\/ee\/v1\/privacy\/set-consent/,
56+
/https:\/\/edge\.adobedc\.net\/ee\/(?:[^/]+\/)?v1\/privacy\/set-consent/,
4957
async (req) => {
5058
const url = new URL(req.request.url);
5159
const configId = url.searchParams.get("configId");
@@ -181,9 +189,7 @@ describe("Advertising - Consent gate", () => {
181189
typeof call.request.body === "string"
182190
? JSON.parse(call.request.body)
183191
: call.request.body;
184-
return (
185-
body?.events?.[0]?.xdm?.eventType === "advertising.enrichment_ct"
186-
);
192+
return body?.events?.[0]?.xdm?.eventType === "advertising.enrichment_ct";
187193
});
188194
expect(conversionCall).toBeTruthy();
189195

@@ -211,7 +217,7 @@ describe("Advertising - Consent gate", () => {
211217
cleanupAll();
212218

213219
const setConsentDeclineHandler = http.post(
214-
/https:\/\/edge\.adobedc\.net\/ee\/v1\/privacy\/set-consent/,
220+
/https:\/\/edge\.adobedc\.net\/ee\/(?:[^/]+\/)?v1\/privacy\/set-consent/,
215221
async (req) => {
216222
const url = new URL(req.request.url);
217223
const configId = url.searchParams.get("configId");
@@ -283,9 +289,7 @@ describe("Advertising - Consent gate", () => {
283289
typeof call.request.body === "string"
284290
? JSON.parse(call.request.body)
285291
: call.request.body;
286-
return (
287-
body?.events?.[0]?.xdm?.eventType === "advertising.enrichment_ct"
288-
);
292+
return body?.events?.[0]?.xdm?.eventType === "advertising.enrichment_ct";
289293
});
290294
expect(conversionCall).toBeFalsy();
291295

0 commit comments

Comments
 (0)