-
Notifications
You must be signed in to change notification settings - Fork 43
/
C14402.js
66 lines (53 loc) · 2.03 KB
/
C14402.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { t, ClientFunction } from "testcafe";
import createNetworkLogger from "../../helpers/networkLogger";
import getResponseBody from "../../helpers/networkLogger/getResponseBody";
import { responseStatus } from "../../helpers/assertions";
import createFixture from "../../helpers/createFixture";
import createResponse from "../../helpers/createResponse";
import { ECID as ECID_REGEX } from "../../helpers/constants/regex";
import {
compose,
orgMainConfigMain,
debugEnabled,
migrationEnabled
} from "../../helpers/constants/configParts";
import createAlloyProxy from "../../helpers/createAlloyProxy";
import { LEGACY_IDENTITY_COOKIE_NAME } from "../../helpers/constants/cookies";
const config = compose(
orgMainConfigMain,
debugEnabled,
migrationEnabled
);
const networkLogger = createNetworkLogger();
createFixture({
title:
"C14402: When ID migration is enabled and no legacy AMCV cookie is found, an AMCV cookie should be created",
requestHooks: [networkLogger.edgeEndpointLogs]
});
test.meta({
ID: "C14402",
SEVERITY: "P0",
TEST_RUN: "Regression"
});
const getDocumentCookie = ClientFunction(() => document.cookie);
test("Test C14402: When ID migration is enabled and no legacy AMCV cookie is found, an AMCV cookie should be created", async () => {
const alloy = createAlloyProxy();
await alloy.configure(config);
await alloy.sendEvent({ renderDecisions: true });
await responseStatus(networkLogger.edgeEndpointLogs.requests, 200);
await t.expect(networkLogger.edgeEndpointLogs.requests.length).eql(1);
const response = JSON.parse(
getResponseBody(networkLogger.edgeEndpointLogs.requests[0])
);
const payloads = createResponse({ content: response }).getPayloadsByType(
"identity:result"
);
const ecidPayload = payloads.filter(
payload => payload.namespace.code === "ECID"
)[0];
await t.expect(ecidPayload.id).match(ECID_REGEX);
const documentCookie = await getDocumentCookie();
await t
.expect(documentCookie)
.contains(`${LEGACY_IDENTITY_COOKIE_NAME}=MCMID|${ecidPayload.id}`);
});