diff --git a/test/functional/helpers/assurance/AssuranceRequestHook.js b/test/functional/helpers/assurance/AssuranceRequestHook.js index bece977ed..4174c214b 100644 --- a/test/functional/helpers/assurance/AssuranceRequestHook.js +++ b/test/functional/helpers/assurance/AssuranceRequestHook.js @@ -12,7 +12,7 @@ governing permissions and limitations under the License. import { RequestHook, t } from "testcafe"; const ASSERTION_DELAY = 200; -const ASSERTION_TIMEOUT = 5000; +const ASSERTION_TIMEOUT = 10000; const delay = () => { return new Promise(resolve => setTimeout(resolve, ASSERTION_DELAY)); }; @@ -38,9 +38,11 @@ const createRequest = (requestLogs, fetchMore) => { // eslint-disable-next-line no-await-in-loop await delay(); } - t.expect().ok( - "Assurance logs did not contain an event matching the predicate after 5 seconds." - ); + await t + .expect() + .ok( + "Assurance logs did not contain an event matching the predicate after 10 seconds." + ); return undefined; }, debug() { @@ -79,9 +81,16 @@ export default class AssuranceRequestHook extends RequestHook { // eslint-disable-next-line no-await-in-loop while (await this.events.advance()) { const event = this.events.current(); - const { payload: { attributes: { requestId } = {} } = {} } = event; - if (requestId && this.eventsByRequestId[requestId]) { - this.eventsByRequestId[requestId].push(event); + const { + payload: { + attributes: { requestId } = {}, + header: { xactionId } = {} + } = {} + } = event; + + const id = requestId || xactionId; + if (id && this.eventsByRequestId[id]) { + this.eventsByRequestId[id].push(event); } } } diff --git a/test/functional/helpers/assurance/createAssuranceApi.js b/test/functional/helpers/assurance/createAssuranceApi.js index df3ba180d..3c7b5e03d 100644 --- a/test/functional/helpers/assurance/createAssuranceApi.js +++ b/test/functional/helpers/assurance/createAssuranceApi.js @@ -23,8 +23,8 @@ const CREATE_SESSION_QUERY = ` }`; const FETCH_EVENTS_QUERY = ` - query eventsQuery($sessionUuid: UUID!, $cursor: EventCursor) { - events(sessionUuid:$sessionUuid,first:1000,after:$cursor){ + query eventsQuery($sessionUuid: UUID!) { + events(sessionUuid:$sessionUuid,first:100) { uuid eventNumber clientId @@ -51,6 +51,9 @@ export default authHeaders => { body: JSON.stringify({ query, variables }) }); const json = await response.json(); + if (json.errors) { + throw new Error(json.errors.message); + } return json.data; }; @@ -68,7 +71,7 @@ export default authHeaders => { return uuid; }, fetchEvents: sessionUuid => { - let cursor = null; + const seenUuids = new Set(); let events = []; let i = 0; return { @@ -77,15 +80,16 @@ export default authHeaders => { }, advance: async () => { if (i >= events.length) { - if (events.length > 0) { - const { eventNumber, timestamp } = events[events.length - 1]; - cursor = { eventNumber, timestamp, sessionUuid }; - } const response = await makeGraphRequest(FETCH_EVENTS_QUERY, { - sessionUuid, - cursor + sessionUuid + }); + events = response.events.filter(e => { + if (seenUuids.has(e.uuid)) { + return false; + } + seenUuids.add(e.uuid); + return true; }); - events = response.events; i = 0; return events.length > 0; } diff --git a/test/functional/specs/Data Collector/C15958190.js b/test/functional/specs/Data Collector/C15958190.js new file mode 100644 index 000000000..4a38f33b0 --- /dev/null +++ b/test/functional/specs/Data Collector/C15958190.js @@ -0,0 +1,140 @@ +/* +Copyright 2023 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 { t } from "testcafe"; +import createNetworkLogger from "../../helpers/networkLogger"; +import { responseStatus } from "../../helpers/assertions/index"; +import createFixture from "../../helpers/createFixture"; +import { + compose, + orgMainConfigMain, + debugEnabled +} from "../../helpers/constants/configParts"; +import createAlloyProxy from "../../helpers/createAlloyProxy"; +import { createAssuranceRequestHook } from "../../helpers/assurance"; + +const networkLogger = createNetworkLogger(); +const config = compose(orgMainConfigMain, debugEnabled); + +createFixture({ + title: "C15958190 Analytics maps long names from data", + requestHooks: [networkLogger.edgeEndpointLogs] +}); + +test.meta({ + ID: "C15958190", + SEVERITY: "P0", + TEST_RUN: "Regression" +}); + +test("Test C15958190 Analytics maps long names from data", async () => { + const assuranceRequests = await createAssuranceRequestHook(); + await t.addRequestHooks(assuranceRequests); + + const alloy = createAlloyProxy(); + await alloy.configure(config); + await alloy.sendEvent({ + xdm: {}, + data: { + __adobe: { + analytics: { + pageName: "C15958190-pagename", + pageURL: "C15958190-pageurl", + referrer: "C15958190-referrer", + contextData: { + "contextData-key": "C15958190-contextData-value" + }, + currencyCode: "C15958190-currencyCode", + purchaseID: "C15958190-purchaseID", + channel: "C15958190-channel", + server: "C15958190-server", + pageType: "C15958190-pageType", + transactionID: "C15958190-transactionID", + campaign: "C15958190-campaign", + zip: "C15958190-zip", + events: "C15958190-events", + events2: "C15958190-events2", + products: "C15958190-products", + linkURL: "C15958190-linkURL", + linkName: "C15958190-linkName", + linkType: "e", + eVar1: "C15958190-eVar1", + prop1: "C15958190-prop1", + list1: "C15958190-list1", + pe: "C15958190-pe", + pev1: "C15958190-pev1", + pev2: "C15958190-pev2", + pev3: "C15958190-pev3", + latitude: "C15958190-latitude", + longitude: "C15958190-longitude", + resolution: "C15958190-resolution", + colorDepth: "C15958190-colorDepth", + javascriptVersion: "C15958190-javascriptVersion", + javaEnabled: "C15958190-javaEnabled", + cookiesEnabled: "C15958190-cookiesEnabled", + browserWidth: "C15958190-browserWidth", + browserHeight: "C15958190-browserHeight", + connectionType: "C15958190-connectionType" + } + } + } + }); + + await responseStatus(networkLogger.edgeEndpointLogs.requests, 200); + + const mappingLog = await assuranceRequests.requests[0].find(log => { + const { vendor, payload: { name } = {} } = log; + return vendor === "com.adobe.analytics" && name === "analytics.mapping"; + }); + + const mappings = + mappingLog.payload.context.mappedQueryParams.unifiedjsqeonlylatest; + console.log(JSON.stringify(mappings, null, 2)); + const expectedMappings = { + gn: "C15958190-pageName", + g: "C15958190-pageURL", + r: "C15958190-referrer", + "c.contextData-key": "C15958190-contextData-value", + cc: "C15958190-currencyCode", + purchaseID: "C15958190-purchaseID", + ch: "C15958190-channel", + server: "C15958190-server", + gt: "C15958190-pageType", + xact: "C15958190-transactionID", + v0: "C15958190-campaign", + zip: "C15958190-zip", + events: "C15958190-events,C15958190-events2", + products: "C15958190-products", + pev1: "C15958190-linkURL", + pev2: "C15958190-linkName", + pe: "lnk_e", + v1: "C15958190-eVar1", + c1: "C15958190-prop1", + list1: "C15958190-list1", + pev3: "C15958190-pev3", + lat: "C15958190-latitude", + lon: "C15958190-longitude", + s: "C15958190-resolution", + c: "C15958190-colorDepth", + j: "C15958190-javascriptVersion", + v: "C15958190-javaEnabled", + k: "C15958190-cookiesEnabled", + bw: "C15958190-browserWidth", + bh: "C15958190-browserHeight", + ct: "C15958190-connectionType" + }; + + // eslint-disable-next-line no-restricted-syntax + for (const key of Object.keys(expectedMappings)) { + // eslint-disable-next-line no-await-in-loop + await t.expect(mappings[key]).eql(expectedMappings[key]); + } +}); diff --git a/test/functional/specs/Personalization/C????.js b/test/functional/specs/Data Collector/C15958191.js similarity index 67% rename from test/functional/specs/Personalization/C????.js rename to test/functional/specs/Data Collector/C15958191.js index 795f10059..66be8529c 100644 --- a/test/functional/specs/Personalization/C????.js +++ b/test/functional/specs/Data Collector/C15958191.js @@ -25,41 +25,46 @@ const networkLogger = createNetworkLogger(); const config = compose(orgMainConfigMain, debugEnabled); createFixture({ - title: "C???? assurance example", + title: "C15958191 Data prep maps products to XDM", requestHooks: [networkLogger.edgeEndpointLogs] }); test.meta({ - ID: "C????", + ID: "C15958191", SEVERITY: "P0", TEST_RUN: "Regression" }); -test("Test C???? assurance example", async () => { +test("Test C15958191 Data prep maps products to XDM", async () => { const assuranceRequests = await createAssuranceRequestHook(); await t.addRequestHooks(assuranceRequests); const alloy = createAlloyProxy(); await alloy.configure(config); await alloy.sendEvent({ - renderDecisions: true, - decisionScopes: ["alloy-test-scope-1"] + xdm: {}, + data: { + __adobe: { + analytics: { + eVar1: "eVar1Value", + prop1: "prop1Value", + products: "" + } + } + } }); await responseStatus(networkLogger.edgeEndpointLogs.requests, 200); - const mappingLog = await assuranceRequests.requests[0].find(log => { - const { vendor, payload: { name } = {} } = log; - return vendor === "com.adobe.analytics" && name === "analytics.mapping"; + const pipelineLog = await assuranceRequests.requests[0].find(log => { + const { vendor, payload: { header: { msgType } = {} } = {} } = log; + return ( + vendor === "com.adobe.streaming.validation" && + msgType === "xdmEntityCreate" + ); }); - await t - .expect( - mappingLog.payload.context.mappedQueryParams.unifiedjsqeonlylatest.g - ) - .eql("https://alloyio.com/functional-test/testPage.html"); + const mappedXdm = pipelineLog.payload.body.xdmEntity; + console.log(JSON.stringify(mappedXdm, null, 2)); - // you can run this to see all the logs instead of the find above - // await new Promise(resolve => setTimeout(resolve, 5000)); - // await assuranceRequests.fetchMore(); - // assuranceRequests.requests[0].debug(); + // TODO add assertions here that the mapping happened correctly. });