@@ -16,26 +16,32 @@ describe("Remaining requests tests ", () => {
16
16
hp . haltAndClearStorage ( ( ) => {
17
17
initMain ( false ) ;
18
18
19
- // Create a session and end it
20
- Countly . begin_session ( ) ;
21
- Countly . end_session ( undefined , true ) ;
22
-
23
- // We expect 3 requests: begin_session, end_session, orientation
24
- hp . interceptAndCheckRequests ( undefined , undefined , undefined , undefined , "begin_session" , ( requestParams ) => {
25
- expect ( requestParams . get ( "begin_session" ) ) . to . equal ( "1" ) ;
26
- expect ( requestParams . get ( "rr" ) ) . to . equal ( "3" ) ;
27
- } ) ;
28
- hp . interceptAndCheckRequests ( undefined , undefined , undefined , undefined , "end_session" , ( requestParams ) => {
29
- expect ( requestParams . get ( "end_session" ) ) . to . equal ( "1" ) ;
30
- expect ( requestParams . get ( "rr" ) ) . to . equal ( "2" ) ;
19
+ // We will expect 4 requests: health check, begin_session, end_session, orientation
20
+ hp . interceptAndCheckRequests ( undefined , undefined , undefined , "?hc=*" , "hc" , ( requestParams ) => {
21
+ expect ( requestParams . get ( "hc" ) ) . to . equal ( JSON . stringify ( { el : 0 , wl : 0 , sc : - 1 , em : "\"\"" } ) ) ;
22
+ expect ( requestParams . get ( "rr" ) ) . to . equal ( null ) ;
31
23
} ) ;
32
- hp . interceptAndCheckRequests ( undefined , undefined , undefined , undefined , "orientation" , ( requestParams ) => {
33
- expect ( JSON . parse ( requestParams . get ( "events" ) ) [ 0 ] . key ) . to . equal ( "[CLY]_orientation" ) ;
34
- expect ( requestParams . get ( "rr" ) ) . to . equal ( "1" ) ;
35
- } ) ;
36
- cy . wait ( 100 ) . then ( ( ) => {
37
- cy . fetch_local_request_queue ( ) . then ( ( rq ) => {
38
- expect ( rq . length ) . to . equal ( 0 ) ;
24
+ cy . wait ( 1000 ) . then ( ( ) => {
25
+ // Create a session
26
+ Countly . begin_session ( ) ;
27
+ hp . interceptAndCheckRequests ( undefined , undefined , undefined , "?begin_session=*" , "begin_session" , ( requestParams ) => {
28
+ expect ( requestParams . get ( "begin_session" ) ) . to . equal ( "1" ) ;
29
+ expect ( requestParams . get ( "rr" ) ) . to . equal ( "3" ) ;
30
+ } ) ;
31
+ // End the session
32
+ Countly . end_session ( undefined , true ) ;
33
+ hp . interceptAndCheckRequests ( undefined , undefined , undefined , undefined , "end_session" , ( requestParams ) => {
34
+ expect ( requestParams . get ( "end_session" ) ) . to . equal ( "1" ) ;
35
+ expect ( requestParams . get ( "rr" ) ) . to . equal ( "2" ) ;
36
+ } ) ;
37
+ hp . interceptAndCheckRequests ( undefined , undefined , undefined , undefined , "orientation" , ( requestParams ) => {
38
+ expect ( JSON . parse ( requestParams . get ( "events" ) ) [ 0 ] . key ) . to . equal ( "[CLY]_orientation" ) ;
39
+ expect ( requestParams . get ( "rr" ) ) . to . equal ( "1" ) ;
40
+ } ) ;
41
+ cy . wait ( 100 ) . then ( ( ) => {
42
+ cy . fetch_local_request_queue ( ) . then ( ( rq ) => {
43
+ expect ( rq . length ) . to . equal ( 0 ) ;
44
+ } ) ;
39
45
} ) ;
40
46
} ) ;
41
47
} ) ;
@@ -48,7 +54,7 @@ describe("Remaining requests tests ", () => {
48
54
Countly . begin_session ( ) ;
49
55
Countly . end_session ( undefined , true ) ;
50
56
cy . fetch_local_request_queue ( ) . then ( ( rq ) => {
51
- // We expect 3 requests in queue: begin_session, end_session, orientation
57
+ // We expect 3 requests in queue: begin_session, end_session, orientation. health check was not in the queue
52
58
expect ( rq . length ) . to . equal ( 3 ) ;
53
59
expect ( rq [ 0 ] . rr ) . to . equal ( 3 ) ;
54
60
expect ( rq [ 1 ] . rr ) . to . equal ( undefined ) ;
0 commit comments