From ece5b8173277ff0d41cbbb0b56c798baf0a0f2fe Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Fri, 6 Mar 2026 15:27:30 +0530 Subject: [PATCH] updated test --- tests/e2e/General/UsageTest.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/e2e/General/UsageTest.php b/tests/e2e/General/UsageTest.php index 2eb2673c8a..f51b04b9c6 100644 --- a/tests/e2e/General/UsageTest.php +++ b/tests/e2e/General/UsageTest.php @@ -1571,12 +1571,23 @@ class UsageTest extends Scope 'type' => 'ping', ])); - $firstMessage = json_decode($clients[1]->receive(), true); - // Depending on timing, the first frame we see here can be either - // a broadcast "event" (from another operation) or the "pong" - // response. Both are valid, and in either case the ping/pong - // traffic still exercises the realtime usage metrics paths. - $this->assertContains($firstMessage['type'], ['event']); + // A broadcast document "event" can still be queued for this connection. + // Read until we see the pong response (and fail fast on unexpected frames). + $pong = null; + for ($i = 0; $i < 5; $i++) { + $frame = json_decode($clients[1]->receive(), true); + $this->assertIsArray($frame); + $this->assertArrayHasKey('type', $frame); + + if ($frame['type'] === 'pong') { + $pong = $frame; + break; + } + + $this->assertEquals('event', $frame['type']); + } + + $this->assertNotNull($pong, 'Expected to receive a pong frame after ping.'); // We expect: // - connections count to remain the same