|
1 | | -/* eslint-disable cypress/no-unnecessary-waiting */ |
2 | 1 | /* eslint-disable require-jsdoc */ |
3 | 2 | var Countly = require("../../lib/countly"); |
4 | | -// import * as Countly from "../../dist/countly_umd.js"; |
5 | | -var hp = require("../support/helper.js"); |
| 3 | +var hp = require("../support/helper"); |
6 | 4 |
|
7 | 5 | function initMain(clear) { |
8 | 6 | Countly.init({ |
@@ -62,22 +60,22 @@ describe("Test Countly.q related methods and processes", () => { |
62 | 60 | // Check that the .q is empty |
63 | 61 | expect(Countly.q.length).to.equal(0); |
64 | 62 |
|
65 | | - cy.fetch_local_request_queue().then((rq_2) => { |
| 63 | + cy.fetch_local_request_queue().then((rq) => { |
66 | 64 | // Check that nothing sent to request queue |
67 | | - expect(rq_2.length).to.equal(0); |
| 65 | + expect(rq.length).to.equal(0); |
68 | 66 | cy.fetch_local_event_queue().then((eq) => { |
69 | 67 | // Check that events are now in event queue |
70 | 68 | expect(eq.length).to.equal(4); |
71 | 69 |
|
72 | 70 | // Send events from event queue to request queue |
73 | 71 | Countly._internals.sendEventsForced(); |
74 | | - cy.fetch_local_event_queue().then((eq_2) => { |
| 72 | + cy.fetch_local_event_queue().then((eq) => { |
75 | 73 | // Check that event queue is empty |
76 | | - expect(eq_2.length).to.equal(0); |
77 | | - cy.fetch_local_request_queue().then((rq_3) => { |
| 74 | + expect(eq.length).to.equal(0); |
| 75 | + cy.fetch_local_request_queue().then((rq) => { |
78 | 76 | // Check that events are now in request queue |
79 | | - expect(rq_3.length).to.equal(1); |
80 | | - const eventsArray = JSON.parse(rq_3[0].events); |
| 77 | + expect(rq.length).to.equal(1); |
| 78 | + const eventsArray = JSON.parse(rq[0].events); |
81 | 79 | expect(eventsArray[0].key).to.equal("event_1"); |
82 | 80 | expect(eventsArray[1].key).to.equal("event_2"); |
83 | 81 | expect(eventsArray[2].key).to.equal("event_3"); |
@@ -125,16 +123,16 @@ describe("Test Countly.q related methods and processes", () => { |
125 | 123 | // Check that event queue has new device ID's orientation event |
126 | 124 | expect(eq.length).to.equal(1); |
127 | 125 | expect(eq[0].key).to.equal("[CLY]_orientation"); |
128 | | - cy.fetch_local_request_queue().then((rq_2) => { |
| 126 | + cy.fetch_local_request_queue().then((rq) => { |
129 | 127 | // Check that events are now in request queue (second request is begin session for new device ID) |
130 | | - expect(rq_2.length).to.equal(2); |
131 | | - const eventsArray = JSON.parse(rq_2[0].events); |
| 128 | + expect(rq.length).to.equal(2); |
| 129 | + const eventsArray = JSON.parse(rq[0].events); |
132 | 130 | expect(eventsArray[0].key).to.equal("event_1"); |
133 | 131 | expect(eventsArray[1].key).to.equal("event_2"); |
134 | 132 | expect(eventsArray[2].key).to.equal("event_3"); |
135 | 133 | expect(eventsArray[3].key).to.equal("event_4"); |
136 | 134 | // check begin session |
137 | | - expect(rq_2[1].begin_session).to.equal(1); |
| 135 | + expect(rq[1].begin_session).to.equal(1); |
138 | 136 | }); |
139 | 137 | }); |
140 | 138 | }); |
@@ -175,16 +173,16 @@ describe("Test Countly.q related methods and processes", () => { |
175 | 173 | cy.fetch_local_event_queue().then((eq) => { |
176 | 174 | // Check that event queue is empty |
177 | 175 | expect(eq.length).to.equal(0); |
178 | | - cy.fetch_local_request_queue().then((rq_2) => { |
| 176 | + cy.fetch_local_request_queue().then((rq) => { |
179 | 177 | // Check that events are now in request queue (second request is user details) |
180 | | - expect(rq_2.length).to.equal(2); |
181 | | - const eventsArray = JSON.parse(rq_2[0].events); |
| 178 | + expect(rq.length).to.equal(2); |
| 179 | + const eventsArray = JSON.parse(rq[0].events); |
182 | 180 | expect(eventsArray[0].key).to.equal("event_1"); |
183 | 181 | expect(eventsArray[1].key).to.equal("event_2"); |
184 | 182 | expect(eventsArray[2].key).to.equal("event_3"); |
185 | 183 | expect(eventsArray[3].key).to.equal("event_4"); |
186 | 184 | // check user details |
187 | | - const user_details = JSON.parse(rq_2[1].user_details); |
| 185 | + const user_details = JSON.parse(rq[1].user_details); |
188 | 186 | expect(user_details.name).to.equal("test_user"); |
189 | 187 | }); |
190 | 188 | }); |
@@ -227,16 +225,16 @@ describe("Test Countly.q related methods and processes", () => { |
227 | 225 | cy.fetch_local_event_queue().then((eq) => { |
228 | 226 | // Check that event queue is empty |
229 | 227 | expect(eq.length).to.equal(0); |
230 | | - cy.fetch_local_request_queue().then((rq_2) => { |
| 228 | + cy.fetch_local_request_queue().then((rq) => { |
231 | 229 | // Check that events are now in request queue (second request is user details) |
232 | | - expect(rq_2.length).to.equal(2); |
233 | | - const eventsArray = JSON.parse(rq_2[0].events); |
| 230 | + expect(rq.length).to.equal(2); |
| 231 | + const eventsArray = JSON.parse(rq[0].events); |
234 | 232 | expect(eventsArray[0].key).to.equal("event_1"); |
235 | 233 | expect(eventsArray[1].key).to.equal("event_2"); |
236 | 234 | expect(eventsArray[2].key).to.equal("event_3"); |
237 | 235 | expect(eventsArray[3].key).to.equal("event_4"); |
238 | 236 | // check user data |
239 | | - const user_details = JSON.parse(rq_2[1].user_details); |
| 237 | + const user_details = JSON.parse(rq[1].user_details); |
240 | 238 | expect(user_details.custom.name).to.equal("test_user"); |
241 | 239 | }); |
242 | 240 | }); |
@@ -267,15 +265,15 @@ describe("Test Countly.q related methods and processes", () => { |
267 | 265 | expect(Countly.q.length).to.equal(4); |
268 | 266 | // Wait for heartBeat to process the .q |
269 | 267 | cy.wait(1500).then(() => { |
270 | | - // Check that the .q is empty |
| 268 | + // Check that the .q is empty |
271 | 269 | expect(Countly.q.length).to.equal(0); |
272 | | - cy.fetch_local_event_queue().then((eq_2) => { |
273 | | - // Check that event queue is empty as all must be in request queue |
274 | | - expect(eq_2.length).to.equal(0); |
275 | | - cy.fetch_local_request_queue().then((rq_2) => { |
276 | | - // Check that events are now in request queue |
277 | | - expect(rq_2.length).to.equal(1); |
278 | | - const eventsArray = JSON.parse(rq_2[0].events); |
| 270 | + cy.fetch_local_event_queue().then((eq) => { |
| 271 | + // Check that event queue is empty as all must be in request queue |
| 272 | + expect(eq.length).to.equal(0); |
| 273 | + cy.fetch_local_request_queue().then((rq) => { |
| 274 | + // Check that events are now in request queue |
| 275 | + expect(rq.length).to.equal(1); |
| 276 | + const eventsArray = JSON.parse(rq[0].events); |
279 | 277 | expect(eventsArray[0].key).to.equal("event_1"); |
280 | 278 | expect(eventsArray[1].key).to.equal("event_2"); |
281 | 279 | expect(eventsArray[2].key).to.equal("event_3"); |
|
0 commit comments