diff --git a/.eslintignore b/.eslintignore index e935cfaf..7cf3347f 100644 --- a/.eslintignore +++ b/.eslintignore @@ -7,7 +7,8 @@ node_modules .github .gitignore CHANGELOG.md -cypress.json +cypress.config.js generateDocs.sh jsdoc_conf.json -LICENSE \ No newline at end of file +LICENSE +cypress/ \ No newline at end of file diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 8ef6c0ed..a439ab55 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -13,7 +13,7 @@ jobs: build-and-test: strategy: matrix: - node-version: [12.x, 14.x, 16.x] + node-version: [14.x, 16.x, 18.x, 20.x] runs-on: ubuntu-latest diff --git a/cypress.config.js b/cypress.config.js new file mode 100644 index 00000000..6cf93d9c --- /dev/null +++ b/cypress.config.js @@ -0,0 +1,9 @@ +const { defineConfig } = require('cypress') +module.exports = defineConfig({ + e2e: { + setupNodeEvents(on, config) { + // implement node event listeners here + }, + }, + userAgent: "abcd", +}); diff --git a/cypress.json b/cypress.json deleted file mode 100644 index f0a56304..00000000 --- a/cypress.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "userAgent": "abcd" -} diff --git a/cypress/integration/async_queue.js b/cypress/e2e/async_queue.cy.js similarity index 87% rename from cypress/integration/async_queue.js rename to cypress/e2e/async_queue.cy.js index d1f8ce24..6448ba39 100644 --- a/cypress/integration/async_queue.js +++ b/cypress/e2e/async_queue.cy.js @@ -1,8 +1,6 @@ -/* eslint-disable cypress/no-unnecessary-waiting */ /* eslint-disable require-jsdoc */ var Countly = require("../../lib/countly"); -// import * as Countly from "../../dist/countly_umd.js"; -var hp = require("../support/helper.js"); +var hp = require("../support/helper"); function initMain(clear) { Countly.init({ @@ -62,22 +60,22 @@ describe("Test Countly.q related methods and processes", () => { // Check that the .q is empty expect(Countly.q.length).to.equal(0); - cy.fetch_local_request_queue().then((rq_2) => { + cy.fetch_local_request_queue().then((rq) => { // Check that nothing sent to request queue - expect(rq_2.length).to.equal(0); + expect(rq.length).to.equal(0); cy.fetch_local_event_queue().then((eq) => { // Check that events are now in event queue expect(eq.length).to.equal(4); // Send events from event queue to request queue Countly._internals.sendEventsForced(); - cy.fetch_local_event_queue().then((eq_2) => { + cy.fetch_local_event_queue().then((eq) => { // Check that event queue is empty - expect(eq_2.length).to.equal(0); - cy.fetch_local_request_queue().then((rq_3) => { + expect(eq.length).to.equal(0); + cy.fetch_local_request_queue().then((rq) => { // Check that events are now in request queue - expect(rq_3.length).to.equal(1); - const eventsArray = JSON.parse(rq_3[0].events); + expect(rq.length).to.equal(1); + const eventsArray = JSON.parse(rq[0].events); expect(eventsArray[0].key).to.equal("event_1"); expect(eventsArray[1].key).to.equal("event_2"); expect(eventsArray[2].key).to.equal("event_3"); @@ -125,16 +123,16 @@ describe("Test Countly.q related methods and processes", () => { // Check that event queue has new device ID's orientation event expect(eq.length).to.equal(1); expect(eq[0].key).to.equal("[CLY]_orientation"); - cy.fetch_local_request_queue().then((rq_2) => { + cy.fetch_local_request_queue().then((rq) => { // Check that events are now in request queue (second request is begin session for new device ID) - expect(rq_2.length).to.equal(2); - const eventsArray = JSON.parse(rq_2[0].events); + expect(rq.length).to.equal(2); + const eventsArray = JSON.parse(rq[0].events); expect(eventsArray[0].key).to.equal("event_1"); expect(eventsArray[1].key).to.equal("event_2"); expect(eventsArray[2].key).to.equal("event_3"); expect(eventsArray[3].key).to.equal("event_4"); // check begin session - expect(rq_2[1].begin_session).to.equal(1); + expect(rq[1].begin_session).to.equal(1); }); }); }); @@ -175,16 +173,16 @@ describe("Test Countly.q related methods and processes", () => { cy.fetch_local_event_queue().then((eq) => { // Check that event queue is empty expect(eq.length).to.equal(0); - cy.fetch_local_request_queue().then((rq_2) => { + cy.fetch_local_request_queue().then((rq) => { // Check that events are now in request queue (second request is user details) - expect(rq_2.length).to.equal(2); - const eventsArray = JSON.parse(rq_2[0].events); + expect(rq.length).to.equal(2); + const eventsArray = JSON.parse(rq[0].events); expect(eventsArray[0].key).to.equal("event_1"); expect(eventsArray[1].key).to.equal("event_2"); expect(eventsArray[2].key).to.equal("event_3"); expect(eventsArray[3].key).to.equal("event_4"); // check user details - const user_details = JSON.parse(rq_2[1].user_details); + const user_details = JSON.parse(rq[1].user_details); expect(user_details.name).to.equal("test_user"); }); }); @@ -227,16 +225,16 @@ describe("Test Countly.q related methods and processes", () => { cy.fetch_local_event_queue().then((eq) => { // Check that event queue is empty expect(eq.length).to.equal(0); - cy.fetch_local_request_queue().then((rq_2) => { + cy.fetch_local_request_queue().then((rq) => { // Check that events are now in request queue (second request is user details) - expect(rq_2.length).to.equal(2); - const eventsArray = JSON.parse(rq_2[0].events); + expect(rq.length).to.equal(2); + const eventsArray = JSON.parse(rq[0].events); expect(eventsArray[0].key).to.equal("event_1"); expect(eventsArray[1].key).to.equal("event_2"); expect(eventsArray[2].key).to.equal("event_3"); expect(eventsArray[3].key).to.equal("event_4"); // check user data - const user_details = JSON.parse(rq_2[1].user_details); + const user_details = JSON.parse(rq[1].user_details); expect(user_details.custom.name).to.equal("test_user"); }); }); @@ -267,15 +265,15 @@ describe("Test Countly.q related methods and processes", () => { expect(Countly.q.length).to.equal(4); // Wait for heartBeat to process the .q cy.wait(1500).then(() => { - // Check that the .q is empty + // Check that the .q is empty expect(Countly.q.length).to.equal(0); - cy.fetch_local_event_queue().then((eq_2) => { - // Check that event queue is empty as all must be in request queue - expect(eq_2.length).to.equal(0); - cy.fetch_local_request_queue().then((rq_2) => { - // Check that events are now in request queue - expect(rq_2.length).to.equal(1); - const eventsArray = JSON.parse(rq_2[0].events); + cy.fetch_local_event_queue().then((eq) => { + // Check that event queue is empty as all must be in request queue + expect(eq.length).to.equal(0); + cy.fetch_local_request_queue().then((rq) => { + // Check that events are now in request queue + expect(rq.length).to.equal(1); + const eventsArray = JSON.parse(rq[0].events); expect(eventsArray[0].key).to.equal("event_1"); expect(eventsArray[1].key).to.equal("event_2"); expect(eventsArray[2].key).to.equal("event_3"); diff --git a/cypress/integration/bridge_utils.js b/cypress/e2e/bridged_utils.cy.js similarity index 89% rename from cypress/integration/bridge_utils.js rename to cypress/e2e/bridged_utils.cy.js index dda162b7..c6673198 100644 --- a/cypress/integration/bridge_utils.js +++ b/cypress/e2e/bridged_utils.cy.js @@ -1,7 +1,6 @@ /* eslint-disable cypress/no-unnecessary-waiting */ /* eslint-disable require-jsdoc */ var Countly = require("../../lib/countly"); -// import * as Countly from "../../dist/countly_umd.js"; var hp = require("../support/helper.js"); function initMain(name, version) { @@ -22,7 +21,7 @@ const SDK_VERSION = "24.4.1"; describe("Bridged SDK Utilities Tests", () => { it("Check if we can override sdk name and version successful", () => { hp.haltAndClearStorage(() => { - initMain("javascript_gtm_web", "24.0.0"); + initMain('javascript_gtm_web', '24.0.0'); hp.events(); cy.fetch_local_request_queue().then((eq) => { expect(eq).to.have.length(1); @@ -33,7 +32,7 @@ describe("Bridged SDK Utilities Tests", () => { }); it("Check if SDK uses default values if SDK name and version was not overriden", () => { hp.haltAndClearStorage(() => { - initMain(undefined, undefined); + initMain(undefined, undefined); hp.events(); cy.fetch_local_request_queue().then((eq) => { expect(eq).to.have.length(1); diff --git a/cypress/integration/consents.js b/cypress/e2e/consents.cy.js similarity index 96% rename from cypress/integration/consents.js rename to cypress/e2e/consents.cy.js index 4d4473f4..2c747cd2 100644 --- a/cypress/integration/consents.js +++ b/cypress/e2e/consents.cy.js @@ -1,12 +1,13 @@ /* eslint-disable cypress/no-unnecessary-waiting */ /* eslint-disable require-jsdoc */ var Countly = require("../../lib/countly"); -var hp = require("../support/helper"); +// import * as Countly from "../../dist/countly_umd.js"; +var hp = require("../support/helper.js"); function initMain(consent) { Countly.init({ app_key: "YOUR_APP_KEY", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", require_consent: consent, device_id: "György Ligeti", test_mode: true, diff --git a/cypress/integration/crashes.js b/cypress/e2e/crashes.cy.js similarity index 90% rename from cypress/integration/crashes.js rename to cypress/e2e/crashes.cy.js index bc06b0dc..c766d80d 100644 --- a/cypress/integration/crashes.js +++ b/cypress/e2e/crashes.cy.js @@ -5,7 +5,7 @@ var hp = require("../support/helper"); function initMain() { Countly.init({ app_key: "YOUR_APP_KEY", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", test_mode: true }); } @@ -26,7 +26,7 @@ describe("Crashes tests ", () => { catch (err) { Countly.log_error(err); } - cy.wait(3000).then(() => { + cy.wait(1000).then(() => { cy.fetch_local_request_queue().then((rq) => { cy.check_crash(rq[0], hp.appKey); }); diff --git a/cypress/integration/device_id.js b/cypress/e2e/device_id.cy.js similarity index 99% rename from cypress/integration/device_id.js rename to cypress/e2e/device_id.cy.js index b85c7cdf..82011ca5 100644 --- a/cypress/integration/device_id.js +++ b/cypress/e2e/device_id.cy.js @@ -5,7 +5,7 @@ var hp = require("../support/helper"); function initMain(deviceId, offline, searchQuery, clear, rq, eq) { Countly.init({ app_key: "YOUR_APP_KEY", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", device_id: deviceId, test_mode: rq, test_mode_eq: eq, diff --git a/cypress/integration/device_id_change.js b/cypress/e2e/device_id_change.cy.js similarity index 95% rename from cypress/integration/device_id_change.js rename to cypress/e2e/device_id_change.cy.js index 9cc3a269..dbb3adfa 100644 --- a/cypress/integration/device_id_change.js +++ b/cypress/e2e/device_id_change.cy.js @@ -1,5 +1,5 @@ var Countly = require("../../lib/countly"); -var hp = require("../support/helper"); +var hp = require("../support/helper.js"); // ======================================== // Device ID change tests @@ -14,7 +14,7 @@ var hp = require("../support/helper"); function initMain(offline) { Countly.init({ app_key: "YOUR_APP_KEY", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", test_mode: true, debug: true, offline_mode: offline @@ -220,7 +220,7 @@ describe("Device ID change tests ", ()=>{ }); describe("Set ID change tests ", () => { - it("set_id should be non merge as there was dev provided id", () => { + it('set_id should be non merge as there was dev provided id', () => { hp.haltAndClearStorage(() => { Countly.init({ app_key: "YOUR_APP_KEY", @@ -239,16 +239,16 @@ describe("Set ID change tests ", () => { cy.fetch_local_request_queue().then((eq2) => { expect(eq2.length).to.equal(3); // no merge request expect(eq2[0].device_id).to.equal("old ID"); - expect(eq2[0].events).to.contains("\"key\":\"1\""); + expect(eq2[0].events).to.contains('"key\":\"1\"'); expect(eq2[1].device_id).to.equal("new ID"); expect(eq2[1].begin_session).to.equal(1); expect(eq2[2].device_id).to.equal("new ID"); - expect(eq2[2].events).to.contains("\"key\":\"2\""); + expect(eq2[2].events).to.contains('"key\":\"2\"'); }); }); }); }); - it("set_id should be merge as there was sdk generated id", () => { + it('set_id should be merge as there was sdk generated id', () => { hp.haltAndClearStorage(() => { initMain(false); // init normally Countly.add_event(eventObj("1")); // record an event. @@ -264,13 +264,14 @@ describe("Set ID change tests ", () => { cy.log(eq2); expect(eq2.length).to.equal(3); // merge request expect(eq2[0].device_id).to.equal(generatedID); - expect(eq2[0].events).to.contains("\"key\":\"1\""); + expect(eq2[0].events).to.contains('"key\":\"1\"'); expect(eq2[1].device_id).to.equal("new ID"); expect(eq2[1].old_device_id).to.equal(generatedID); expect(eq2[2].device_id).to.equal("new ID"); - expect(eq2[2].events).to.contains("\"key\":\"2\""); + expect(eq2[2].events).to.contains('"key\":\"2\"'); }); }); }); }); + }); diff --git a/cypress/integration/device_id_init_scenarios.js b/cypress/e2e/device_id_init_scenarios.cy.js similarity index 99% rename from cypress/integration/device_id_init_scenarios.js rename to cypress/e2e/device_id_init_scenarios.cy.js index 92765070..4ff80b68 100644 --- a/cypress/integration/device_id_init_scenarios.js +++ b/cypress/e2e/device_id_init_scenarios.cy.js @@ -90,7 +90,7 @@ var hp = require("../support/helper"); function initMain(deviceId, offline, searchQuery, clear) { Countly.init({ app_key: "YOUR_APP_KEY", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", device_id: deviceId, test_mode: true, debug: true, diff --git a/cypress/integration/events.js b/cypress/e2e/events.cy.js similarity index 99% rename from cypress/integration/events.js rename to cypress/e2e/events.cy.js index d63210c4..b0dd9380 100644 --- a/cypress/integration/events.js +++ b/cypress/e2e/events.cy.js @@ -6,7 +6,7 @@ var hp = require("../support/helper"); function initMain() { Countly.init({ app_key: "YOUR_APP_KEY", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", session_update: 3, test_mode: true, test_mode_eq: true, diff --git a/cypress/integration/health_check.js b/cypress/e2e/health_check.cy.js similarity index 90% rename from cypress/integration/health_check.js rename to cypress/e2e/health_check.cy.js index 5c433e68..d3d1babc 100644 --- a/cypress/integration/health_check.js +++ b/cypress/e2e/health_check.cy.js @@ -5,7 +5,7 @@ var hp = require("../support/helper"); function initMain() { Countly.init({ app_key: "YOUR_APP_KEY", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", test_mode: true }); } @@ -14,7 +14,7 @@ describe("Health Check tests ", () => { it("Check if health check is sent at the beginning", () => { hp.haltAndClearStorage(() => { initMain(); - cy.intercept("https://your.domain.countly/i?*").as("getXhr"); + cy.intercept("https://your.domain.count.ly/i?*").as("getXhr"); cy.wait("@getXhr").then((xhr) => { const url = new URL(xhr.request.url); diff --git a/cypress/integration/heatmaps.js b/cypress/e2e/heatmaps.cy.js similarity index 97% rename from cypress/integration/heatmaps.js rename to cypress/e2e/heatmaps.cy.js index 2bfb38e0..ca5d4694 100644 --- a/cypress/integration/heatmaps.js +++ b/cypress/e2e/heatmaps.cy.js @@ -11,8 +11,10 @@ function click_check(segmentation, offX, offY) { expect(segmentation.height).to.be.ok; expect(segmentation.view).to.be.ok; expect(segmentation.width).to.be.ok; - expect(segmentation.x).to.equal(clickX + offX); - expect(segmentation.y).to.equal(clickY + offY); + expect(segmentation.x).to.be.above(clickX + offX - 2); + expect(segmentation.x).to.be.below(clickX + offX + 2); + expect(segmentation.y).to.be.above(clickY + offY - 2); + expect(segmentation.y).to.be.below(clickY + offY + 2); } describe("Browser heatmap tests, scrolls", () => { diff --git a/cypress/integration/integration.js b/cypress/e2e/integration.cy.js similarity index 93% rename from cypress/integration/integration.js rename to cypress/e2e/integration.cy.js index 6ad6664e..2273d158 100644 --- a/cypress/integration/integration.js +++ b/cypress/e2e/integration.cy.js @@ -7,7 +7,7 @@ var hp = require("../support/helper"); function initMain() { Countly.init({ app_key: "YOUR_APP_KEY", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", debug: true, test_mode: true }); @@ -50,7 +50,7 @@ describe("Integration test", () => { // TODO: make better cy.fetch_local_request_queue().then((rq) => { cy.log(rq); - hp.testNormalFlow(rq, "/__cypress/iframes/integration%2Fintegration.js", hp.appKey); + hp.testNormalFlow(rq, "/__cypress/iframes/cypress%5Ce2e%5Cintegration.cy.js", hp.appKey); expect(consentStatus).to.equal(true); // no consent necessary expect(remote).to.eql({}); // deepEqual expect(rq[0].device_id).to.equal(id); diff --git a/cypress/integration/internal_limits.js b/cypress/e2e/internal_limits.cy.js similarity index 99% rename from cypress/integration/internal_limits.js rename to cypress/e2e/internal_limits.cy.js index d1f94eb9..39a6528b 100644 --- a/cypress/integration/internal_limits.js +++ b/cypress/e2e/internal_limits.cy.js @@ -15,7 +15,7 @@ const limits = { function initMain() { Countly.init({ app_key: "YOUR_APP_KEY", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", test_mode_eq: true, test_mode: true, debug: true, diff --git a/cypress/integration/manual_widget_reporting.js b/cypress/e2e/manual_widget_reporting.cy.js similarity index 99% rename from cypress/integration/manual_widget_reporting.js rename to cypress/e2e/manual_widget_reporting.cy.js index a120f924..24008310 100644 --- a/cypress/integration/manual_widget_reporting.js +++ b/cypress/e2e/manual_widget_reporting.cy.js @@ -58,7 +58,7 @@ function common_rating_check(param, num) { function initMain() { Countly.init({ app_key: "YOUR_APP_KEY", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", test_mode_eq: true, test_mode: true, debug: true diff --git a/cypress/integration/multi_instance.js b/cypress/e2e/multi_instance.cy.js similarity index 100% rename from cypress/integration/multi_instance.js rename to cypress/e2e/multi_instance.cy.js diff --git a/cypress/integration/remaining_requests.js b/cypress/e2e/remaining_requests.cy.js similarity index 95% rename from cypress/integration/remaining_requests.js rename to cypress/e2e/remaining_requests.cy.js index f9265dec..08745c9f 100644 --- a/cypress/integration/remaining_requests.js +++ b/cypress/e2e/remaining_requests.cy.js @@ -5,7 +5,7 @@ var hp = require("../support/helper"); function initMain(shouldStopRequests) { Countly.init({ app_key: "YOUR_APP_KEY", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", app_version: "1.0", // would prevent requests from being sent to the server if true test_mode: shouldStopRequests @@ -36,7 +36,7 @@ describe("Remaining requests tests ", () => { }); // End the session Countly.end_session(undefined, true); - hp.interceptAndCheckRequests(undefined, undefined, undefined, undefined, "end_session", (requestParams) => { + hp.interceptAndCheckRequests(undefined, undefined, undefined, "?end_session=*", "end", (requestParams) => { expect(requestParams.get("end_session")).to.equal("1"); expect(requestParams.get("rr")).to.equal("2"); expect(requestParams.get("av")).to.equal(av); diff --git a/cypress/integration/reponse_validation.js b/cypress/e2e/reponse_validation.cy.js similarity index 99% rename from cypress/integration/reponse_validation.js rename to cypress/e2e/reponse_validation.cy.js index 01d58c71..a230ba8b 100644 --- a/cypress/integration/reponse_validation.js +++ b/cypress/e2e/reponse_validation.cy.js @@ -10,7 +10,7 @@ var hp = require("../support/helper"); function initMain() { Countly.init({ app_key: "YOUR_APP_KEY", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", test_mode: true, test_mode_eq: true, debug: true diff --git a/cypress/integration/salt.js b/cypress/e2e/salt.cy.js similarity index 93% rename from cypress/integration/salt.js rename to cypress/e2e/salt.cy.js index 4a7b1356..4479e481 100644 --- a/cypress/integration/salt.js +++ b/cypress/e2e/salt.cy.js @@ -1,9 +1,8 @@ /* eslint-disable cypress/no-unnecessary-waiting */ /* eslint-disable require-jsdoc */ var Countly = require("../../lib/countly"); -// import * as Countly from "../../dist/countly_umd.js"; var hp = require("../support/helper.js"); -const crypto = require("crypto"); +const crypto = require('crypto'); function initMain(salt) { Countly.init({ @@ -49,7 +48,7 @@ describe("Salt Tests", () => { hp.haltAndClearStorage(() => { initMain(salt); var rqArray = []; - hp.events(); + hp.events(); cy.intercept("GET", "**/i?**", (req) => { const { url } = req; rqArray.push(url.split("?")[1]); @@ -81,7 +80,7 @@ describe("Salt Tests", () => { * @returns {string} - sha256 hash */ function sha256(data) { - const hash = crypto.createHash("sha256"); + const hash = crypto.createHash('sha256'); hash.update(data); - return hash.digest("hex"); + return hash.digest('hex'); } \ No newline at end of file diff --git a/cypress/integration/sessions.js b/cypress/e2e/sessions.cy.js similarity index 59% rename from cypress/integration/sessions.js rename to cypress/e2e/sessions.cy.js index 0d03a4ab..5904e4b6 100644 --- a/cypress/integration/sessions.js +++ b/cypress/e2e/sessions.cy.js @@ -3,7 +3,7 @@ var Countly = require("../../lib/countly"); var hp = require("../support/helper"); // if you are testing on an app const app_key = hp.appKey; -const waitTime = 4000; +const waitTime = 7000; const eventObj = { key: "buttonClick", count: 1, @@ -15,7 +15,7 @@ const eventObj = { function initMain() { Countly.init({ app_key: "YOUR_APP_KEY", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", session_update: 3, test_mode: true }); @@ -30,7 +30,7 @@ const dummyQueue = [ describe("Session tests ", () => { it("Checks if session start, extension and ending works with a dummy queue", () => { hp.haltAndClearStorage(() => { - // initialize countly + // initialize countly initMain(); // begin session Countly.begin_session(); @@ -50,7 +50,7 @@ describe("Session tests ", () => { }); it("Checks if session start, extension and ending works", () => { hp.haltAndClearStorage(() => { - // initialize countly + // initialize countly initMain(); // begin session Countly.begin_session(); @@ -73,15 +73,24 @@ describe("Session tests ", () => { }); }); }); - describe("Browser session tests, auto", () => { it("Single session test with auto sessions", () => { cy.visit("./cypress/fixtures/session_test_auto.html?use_session_cookie=true") .wait(waitTime); - cy.contains("Event").click().wait(1000); + cy.contains("Event").click().wait(300); cy.visit("./cypress/fixtures/base.html"); cy.fetch_local_request_queue(app_key).then((rq) => { - checkQueueForSessionTests(rq, 5, 4); + cy.log(rq); + // 3 session and 1 orientation 1 event + expect(rq.length).to.equal(5); + // first object of the queue should be about begin session, second is orientation + cy.check_session(rq[0], undefined, undefined, app_key); + // third object of the queue should be about session extension, also input the expected duration + cy.check_session(rq[2], 5, undefined, app_key); + // fourth object of the queue should be about event sent + cy.check_event(JSON.parse(rq[3].events)[0], eventObj, undefined, false); + // fifth object of the queue should be about session extension, also input the expected duration + cy.check_session(rq[4], 1, undefined, app_key); }); }); }); @@ -89,21 +98,41 @@ describe("Browser session tests, manual 1", () => { it("Single sessions test with manual sessions", () => { cy.visit("./cypress/fixtures/session_test_manual_1.html?use_session_cookie=true"); cy.contains("Start").click().wait(waitTime); - cy.contains("Event").click().wait(500); - cy.contains("End").click().wait(500); + cy.contains("Event").click().wait(300); + cy.contains("End").click().wait(300); cy.visit("./cypress/fixtures/base.html"); cy.fetch_local_request_queue(app_key).then((rq) => { - checkQueueForSessionTests(rq, 4, 4); + cy.log(rq); + // 3 session and 1 orientation 1 event + expect(rq.length).to.equal(5); + // first object of the queue should be about begin session, second is orientation + cy.check_session(rq[0], undefined, undefined, app_key); + // third object of the queue should be about session extension, also input the expected duration + cy.check_session(rq[2], 5, undefined, app_key); + // fourth object of the queue should be about event sent + cy.check_event(JSON.parse(rq[3].events)[0], eventObj, undefined, false); + // fifth object of the queue should be about session extension, also input the expected duration + cy.check_session(rq[4], 1, undefined, app_key); }); }); }); describe("Browser session tests, manual 2", () => { it("Single bounce test with manual sessions 2", () => { cy.visit("./cypress/fixtures/session_test_manual_2.html?use_session_cookie=true").wait(waitTime); - cy.contains("Event").click().wait(500); + cy.contains("Event").click().wait(300); cy.visit("./cypress/fixtures/base.html"); cy.fetch_local_request_queue(app_key).then((rq) => { - checkQueueForSessionTests(rq, 4, 4); + cy.log(rq); + // 3 session and 1 orientation 1 event + expect(rq.length).to.equal(5); + // first object of the queue should be about begin session, second is orientation + cy.check_session(rq[0], undefined, undefined, app_key); + // third object of the queue should be about session extension, also input the expected duration + cy.check_session(rq[2], 5, undefined, app_key); + // fourth object of the queue should be about event sent + cy.check_event(JSON.parse(rq[3].events)[0], eventObj, undefined, false); + // fifth object of the queue should be about session extension, also input the expected duration + cy.check_session(rq[4], 1, undefined, app_key); }); }); }); @@ -111,10 +140,20 @@ describe("Browser session tests, auto, no cookie", () => { it("Single bounce test with auto sessions and no cookies", () => { cy.visit("./cypress/fixtures/session_test_auto.html") .wait(waitTime); - cy.contains("Event").click().wait(500); + cy.contains("Event").click().wait(300); cy.visit("./cypress/fixtures/base.html"); cy.fetch_local_request_queue(app_key).then((rq) => { - checkQueueForSessionTests(rq, 5, 4); + cy.log(rq); + // 3 session and 1 orientation 1 event + expect(rq.length).to.equal(5); + // first object of the queue should be about begin session, second is orientation + cy.check_session(rq[0], undefined, undefined, app_key); + // third object of the queue should be about session extension, also input the expected duration + cy.check_session(rq[2], 5, undefined, app_key); + // fourth object of the queue should be about event sent + cy.check_event(JSON.parse(rq[3].events)[0], eventObj, undefined, false); + // fifth object of the queue should be about session extension, also input the expected duration + cy.check_session(rq[4], 1, true, app_key); }); }); }); @@ -124,12 +163,22 @@ describe("Browser session tests, manual 1, no cookie", () => { cy.contains("Start").click(); cy.wait(waitTime); cy.contains("Event").click(); - cy.wait(500); + cy.wait(300); cy.contains("End").click(); - cy.wait(500); + cy.wait(300); cy.visit("./cypress/fixtures/base.html"); cy.fetch_local_request_queue(app_key).then((rq) => { - checkQueueForSessionTests(rq, 5, 4); + cy.log(rq); + // 3 session and 1 orientation 1 event + expect(rq.length).to.equal(5); + // first object of the queue should be about begin session, second is orientation + cy.check_session(rq[0], undefined, undefined, app_key); + // third object of the queue should be about session extension, also input the expected duration + cy.check_session(rq[2], 5, undefined, app_key); + // fourth object of the queue should be about event sent + cy.check_event(JSON.parse(rq[3].events)[0], eventObj, undefined, false); + // fifth object of the queue should be about session extension, also input the expected duration + cy.check_session(rq[4], 1, true, app_key); }); }); }); @@ -139,15 +188,24 @@ describe("Browser session tests, manual 2, no cookie", () => { cy.contains("Event").click().wait(500); cy.visit("./cypress/fixtures/base.html"); cy.fetch_local_request_queue(app_key).then((rq) => { - checkQueueForSessionTests(rq, 5, 4); + cy.log(rq); + // 3 session and 1 orientation 1 event + expect(rq.length).to.equal(5); + // first object of the queue should be about begin session, second is orientation + cy.check_session(rq[0], undefined, undefined, app_key); + // third object of the queue should be about session extension, also input the expected duration + cy.check_session(rq[2], 5, undefined, app_key); + // fourth object of the queue should be about event sent + cy.check_event(JSON.parse(rq[3].events)[0], eventObj, undefined, false); + // fifth object of the queue should be about session extension, also input the expected duration + cy.check_session(rq[4], 1, true, app_key); }); }); }); - describe("Check request related functions", () => { it("Check if prepareRequest forms a proper request object", () => { hp.haltAndClearStorage(() => { - // initialize countly + // initialize countly initMain(); let reqObject = {}; Countly._internals.prepareRequest(reqObject); @@ -157,7 +215,7 @@ describe("Check request related functions", () => { }); it("Check if prepareRequest forms a proper request object from a bad one ", () => { hp.haltAndClearStorage(() => { - // initialize countly + // initialize countly initMain(); let reqObject = { app_key: null, device_id: null }; Countly._internals.prepareRequest(reqObject); @@ -167,7 +225,7 @@ describe("Check request related functions", () => { }); it("Check if prepareRequest forms a proper request object and not erase an extra value ", () => { hp.haltAndClearStorage(() => { - // initialize countly + // initialize countly initMain(); let reqObject = { extraKey: "value" }; Countly._internals.prepareRequest(reqObject); @@ -176,35 +234,4 @@ describe("Check request related functions", () => { cy.check_request_commons(reqObject); }); }); -}); - -/** - * checks the queue for session tests - * @param {*} queue - queue to check - * @param {*} expectedLength - expected length of the queue - * @param {*} sessionDuration - expected session duration - */ -function checkQueueForSessionTests(queue, expectedLength, sessionDuration) { - expect(queue.length).to.be.within(expectedLength - 1, expectedLength + 1); - let beginSes = 1; - for (let i = 0; i < queue.length; i++) { - const currentRequest = queue[i]; - if (currentRequest.begin_session) { - cy.check_session(currentRequest, undefined, undefined, app_key); - beginSes--; - } - else if (currentRequest.events) { - const event = JSON.parse(currentRequest.events)[0]; - if (event.key === "buttonClick") { - cy.check_event(event, eventObj, undefined, false); - } - } - else if (currentRequest.session_duration) { - cy.check_session(currentRequest, sessionDuration, undefined, app_key); - } - else if (currentRequest.end_session) { - cy.check_session(currentRequest, 0, true, app_key); - } - } - expect(beginSes).to.equal(0); -} \ No newline at end of file +}); \ No newline at end of file diff --git a/cypress/integration/storage.js b/cypress/e2e/storage.cy.js similarity index 95% rename from cypress/integration/storage.js rename to cypress/e2e/storage.cy.js index b9cfc8e1..40b0b58b 100644 --- a/cypress/integration/storage.js +++ b/cypress/e2e/storage.cy.js @@ -5,7 +5,7 @@ var hp = require("../support/helper"); function initMain(val) { Countly.init({ app_key: "YOUR_APP_KEY", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", test_mode_eq: true, test_mode: true, debug: true, @@ -37,7 +37,7 @@ for (let i = 0; i < 5; i++) { } else if (isNone) { expect(value).to.equal(null); - expect(document.cookie).to.equal(""); + expect(document.cookie).to.equal("__cypress.initial=true"); // since cypress 13.6 } else { expect(value).to.equal(valueToStore); @@ -49,7 +49,7 @@ for (let i = 0; i < 5; i++) { hp.haltAndClearStorage(() => { initMain(flag); if (isNone) { - expect(document.cookie).to.equal(""); + expect(document.cookie).to.equal("__cypress.initial=true"); // since cypress 13.6 } Countly._internals.setValueInStorage(key, valueToStore); expect(isNone ? undefined : valueToStore).to.equal(Countly._internals.getValueFromStorage(key)); @@ -65,7 +65,7 @@ for (let i = 0; i < 5; i++) { hp.haltAndClearStorage(() => { initMain(flag); if (isNone) { - expect(document.cookie).to.equal(""); + expect(document.cookie).to.equal("__cypress.initial=true"); // since cypress 13.6 } Countly._internals.setValueInStorage(key, valueToStore); expect(isNone ? undefined : valueToStore).to.equal(Countly._internals.getValueFromStorage(key)); @@ -85,7 +85,7 @@ for (let i = 0; i < 5; i++) { expect(value).to.equal(null); }); if (isNone || isLocal) { - expect(document.cookie).to.equal(""); + expect(document.cookie).to.equal("__cypress.initial=true"); // since cypress 13.6 } else { expect(document.cookie).to.include(`${hp.appKey}/${key}=${valueToStore}`); diff --git a/cypress/integration/storage_change.js b/cypress/e2e/storage_change.cy.js similarity index 97% rename from cypress/integration/storage_change.js rename to cypress/e2e/storage_change.cy.js index 101e6360..330293db 100644 --- a/cypress/integration/storage_change.js +++ b/cypress/e2e/storage_change.cy.js @@ -6,7 +6,7 @@ import { triggerStorageChange } from "../support/integration_helper"; function initMain(val) { Countly.init({ app_key: "YOUR_APP_KEY", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", device_id: 0, // provide number test_mode_eq: true, test_mode: true, @@ -78,7 +78,7 @@ describe("Multi tab storage change test", () => { hp.haltAndClearStorage(() => { let firstIns = Countly.init({ app_key: "YOUR_APP_KEY1", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", device_id: 0, test_mode_eq: true, test_mode: true, @@ -87,7 +87,7 @@ describe("Multi tab storage change test", () => { }); let secondIns = Countly.init({ app_key: "YOUR_APP_KEY2", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", device_id: -1, test_mode_eq: true, test_mode: true, diff --git a/cypress/integration/user_agent.js b/cypress/e2e/user_agent.cy.js similarity index 90% rename from cypress/integration/user_agent.js rename to cypress/e2e/user_agent.cy.js index 9ad95de8..54143c96 100644 --- a/cypress/integration/user_agent.js +++ b/cypress/e2e/user_agent.cy.js @@ -6,7 +6,7 @@ var hp = require("../support/helper"); function initMain() { Countly.init({ app_key: "YOUR_APP_KEY", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", test_mode_eq: true }); } @@ -64,4 +64,10 @@ describe("User Agent tests ", () => { expect(Countly._internals.userAgentSearchBotDetection("Lighthouse")).to.equal(true); }); }); + // userAgentData is not supported by all browsers yet so it is hard to test with consistency + it("Check if currentUserAgentDataString override works", () => { + hp.haltAndClearStorage(() => { + expect(Countly._internals.currentUserAgentDataString('123')).to.equal("123"); + }); + }); }); diff --git a/cypress/integration/user_details.js b/cypress/e2e/user_details.cy.js similarity index 99% rename from cypress/integration/user_details.js rename to cypress/e2e/user_details.cy.js index 925ee8aa..d9446bcd 100644 --- a/cypress/integration/user_details.js +++ b/cypress/e2e/user_details.cy.js @@ -6,7 +6,7 @@ var hp = require("../support/helper"); function initMain() { Countly.init({ app_key: "YOUR_APP_KEY", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", test_mode_eq: true, test_mode: true }); diff --git a/cypress/integration/utm.js b/cypress/e2e/utm.cy.js similarity index 89% rename from cypress/integration/utm.js rename to cypress/e2e/utm.cy.js index 34e9102f..a9c7621b 100644 --- a/cypress/integration/utm.js +++ b/cypress/e2e/utm.cy.js @@ -5,7 +5,7 @@ var hp = require("../support/helper"); function initMulti(appKey, searchQuery, utmStuff) { Countly.init({ app_key: appKey, - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", test_mode: true, test_mode_eq: true, utm: utmStuff, @@ -19,7 +19,7 @@ describe("UTM tests ", () => { it("Checks if a single default utm tag works", () => { hp.haltAndClearStorage(() => { initMulti("YOUR_APP_KEY", "?utm_source=hehe", undefined); - Countly.q.push(["track_errors"]); // adding this as calling it during init used to cause an error (at v23.12.5) + Countly.q.push(['track_errors']); // adding this as calling it during init used to cause an error (at v23.12.5) cy.fetch_local_request_queue().then((rq) => { cy.log(rq); const custom = JSON.parse(rq[0].user_details).custom; @@ -29,7 +29,7 @@ describe("UTM tests ", () => { }); it("Checks if default utm tags works", () => { hp.haltAndClearStorage(() => { - initMulti("YOUR_APP_KEY", "?utm_source=hehe&utm_medium=hehe1&utm_campaign=hehe2&utm_term=hehe3&utm_content=hehe4", undefined); + initMulti("YOUR_APP_KEY", "utm_source=hehe&utm_medium=hehe1&utm_campaign=hehe2&utm_term=hehe3&utm_content=hehe4", undefined); cy.fetch_local_request_queue().then((rq) => { cy.log(rq); const custom = JSON.parse(rq[0].user_details).custom; @@ -39,7 +39,7 @@ describe("UTM tests ", () => { }); it("Checks if a single custom utm tag works", () => { hp.haltAndClearStorage(() => { - initMulti("YOUR_APP_KEY", "utm_aa=hehe", { aa: true, bb: true }); + initMulti("YOUR_APP_KEY", "?utm_aa=hehe", { aa: true, bb: true }); cy.fetch_local_request_queue().then((rq) => { cy.log(rq); const custom = JSON.parse(rq[0].user_details).custom; @@ -70,13 +70,13 @@ describe("UTM tests ", () => { initMulti("Countly_4", "?utm_source=hehe4", { ss: true }); // utm object not provided with default query - initMulti("Countly_3", "?utm_source=hehe3", undefined); + initMulti("Countly_3", "utm_source=hehe3", undefined); // utm object not provided with inappropriate query - initMulti("Countly_5", "utm_ss=hehe5", undefined); + initMulti("Countly_5", "?utm_ss=hehe5", undefined); // default (original) init with no custom tags and default query - initMulti("YOUR_APP_KEY", "?utm_source=hehe", undefined); + initMulti("YOUR_APP_KEY", "utm_source=hehe", undefined); // check original cy.fetch_local_request_queue().then((rq) => { @@ -111,7 +111,7 @@ describe("UTM tests ", () => { initMulti("YOUR_APP_KEY", "?utm_source=hehe", undefined); // utm object not provided with full + weird query - initMulti("Countly_multi_1", "?utm_source=hehe&utm_medium=hehe1&utm_campaign=hehe2&utm_term=hehe3&utm_content=hehe4&fdsjhflkjhsdlkfjhsdlkjfhksdjhfkj+dsf;jsdlkjflk+=skdjflksjd=fksdfl;sd=sdkfmk&&&", undefined); + initMulti("Countly_multi_1", "utm_source=hehe&utm_medium=hehe1&utm_campaign=hehe2&utm_term=hehe3&utm_content=hehe4&fdsjhflkjhsdlkfjhsdlkjfhksdjhfkj+dsf;jsdlkjflk+=skdjflksjd=fksdfl;sd=sdkfmk&&&", undefined); // utm object given that includes 2 default 1 custom, full plus custom query + gabledeboop initMulti("Countly_multi_2", "?utm_source=hehe&utm_medium=hehe1&utm_campaign=hehe2&utm_term=hehe3&utm_content=hehe4&utm_sthelse=hehe5&fdsjhflkjhsdlkfjhsdlkjfhksdjhfkj+dsf;jsdlkjflk+=skdjflksjd=fksdfl;sd=sdkfmk&&&", { source: true, term: true, sthelse: true }); @@ -172,7 +172,7 @@ describe("UTM tests ", () => { initMulti("Countly_multi_next_1", "?utm_sourcer=hehe&utm_mediumr=hehe1&utm_campaignr=hehe2&utm_rterm=hehe3&utm_corntent=hehe4&fdsjhflkjhsdlkfjhsdlkjfhksdjhfkj+dsf;jsdlkjflk+=skdjflksjd=fksdfl;sd=sdkfmk&&&", undefined); // utm object default, custom query + gabledeboop - initMulti("Countly_multi_next_2", "?utm_sourcer=hehe&utm_mediumr=hehe1&utm_campaignr=hehe2&utm_rterm=hehe3&utm_corntent=hehe4&fdsjhflkjhsdlkfjhsdlkjfhksdjhfkj+dsf;jsdlkjflk+=skdjflksjd=fksdfl;sd=sdkfmk&&&", { source: true, medium: true, campaign: true, term: true, content: true }); + initMulti("Countly_multi_next_2", "utm_sourcer=hehe&utm_mediumr=hehe1&utm_campaignr=hehe2&utm_rterm=hehe3&utm_corntent=hehe4&fdsjhflkjhsdlkfjhsdlkjfhksdjhfkj+dsf;jsdlkjflk+=skdjflksjd=fksdfl;sd=sdkfmk&&&", { source: true, medium: true, campaign: true, term: true, content: true }); // custom utm object, custom query + gabledeboop initMulti("Countly_multi_next_3", "?utm_sauce=hehe&utm_pan=hehe2&dasdashdjkhaslkjdhsakj=dasmndlask=asdkljska&&utm_source=hehe", { sauce: true, pan: true }); diff --git a/cypress/integration/view_utm_referrer.js b/cypress/e2e/view_utm_referrer.cy.js similarity index 97% rename from cypress/integration/view_utm_referrer.js rename to cypress/e2e/view_utm_referrer.cy.js index effdcca8..4b7e0840 100644 --- a/cypress/integration/view_utm_referrer.js +++ b/cypress/e2e/view_utm_referrer.cy.js @@ -5,7 +5,7 @@ var hp = require("../support/helper"); function init(appKey, searchQuery, utmStuff) { Countly.init({ app_key: appKey, - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", test_mode: true, test_mode_eq: true, utm: utmStuff, // utm object provided in init @@ -113,7 +113,7 @@ describe("View with utm and referrer tests ", () => { // we check if multiple custom utm tags are recorded in the view event if they are in the utm object it("Checks if multiple custom utm tags appears in view", () => { hp.haltAndClearStorage(() => { - init("YOUR_APP_KEY", "?utm_aa=hehe&utm_bb=hoho", { aa: true, bb: true }); + init("YOUR_APP_KEY", "utm_aa=hehe&utm_bb=hoho", { aa: true, bb: true }); Countly.track_view(pageNameOne); cy.fetch_local_event_queue().then((eq) => { cy.check_view_event(eq[0], pageNameOne, undefined, false); @@ -166,7 +166,7 @@ describe("View with utm and referrer tests ", () => { // default (original) init with no custom tags and default query var C1 = Countly.init({ app_key: "YOUR_APP_KEY", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", test_mode: true, test_mode_eq: true, utm: undefined, // utm object provided in init @@ -179,12 +179,12 @@ describe("View with utm and referrer tests ", () => { // utm object provided with appropriate query var C2 = Countly.init({ app_key: "Countly_2", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", test_mode: true, test_mode_eq: true, utm: { ss: true }, // utm object provided in init getSearchQuery: function() { // override default search query - return "?utm_ss=hehe2"; + return "utm_ss=hehe2"; } }); C2.track_view(pageNameOne); @@ -278,7 +278,7 @@ describe("isReferrerUsable tests", () => { hp.haltAndClearStorage(() => { Countly.init({ app_key: "YOUR_APP_KEY", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", ignore_referrers: ["http://example.com"] }); const result = Countly._internals.isReferrerUsable("http://example.com/something"); diff --git a/cypress/integration/views.js b/cypress/e2e/views.cy.js similarity index 99% rename from cypress/integration/views.js rename to cypress/e2e/views.cy.js index 236f35e1..4d6a5c58 100644 --- a/cypress/integration/views.js +++ b/cypress/e2e/views.cy.js @@ -6,7 +6,7 @@ var hp = require("../support/helper"); function initMain() { Countly.init({ app_key: "YOUR_APP_KEY", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", test_mode_eq: true, test_mode: true }); diff --git a/cypress/integration/web_worker_queues.js b/cypress/e2e/web_worker_queues.cy.js similarity index 93% rename from cypress/integration/web_worker_queues.js rename to cypress/e2e/web_worker_queues.cy.js index 58dfecad..d612d861 100644 --- a/cypress/integration/web_worker_queues.js +++ b/cypress/e2e/web_worker_queues.cy.js @@ -1,7 +1,7 @@ describe("Web Worker Local Queue Tests", () => { it("Verify queues for all features", () => { // create a worker - const myWorker = new Worker("../../examples/mpa/worker_for_test.js"); + const myWorker = new Worker("../../test_workers/worker_for_test.js", { type: "module" }); // send an event to worker myWorker.postMessage({ data: { key: "key" }, type: "event" }); diff --git a/cypress/integration/web_worker_requests.js b/cypress/e2e/web_worker_requests.cy.js similarity index 70% rename from cypress/integration/web_worker_requests.js rename to cypress/e2e/web_worker_requests.cy.js index b40e8154..2c20cb68 100644 --- a/cypress/integration/web_worker_requests.js +++ b/cypress/e2e/web_worker_requests.cy.js @@ -1,5 +1,6 @@ -import { appKey } from "../support/helper"; +import { turnSearchStringToObject, check_commons } from "../support/helper"; +var expectedRequests = 4; const myEvent = { key: "buttonClick", segmentation: { @@ -10,7 +11,7 @@ const myEvent = { describe("Web Worker Request Intercepting Tests", () => { it("SDK able to send requests for most basic calls", () => { // create a worker - const myWorker = new Worker("../../examples/worker.js"); + const myWorker = new Worker("../../test_workers/worker.js", { type: "module" }); // send an event to worker myWorker.postMessage({ data: myEvent, type: "event" }); @@ -22,8 +23,8 @@ describe("Web Worker Request Intercepting Tests", () => { cy.intercept("GET", "**/i?**", (req) => { const { url } = req; - // check url starts with https://your.domain.countly/i? - assert.isTrue(url.startsWith("https://your.domain.countly/i?")); + // check url starts with https://your.domain.count.ly/i? + assert.isTrue(url.startsWith("https://your.domain.count.ly/i?")); // turn query string into object const paramsObject = turnSearchStringToObject(url.split("?")[1]); @@ -32,7 +33,6 @@ describe("Web Worker Request Intercepting Tests", () => { check_commons(paramsObject); // we expect 4 requests: begin_session, end_session, healthcheck, event(event includes view and buttonClick) - let expectedRequests = 4; if (paramsObject.hc) { // check hc params types, values can change assert.isTrue(typeof paramsObject.hc.el === "number"); @@ -83,43 +83,3 @@ describe("Web Worker Request Intercepting Tests", () => { }); }); }); - -/** - * Check common params for all requests - * @param {Object} paramsObject - object from search string - */ -function check_commons(paramsObject) { - expect(paramsObject.timestamp).to.be.ok; - expect(paramsObject.timestamp.toString().length).to.equal(13); - expect(paramsObject.hour).to.be.within(0, 23); - expect(paramsObject.dow).to.be.within(0, 7); - expect(paramsObject.app_key).to.equal(appKey); - expect(paramsObject.device_id).to.be.ok; - expect(paramsObject.sdk_name).to.equal("javascript_native_web"); - expect(paramsObject.sdk_version).to.be.ok; - expect(paramsObject.t).to.be.within(0, 3); - expect(paramsObject.av).to.equal(0); // av is 0 as we parsed parsable things - if (!paramsObject.hc) { // hc is direct request - expect(paramsObject.rr).to.be.above(-1); - } - expect(paramsObject.metrics._ua).to.be.ok; -} - -/** - * Turn search string into object with values parsed - * @param {String} searchString - search string - * @returns {object} - object from search string - */ -function turnSearchStringToObject(searchString) { - const searchParams = new URLSearchParams(searchString); - const paramsObject = {}; - for (const [key, value] of searchParams.entries()) { - try { - paramsObject[key] = JSON.parse(value); // try to parse value - } - catch (e) { - paramsObject[key] = value; - } - } - return paramsObject; -} \ No newline at end of file diff --git a/cypress/fixtures/click_test.html b/cypress/fixtures/click_test.html index 1e5e3b04..bca3ef33 100644 --- a/cypress/fixtures/click_test.html +++ b/cypress/fixtures/click_test.html @@ -19,7 +19,7 @@ var domEl = queryExtractor(window.location.search).dom; Countly.init({ app_key: "YOUR_APP_KEY", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", debug: true, test_mode: true }) diff --git a/cypress/fixtures/multi_instance.html b/cypress/fixtures/multi_instance.html index b3deb9bd..fa9ddacb 100644 --- a/cypress/fixtures/multi_instance.html +++ b/cypress/fixtures/multi_instance.html @@ -22,7 +22,7 @@ //initializing first instance, which will be global Countly Countly.init({ app_key: "YOUR_APP_KEY1", - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", test_mode: true }) Countly.remove_consent(); @@ -57,7 +57,7 @@ //initialize second instance for another app synchronously var Countly2 = Countly.init({ app_key: "YOUR_APP_KEY2", //must have different APP key - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", test_mode: true }); @@ -94,7 +94,7 @@ //initialize third instance for another app asynchronously Countly.q.push(["init", { app_key: "YOUR_APP_KEY3", //must have different APP key - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", test_mode: true }]) @@ -128,7 +128,7 @@ //initialize fourth instance for another app asynchronously Countly.q.push(["init", { app_key: "YOUR_APP_KEY4", //must have different APP key - url: "https://your.domain.countly", + url: "https://your.domain.count.ly", test_mode: true }]) diff --git a/cypress/fixtures/referrer.html b/cypress/fixtures/referrer.html index 527414f1..5b94d0a5 100644 --- a/cypress/fixtures/referrer.html +++ b/cypress/fixtures/referrer.html @@ -4,7 +4,7 @@ -