Skip to content

Commit

Permalink
Merge pull request #696 from adobe/upgrade-testcafe
Browse files Browse the repository at this point in the history
Upgraded testcafe and browserstack provider.
  • Loading branch information
Aaronius committed Mar 18, 2021
2 parents 6e49d0f + 7450686 commit cfbcaf8
Show file tree
Hide file tree
Showing 31 changed files with 1,716 additions and 33,706 deletions.
19,366 changes: 1,538 additions & 17,828 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -125,8 +125,8 @@
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^7.0.2",
"start-server-and-test": "^1.10.6",
"testcafe": "^1.10.0",
"testcafe-browser-provider-browserstack": "^1.13.0-alpha.1",
"testcafe": "^1.12.0",
"testcafe-browser-provider-browserstack": "^1.13.2-alpha.1",
"ua-parser": "^0.3.5",
"url-parse": "^1.4.7",
"yargs": "^16.2.0"
Expand Down
15,804 changes: 25 additions & 15,779 deletions sandbox/package-lock.json

Large diffs are not rendered by default.

14 changes: 0 additions & 14 deletions sandbox/public/functional-test/alloyTestPage.html

This file was deleted.

Empty file.
15 changes: 15 additions & 0 deletions sandbox/public/functional-test/reloadPage.html
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Alloy Test Page</title>
</head>
<body>
<h1>
Testcafe injects Alloy and configurations during runtime. This is a
standalone test page that is hosted on alloyio.com/functional-test/ This
page is only used by reloadPage.js as an interim workaround for
https://github.com/DevExpress/testcafe/issues/5992
</h1>
</body>
</html>
13 changes: 13 additions & 0 deletions sandbox/public/functional-test/testPage.html
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Alloy Test Page</title>
</head>
<body>
<h1>
Testcafe injects Alloy and configurations during runtime. This is a
standalone test page that is hosted on alloyio.com/functional-test/
</h1>
</body>
</html>
39 changes: 39 additions & 0 deletions sandbox/public/functional-test/testPageWithCsp.html
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<!--
While it seems reasonable to use re-use our default test page
and just add the meta CSP element dynamically during our test,
TestCafe has a bug that prevents that approach from working properly.
https://github.com/DevExpress/testcafe/issues/6057
-->
<meta
http-equiv="Content-Security-Policy"
content="default-src 'self';
script-src 'self' 'unsafe-eval' 'nonce-aZ96GeVfD9D';
style-src 'self' 'nonce-aZ96GeVfD9D';
connect-src 'self' *.alloyio.com *.demdex.net *.adobedc.net;"
/>
<title>Alloy Test Page</title>
<!--
A customer using a CSP would typically add a nonce attribute to
the base code script we provide in Alloy's installation instructions.
Then, Alloy would find the nonce on that script tag and use the
nonce value when adding script or style elements (typically when
rendering personalized content). Because TestCafe limits how the
base code's script tag is constructed
(https://github.com/DevExpress/testcafe/issues/5612), we can't add
a nonce attribute to the script tag that TestCafe adds to the page.
So, as a workaround, we've provided this script tag with a nonce, so that
Alloy can properly access and use its nonce value.
-->
<script nonce="aZ96GeVfD9D"></script>
</head>
<body>
<h1>
Testcafe injects Alloy and configurations during runtime. This is a
standalone test page that is hosted on alloyio.com/functional-test/
</h1>
</body>
</html>
4 changes: 0 additions & 4 deletions test/functional/helpers/constants/general.js

This file was deleted.

13 changes: 13 additions & 0 deletions test/functional/helpers/constants/regex.js
@@ -0,0 +1,13 @@
/*
Copyright 2021 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.
*/

export const ECID = /^[0-9]{38}$/;
1 change: 0 additions & 1 deletion test/functional/helpers/constants/testPageUrl.js

This file was deleted.

19 changes: 19 additions & 0 deletions test/functional/helpers/constants/url.js
@@ -0,0 +1,19 @@
/*
Copyright 2021 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.
*/

const baseUrl = `https://alloyio.com/functional-test`;

export const TEST_PAGE = `${baseUrl}/testPage.html`;
export const TEST_PAGE_WITH_CSP = `${baseUrl}/testPageWithCsp.html`;
// This page is only used by reloadPage.js as an interim workaround for
// https://github.com/DevExpress/testcafe/issues/5992
export const RELOAD_PAGE = `${baseUrl}/reloadPage.html`;
4 changes: 2 additions & 2 deletions test/functional/helpers/createFixture/index.js
@@ -1,10 +1,10 @@
import testPageUrl from "../constants/testPageUrl";
import { TEST_PAGE as TEST_PAGE_URL } from "../constants/url";
import { getFixtureClientScripts } from "./clientScripts";
import destinationRequestMock from "./destinationRequestMock";

export default ({
title = "",
url = testPageUrl,
url = TEST_PAGE_URL,
requestHooks = [],
includeAlloyLibrary = true,
includeVisitorLibrary = false,
Expand Down
4 changes: 3 additions & 1 deletion test/functional/helpers/reloadPage.js
Expand Up @@ -11,6 +11,7 @@ governing permissions and limitations under the License.
*/

import { t, ClientFunction } from "testcafe";
import { RELOAD_PAGE as RELOAD_PAGE_URL } from "./constants/url";

const getLocalStorageEntries = ClientFunction(() => {
const entries = Object.keys(window.localStorage)
Expand Down Expand Up @@ -49,7 +50,8 @@ export default async () => {
// because if we just tried to navigate to the same page we're on, TestCafe
// would hang in Safari (at least).
const localStorageEntries = await getLocalStorageEntries();
await t.navigateTo("blank.html");
// We could navigate to any other page and then back again.
await t.navigateTo(RELOAD_PAGE_URL);
await t.navigateTo(currentUrl);
await setLocalStorageEntries(localStorageEntries);
};
8 changes: 4 additions & 4 deletions test/functional/specs/Context/C2598.js
Expand Up @@ -3,7 +3,7 @@ import createNetworkLogger from "../../helpers/networkLogger";
import { responseStatus } from "../../helpers/assertions/index";
import createFixture from "../../helpers/createFixture";
import webContextConfig from "../../helpers/constants/webContextConfig";
import testPageUrl from "../../helpers/constants/testPageUrl";
import { TEST_PAGE as TEST_PAGE_URL } from "../../helpers/constants/url";
import createAlloyProxy from "../../helpers/createAlloyProxy";

const networkLogger = createNetworkLogger();
Expand All @@ -12,7 +12,7 @@ createFixture({
title:
"C2598 - Adds only web context data when only web is specified in configuration.",
requestHooks: [networkLogger.edgeEndpointLogs],
url: testPageUrl
url: TEST_PAGE_URL
});

test.meta({
Expand Down Expand Up @@ -41,11 +41,11 @@ test("Test C2598 - Adds only web context data when only web is specified in conf
await t.expect(stringifyRequest.events[0].xdm.web.webPageDetails).ok();
await t
.expect(stringifyRequest.events[0].xdm.web.webPageDetails.URL)
.eql(testPageUrl);
.eql(TEST_PAGE_URL);
await t.expect(stringifyRequest.events[0].xdm.web.webReferrer).ok();
await t
.expect(stringifyRequest.events[0].xdm.web.webReferrer.URL)
.eql(testPageUrl);
.eql(TEST_PAGE_URL);

await t.expect(stringifyRequest.events[0].xdm.device).notOk();
await t.expect(stringifyRequest.events[0].xdm.placeContext).notOk();
Expand Down
3 changes: 2 additions & 1 deletion test/functional/specs/Context/C2599.js
Expand Up @@ -4,6 +4,7 @@ import { responseStatus } from "../../helpers/assertions/index";
import createFixture from "../../helpers/createFixture";
import deviceContextConfig from "../../helpers/constants/deviceContextConfig";
import createAlloyProxy from "../../helpers/createAlloyProxy";
import { TEST_PAGE as TEST_PAGE_URL } from "../../helpers/constants/url";

const networkLogger = createNetworkLogger();

Expand All @@ -23,7 +24,7 @@ const sendEventOptions = {
xdm: {
web: {
webPageDetails: {
URL: "https://alloyio.com/functional-test/alloyTestPage.html"
URL: TEST_PAGE_URL
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion test/functional/specs/Context/C2600.js
Expand Up @@ -4,6 +4,7 @@ import { responseStatus } from "../../helpers/assertions/index";
import createFixture from "../../helpers/createFixture";
import environmentContextConfig from "../../helpers/constants/environmentContextConfig";
import createAlloyProxy from "../../helpers/createAlloyProxy";
import { TEST_PAGE as TEST_PAGE_URL } from "../../helpers/constants/url";

const networkLogger = createNetworkLogger();

Expand All @@ -23,7 +24,7 @@ const sendEventOptions = {
xdm: {
web: {
webPageDetails: {
URL: "https://alloyio.com/functional-test/alloyTestPage.html"
URL: TEST_PAGE_URL
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion test/functional/specs/Context/C2601.js
Expand Up @@ -4,6 +4,7 @@ import { responseStatus } from "../../helpers/assertions/index";
import createFixture from "../../helpers/createFixture";
import placeContextConfig from "../../helpers/constants/placeContextConfig";
import createAlloyProxy from "../../helpers/createAlloyProxy";
import { TEST_PAGE as TEST_PAGE_URL } from "../../helpers/constants/url";

const networkLogger = createNetworkLogger();

Expand All @@ -23,7 +24,7 @@ const sendEventOptions = {
xdm: {
web: {
webPageDetails: {
URL: "https://alloyio.com/functional-test/alloyTestPage.html"
URL: TEST_PAGE_URL
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions test/functional/specs/ID Migration/C14400.js
Expand Up @@ -4,7 +4,7 @@ import getResponseBody from "../../helpers/networkLogger/getResponseBody";
import { responseStatus } from "../../helpers/assertions";
import createFixture from "../../helpers/createFixture";
import createResponse from "../../helpers/createResponse";
import generalConstants from "../../helpers/constants/general";
import { ECID as ECID_REGEX } from "../../helpers/constants/regex";
import {
compose,
orgMainConfigMain,
Expand All @@ -20,7 +20,6 @@ const config = compose(
);

const networkLogger = createNetworkLogger();
const { ecidRegex } = generalConstants;

createFixture({
title:
Expand Down Expand Up @@ -67,7 +66,7 @@ test("Test C14400: When ID migration is disabled and no identity cookie is found
payload => payload.namespace.code === "ECID"
)[0];

await t.expect(ecidPayload.id).match(ecidRegex);
await t.expect(ecidPayload.id).match(ECID_REGEX);

const documentCookie = await getDocumentCookie();

Expand Down
5 changes: 2 additions & 3 deletions test/functional/specs/ID Migration/C14401.js
Expand Up @@ -4,7 +4,7 @@ import getResponseBody from "../../helpers/networkLogger/getResponseBody";
import { responseStatus } from "../../helpers/assertions";
import createFixture from "../../helpers/createFixture";
import createResponse from "../../helpers/createResponse";
import generalConstants from "../../helpers/constants/general";
import { ECID as ECID_REGEX } from "../../helpers/constants/regex";
import {
compose,
orgMainConfigMain,
Expand All @@ -21,7 +21,6 @@ const config = compose(
);

const networkLogger = createNetworkLogger();
const { ecidRegex } = generalConstants;

createFixture({
title:
Expand Down Expand Up @@ -62,5 +61,5 @@ test("Test C14401: When ID migration is disabled and no identity cookie is found
payload => payload.namespace.code === "ECID"
)[0];

await t.expect(ecidPayload.id).match(ecidRegex);
await t.expect(ecidPayload.id).match(ECID_REGEX);
});
5 changes: 2 additions & 3 deletions test/functional/specs/ID Migration/C14402.js
Expand Up @@ -4,7 +4,7 @@ import getResponseBody from "../../helpers/networkLogger/getResponseBody";
import { responseStatus } from "../../helpers/assertions";
import createFixture from "../../helpers/createFixture";
import createResponse from "../../helpers/createResponse";
import generalConstants from "../../helpers/constants/general";
import { ECID as ECID_REGEX } from "../../helpers/constants/regex";
import {
compose,
orgMainConfigMain,
Expand All @@ -21,7 +21,6 @@ const config = compose(
);

const networkLogger = createNetworkLogger();
const { ecidRegex } = generalConstants;

createFixture({
title:
Expand Down Expand Up @@ -57,7 +56,7 @@ test("Test C14402: When ID migration is enabled and no legacy AMCV cookie is fou
payload => payload.namespace.code === "ECID"
)[0];

await t.expect(ecidPayload.id).match(ecidRegex);
await t.expect(ecidPayload.id).match(ECID_REGEX);

const documentCookie = await getDocumentCookie();

Expand Down
5 changes: 2 additions & 3 deletions test/functional/specs/ID Migration/C14403.js
Expand Up @@ -4,7 +4,7 @@ import getResponseBody from "../../helpers/networkLogger/getResponseBody";
import { responseStatus } from "../../helpers/assertions";
import createFixture from "../../helpers/createFixture";
import createResponse from "../../helpers/createResponse";
import generalConstants from "../../helpers/constants/general";
import { ECID as ECID_REGEX } from "../../helpers/constants/regex";
import {
compose,
orgMainConfigMain,
Expand All @@ -20,7 +20,6 @@ const config = compose(
);

const networkLogger = createNetworkLogger();
const { ecidRegex } = generalConstants;

createFixture({
title:
Expand Down Expand Up @@ -56,7 +55,7 @@ test("Test C14403: When ID migration is disabled and no legacy AMCV cookie is fo
payload => payload.namespace.code === "ECID"
)[0];

await t.expect(ecidPayload.id).match(ecidRegex);
await t.expect(ecidPayload.id).match(ECID_REGEX);

const documentCookie = await getDocumentCookie();

Expand Down
4 changes: 2 additions & 2 deletions test/functional/specs/Logging/C2586.js
@@ -1,11 +1,11 @@
import createFixture from "../../helpers/createFixture";
import testPageUrl from "../../helpers/constants/testPageUrl";
import { TEST_PAGE as TEST_PAGE_URL } from "../../helpers/constants/url";
import { orgMainConfigMain } from "../../helpers/constants/configParts";
import createAlloyProxy from "../../helpers/createAlloyProxy";

createFixture({
title: "C2586: Toggle logging through the querystring parameter.",
url: `${testPageUrl}?alloy_debug=true`
url: `${TEST_PAGE_URL}?alloy_debug=true`
});

test.meta({
Expand Down
9 changes: 6 additions & 3 deletions test/functional/specs/Personalization/C28755.js
Expand Up @@ -9,11 +9,14 @@ import {
} from "../../helpers/constants/configParts";
import getResponseBody from "../../helpers/networkLogger/getResponseBody";
import createResponse from "../../helpers/createResponse";
import testPageUrl from "../../helpers/constants/testPageUrl";
import { TEST_PAGE as TEST_PAGE_URL } from "../../helpers/constants/url";
import createAlloyProxy from "../../helpers/createAlloyProxy";

const networkLogger = createNetworkLogger();
const config = compose(orgMainConfigMain, debugEnabled);
const config = compose(
orgMainConfigMain,
debugEnabled
);
const PAGE_WIDE_SCOPE = "__view__";
const decisionContent =
'<div id="C28755">Here is an awesome target offer!</div>';
Expand All @@ -22,7 +25,7 @@ createFixture({
title:
"C28755: The first sendEvent on the page should fetch Personalization VEC offers",
requestHooks: [networkLogger.edgeEndpointLogs],
url: `${testPageUrl}?test=C28755`
url: `${TEST_PAGE_URL}?test=C28755`
});

test.meta({
Expand Down

0 comments on commit cfbcaf8

Please sign in to comment.