@@ -47,15 +47,15 @@ describe('Logging and Telemetry integration', function () {
4747 ) ;
4848 } ) ;
4949
50- it ( 'contains an identify call' , function ( ) {
50+ it ( 'tracks an event for identify call' , function ( ) {
5151 const identify = telemetry
5252 . events ( )
5353 . find ( ( entry ) => entry . type === 'identify' ) ;
5454 expect ( identify . traits . platform ) . to . equal ( process . platform ) ;
5555 expect ( identify . traits . arch ) . to . equal ( process . arch ) ;
5656 } ) ;
5757
58- it ( 'contains a call for the welcome tour being closed' , function ( ) {
58+ it ( 'tracks an event for the welcome tour being closed' , function ( ) {
5959 const tourClosed = telemetry
6060 . events ( )
6161 . find ( ( entry ) => entry . event === 'Tour Closed' ) ;
@@ -66,21 +66,54 @@ describe('Logging and Telemetry integration', function () {
6666 expect ( tourClosed . properties . compass_channel ) . to . be . a ( 'string' ) ;
6767 } ) ;
6868
69- it ( 'contains call for shell use events ' , function ( ) {
69+ it ( 'tracks an event for shell use' , function ( ) {
7070 const shellUse = telemetry
7171 . events ( )
7272 . find ( ( entry ) => entry . event === 'Shell Use' ) ;
7373 expect ( shellUse . properties . compass_version ) . to . be . a ( 'string' ) ;
7474 } ) ;
7575
76- it ( 'contains call for shell connection events ' , function ( ) {
76+ it ( 'tracks an event for shell connection' , function ( ) {
7777 const shellNewConnection = telemetry
7878 . events ( )
7979 . find ( ( entry ) => entry . event === 'Shell New Connection' ) ;
8080 expect ( shellNewConnection . properties . is_localhost ) . to . equal ( true ) ;
8181 } ) ;
8282
83- it ( 'contains calls for screens that were accessed' , function ( ) {
83+ it ( 'tracks an event for an attempt to establish a new connection' , function ( ) {
84+ const connectionAttempt = telemetry
85+ . events ( )
86+ . find ( ( entry ) => entry . event === 'Connection Attempt' ) ;
87+ expect ( connectionAttempt . properties . is_favorite ) . to . equal ( false ) ;
88+ expect ( connectionAttempt . properties . is_recent ) . to . equal ( false ) ;
89+ expect ( connectionAttempt . properties . is_new ) . to . equal ( true ) ;
90+ } ) ;
91+
92+ it ( 'tracks an event when a connection is established' , function ( ) {
93+ const connectionAttempt = telemetry
94+ . events ( )
95+ . find ( ( entry ) => entry . event === 'New Connection' ) ;
96+ expect ( connectionAttempt . properties . is_localhost ) . to . equal ( true ) ;
97+ expect ( connectionAttempt . properties . is_atlas ) . to . equal ( false ) ;
98+ expect ( connectionAttempt . properties . is_dataLake ) . to . equal ( false ) ;
99+ expect ( connectionAttempt . properties . is_enterprise ) . to . equal ( false ) ;
100+ expect ( connectionAttempt . properties . is_public_cloud ) . to . equal ( false ) ;
101+ expect ( connectionAttempt . properties . is_do ) . to . equal ( false ) ;
102+
103+ expect ( connectionAttempt . properties . public_cloud_name ) . to . be . a (
104+ 'string'
105+ ) ;
106+ expect ( connectionAttempt . properties . is_genuine ) . to . be . a ( 'boolean' ) ;
107+ expect ( connectionAttempt . properties . non_genuine_server_name ) . to . be . a (
108+ 'string'
109+ ) ;
110+ expect ( connectionAttempt . properties . server_version ) . to . be . a ( 'string' ) ;
111+ expect ( connectionAttempt . properties . server_arch ) . to . be . a ( 'string' ) ;
112+ expect ( connectionAttempt . properties . server_os_family ) . to . be . a ( 'string' ) ;
113+ expect ( connectionAttempt . properties . auth_type ) . to . be . a ( 'string' ) ;
114+ } ) ;
115+
116+ it ( 'tracks an event for screens that were accessed' , function ( ) {
84117 expect ( telemetry . screens ( ) ) . to . include ( 'databases' ) ;
85118 } ) ;
86119 } ) ;
@@ -295,12 +328,10 @@ describe('Logging and Telemetry integration', function () {
295328 ] ;
296329
297330 let criticalPathActualLogs ;
331+ const testedIndexes = new Set ( ) ;
298332
299333 // eslint-disable-next-line mocha/no-hooks-for-single-case
300334 before ( function ( ) {
301- const criticalPathIds = new Set (
302- criticalPathExpectedLogs . map ( ( entry ) => entry . id )
303- ) ;
304335 criticalPathActualLogs = compassLog . filter ( ( entry ) => {
305336 // Remove most mongosh entries as they are quite noisy
306337 if (
@@ -312,29 +343,31 @@ describe('Logging and Telemetry integration', function () {
312343 return false ;
313344 }
314345
315- return criticalPathIds . has ( entry . id ) ;
346+ return true ;
316347 } ) ;
317348 } ) ;
318349
319350 // eslint-disable-next-line mocha/no-setup-in-describe
320- criticalPathExpectedLogs . forEach ( ( expected , i ) => {
351+ criticalPathExpectedLogs . forEach ( ( expected ) => {
321352 it ( `logs "${ expected . msg } "` , function ( ) {
322- if ( ! criticalPathActualLogs [ i ] ) {
353+ const actualLogIndex = criticalPathActualLogs . findIndex (
354+ ( { id } , index ) => id === expected . id && ! testedIndexes . has ( index )
355+ ) ;
356+ if ( actualLogIndex < 0 ) {
323357 throw new Error (
324- `No criticalPathActualLog for index ${ i } expected ${ JSON . stringify (
325- expected
326- ) } was empty`
358+ `No actual log found for expected ${ JSON . stringify ( expected ) } `
327359 ) ;
328360 }
329361
362+ testedIndexes . add ( actualLogIndex ) ;
330363 const { attr : expectedAttr , ...expectedWithoutAttr } = expected ;
331- const { attr : actualAttr , ...actualWihoutAttr } =
332- criticalPathActualLogs [ i ] ;
364+ const { attr : actualAttr , ...actualWithoutAttr } =
365+ criticalPathActualLogs [ actualLogIndex ] ;
333366
334367 // Timestamps vary between each execution
335- delete actualWihoutAttr . t ;
368+ delete actualWithoutAttr . t ;
336369
337- expect ( expectedWithoutAttr ) . to . deep . equal ( actualWihoutAttr ) ;
370+ expect ( expectedWithoutAttr ) . to . deep . equal ( actualWithoutAttr ) ;
338371
339372 // we already know this would fail the expectation
340373 if (
0 commit comments