@@ -36,10 +36,7 @@ async function waitForStringInOutput(
3636 while ( Date . now ( ) - startTime < timeoutMs ) {
3737 const output = outputFn ( ) ;
3838
39- // Log output changes for debugging
40- if ( output !== lastOutput && process . env . E2E_DEBUG ) {
41- console . log ( `[DEBUG] Output updated, looking for "${ targetString } "` ) ;
42- console . log ( `[DEBUG] Current output: ${ output . slice ( Math . max ( 0 , output . length - 200 ) ) } ` ) ;
39+ if ( output !== lastOutput ) {
4340 lastOutput = output ;
4441 }
4542
@@ -48,7 +45,6 @@ async function waitForStringInOutput(
4845 output . toLowerCase ( ) . includes ( targetString . toLowerCase ( ) ) ||
4946 // Handle ANSI codes that might interfere
5047 stripAnsi ( output ) . includes ( targetString ) ) {
51- console . log ( `Found target string: "${ targetString } "` ) ;
5248 return ;
5349 }
5450
@@ -88,7 +84,6 @@ if (!SHOULD_SKIP_E2E) {
8884 testRoomId = getUniqueChannelName ( "room" ) ;
8985 client1Id = getUniqueClientId ( "client1" ) ;
9086 client2Id = getUniqueClientId ( "client2" ) ;
91- console . log ( `Test setup: Room=${ testRoomId } , Client1=${ client1Id } , Client2=${ client2Id } ` ) ;
9287 } ) ;
9388
9489 describe ( 'Room occupancy functionality' , function ( ) {
@@ -97,7 +92,6 @@ if (!SHOULD_SKIP_E2E) {
9792
9893 try {
9994 // Start client1 entering presence (this is a long-running command)
100- console . log ( `Client1 entering presence to establish room occupancy` ) ;
10195 presenceRunner = await startPresenceCommand (
10296 [ 'rooms' , 'presence' , 'enter' , testRoomId , '--profile-data' , '{"name":"TestUser1"}' , '--client-id' , client1Id , '--duration' , '15' ] ,
10397 / E n t e r e d r o o m / ,
@@ -106,10 +100,8 @@ if (!SHOULD_SKIP_E2E) {
106100
107101 // Wait longer for presence to establish in CI
108102 const initialWait = process . env . CI ? 5000 : 3000 ;
109- console . log ( `Waiting ${ initialWait } ms for presence to fully establish...` ) ;
110103 await new Promise ( resolve => setTimeout ( resolve , initialWait ) ) ;
111104
112- console . log ( `Presence process output so far: ${ presenceRunner . combined ( ) . slice ( - 200 ) } ` ) ;
113105
114106 // Check occupancy metrics multiple times with retry logic
115107 let occupancyResult : { exitCode : number | null ; stdout : string ; stderr : string } | null = null ;
@@ -118,15 +110,11 @@ if (!SHOULD_SKIP_E2E) {
118110
119111 while ( attempts < maxAttempts ) {
120112 attempts ++ ;
121- console . log ( `Checking occupancy metrics for room ${ testRoomId } (attempt ${ attempts } /${ maxAttempts } )` ) ;
122113
123114 occupancyResult = await runCommand ( [ 'rooms' , 'occupancy' , 'get' , testRoomId ] , {
124115 timeoutMs : process . env . CI ? 15000 : 10000
125116 } ) ;
126117
127- console . log ( `Occupancy attempt ${ attempts } - Exit code: ${ occupancyResult . exitCode } ` ) ;
128- console . log ( `Occupancy stdout: ${ occupancyResult . stdout } ` ) ;
129- console . log ( `Occupancy stderr: ${ occupancyResult . stderr } ` ) ;
130118
131119 if ( occupancyResult . exitCode === 0 &&
132120 occupancyResult . stdout . includes ( "Connections:" ) &&
@@ -136,7 +124,6 @@ if (!SHOULD_SKIP_E2E) {
136124
137125 if ( attempts < maxAttempts ) {
138126 const retryDelay = 2000 * attempts ; // Progressive delay
139- console . log ( `Occupancy check failed, waiting ${ retryDelay } ms before retry...` ) ;
140127 await new Promise ( resolve => setTimeout ( resolve , retryDelay ) ) ;
141128 }
142129 }
@@ -166,64 +153,48 @@ if (!SHOULD_SKIP_E2E) {
166153
167154 try {
168155 // Start client1 subscribing to presence events
169- console . log ( `[Test Debug] Starting presence subscription for client1 (${ client1Id } ) on room ${ testRoomId } ` ) ;
170156 subscribeRunner = await startSubscribeCommand (
171157 [ 'rooms' , 'presence' , 'subscribe' , testRoomId , '--client-id' , client1Id , '--duration' , '35' ] ,
172158 / S u b s c r i b i n g t o p r e s e n c e e v e n t s / ,
173159 { timeoutMs : process . env . CI ? 30000 : 20000 }
174160 ) ;
175- console . log ( `[Test Debug] Subscriber process for client1 started and ready.` ) ;
176161
177162 // Wait a moment for client1's subscription to fully establish
178163 const client1SetupWait = process . env . CI ? 4000 : 2000 ;
179- console . log ( `[Test Debug] Waiting ${ client1SetupWait } ms for client1 subscription to fully establish.` ) ;
180164 await new Promise ( resolve => setTimeout ( resolve , client1SetupWait ) ) ;
181165
182166 // Have client2 enter the room
183- console . log ( `[Test Debug] Client2 (${ client2Id } ) entering room ${ testRoomId } with profile data.` ) ;
184167 enterRunner = await startPresenceCommand (
185168 [ 'rooms' , 'presence' , 'enter' , testRoomId , '--profile-data' , '{"name":"TestUser2","status":"active"}' , '--client-id' , client2Id , '--duration' , '25' ] ,
186169 / E n t e r e d r o o m / ,
187170 { timeoutMs : process . env . CI ? 30000 : 20000 }
188171 ) ;
189- console . log ( `[Test Debug] Enter process for client2 started and ready.` ) ;
190172
191173 // Add a significant delay for presence event propagation
192174 const propagationDelay = process . env . CI ? 10000 : 7000 ;
193- console . log ( `[Test Debug] Waiting ${ propagationDelay } ms for presence event propagation after client2 entered.` ) ;
194175 await new Promise ( resolve => setTimeout ( resolve , propagationDelay ) ) ;
195176
196177 // Wait for all presence event components using the improved detection
197- console . log ( "[Test Debug] Waiting for presence event components to appear..." ) ;
198178
199179 try {
200180 // Wait for action enter pattern
201181 await waitForOutput ( subscribeRunner , `Action: enter` , process . env . CI ? 20000 : 15000 ) ;
202- console . log ( "[Test Debug] ✓ Detected presence action: enter" ) ;
203182
204183 // Wait for client ID pattern
205184 await waitForOutput ( subscribeRunner , `Client: ${ client2Id } ` , process . env . CI ? 10000 : 5000 ) ;
206- console . log ( "[Test Debug] ✓ Detected client ID in presence event" ) ;
185+ // Wait for profile data pattern - correct JSON formatting with spaces
207186
208187 // Wait for profile data pattern
209188 await waitForOutput ( subscribeRunner , `"name":"TestUser2"` , process . env . CI ? 10000 : 5000 ) ;
210- console . log ( "[Test Debug] ✓ Detected profile data in presence event" ) ;
211189
212190 // Wait for status in profile data
213191 await waitForOutput ( subscribeRunner , `"status":"active"` , process . env . CI ? 5000 : 3000 ) ;
214- console . log ( "[Test Debug] ✓ Detected status in profile data" ) ;
215-
216- console . log ( "[Test Debug] All presence event components detected successfully!" ) ;
217192
218193 } catch ( error ) {
219- console . log ( `[TEST FAILURE DEBUG] Failed to detect presence event components: ${ error instanceof Error ? error . message : String ( error ) } ` ) ;
220- console . log ( `[TEST FAILURE DEBUG] Final subscriber output:\n${ subscribeRunner . combined ( ) . slice ( - 1500 ) } ` ) ;
221- console . log ( `[TEST FAILURE DEBUG] Final enterer output:\n${ enterRunner . combined ( ) . slice ( - 1500 ) } ` ) ;
222194 throw error ;
223195 }
224196
225197 } finally {
226- console . log ( "[Test Debug] Entering finally block for Rooms Presence test." ) ;
227198 await cleanupRunners ( [ subscribeRunner , enterRunner ] . filter ( Boolean ) as CliRunner [ ] ) ;
228199 await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ; // Final wait for cleanup
229200 }
@@ -236,44 +207,33 @@ if (!SHOULD_SKIP_E2E) {
236207
237208 try {
238209 // Start subscribing to messages with client1
239- console . log ( `[Test Debug] Starting message subscribe for client1 on room ${ testRoomId } ` ) ;
240210 subscribeRunner = await startSubscribeCommand (
241211 [ 'rooms' , 'messages' , 'subscribe' , testRoomId , '--client-id' , client1Id , '--duration' , '30' ] ,
242212 / C o n n e c t e d t o r o o m : / ,
243213 { timeoutMs : process . env . CI ? 45000 : 25000 }
244214 ) ;
245215
246- console . log ( `[Test Debug] Subscribe process started and ready` ) ;
247216
248217 // Wait a bit to ensure subscription is established
249218 const setupWait = process . env . CI ? 3000 : 1000 ;
250- console . log ( `[Test Debug] Waiting ${ setupWait } ms for subscription to establish` ) ;
251219 await new Promise ( resolve => setTimeout ( resolve , setupWait ) ) ;
252220
253221 // Have client2 send a message
254222 const testMessage = "Hello from E2E test!" ;
255- console . log ( `[Test Debug] Client2 sending message: "${ testMessage } "` ) ;
256223 const sendResult = await runCommand ( [ 'rooms' , 'messages' , 'send' , testRoomId , testMessage , '--client-id' , client2Id ] , {
257224 timeoutMs : process . env . CI ? 20000 : 10000
258225 } ) ;
259226
260- console . log ( `[Test Debug] Send result - exitCode: ${ sendResult . exitCode } ` ) ;
261- console . log ( `[Test Debug] Send result - stdout: ${ sendResult . stdout } ` ) ;
262- console . log ( `[Test Debug] Send result - stderr: ${ sendResult . stderr } ` ) ;
263-
264227 expect ( sendResult . exitCode ) . to . equal ( 0 ) ;
265228 expect ( sendResult . stdout ) . to . contain ( "Message sent successfully" ) ;
266229
267230 // Wait for the message to be received by the subscriber
268- console . log ( `[Test Debug] Waiting for message to be received by subscriber` ) ;
269231 await waitForOutput ( subscribeRunner , testMessage , process . env . CI ? 10000 : 6000 ) ;
270232 await waitForOutput ( subscribeRunner , client2Id , process . env . CI ? 5000 : 3000 ) ;
271- console . log ( `[Test Debug] Message detected in subscriber output!` ) ;
272233
273234 // Send a second message with metadata
274235 const secondMessage = "Second test message with metadata" ;
275236 const metadata = { timestamp : Date . now ( ) , type : "test" } ;
276- console . log ( `[Test Debug] Client2 sending second message with metadata` ) ;
277237 const sendResult2 = await runCommand ( [
278238 'rooms' , 'messages' , 'send' , testRoomId , secondMessage ,
279239 '--metadata' , JSON . stringify ( metadata ) , '--client-id' , client2Id
@@ -284,10 +244,7 @@ if (!SHOULD_SKIP_E2E) {
284244 expect ( sendResult2 . exitCode ) . to . equal ( 0 ) ;
285245
286246 // Wait for the second message to be received
287- console . log ( `[Test Debug] Waiting for second message to be received` ) ;
288247 await waitForOutput ( subscribeRunner , secondMessage , process . env . CI ? 10000 : 6000 ) ;
289- console . log ( `[Test Debug] Second message detected in subscriber output!` ) ;
290-
291248 } finally {
292249 if ( subscribeRunner ) {
293250 await subscribeRunner . kill ( ) ;
0 commit comments