Skip to content

Commit cd84de0

Browse files
committed
Test awareness setter does not destroy.
1 parent 3bbb01f commit cd84de0

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

tests/phpunit/tests/rest-api/rest-collaboration-server.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,6 +1388,26 @@ public function test_awareness_uses_in_memory_cache() {
13881388
$this->assertSame( 0, $db_calls_after - $db_calls_initial, 'Subsequent awareness retrieval should use in-memory cache and not query database.' );
13891389
}
13901390

1391+
/**
1392+
* Ensure adding subsequent client does not remove existing clients from room.
1393+
*/
1394+
public function test_awareness_updates_for_multiple_users() {
1395+
$storage = new WP_Collaboration_Table_Storage();
1396+
1397+
// User 1 sets awareness.
1398+
$storage->set_awareness_state( 'test-room', 'client-1', array( 'name' => 'Client 1' ), 1 );
1399+
1400+
// User 2 sets awareness.
1401+
$storage->set_awareness_state( 'test-room', 'client-2', array( 'name' => 'Client 2' ), 2 );
1402+
1403+
// Retrieve awareness state and verify both users are present.
1404+
$awareness = $storage->get_awareness_state( 'test-room' );
1405+
$clients = wp_list_pluck( $awareness, 'client_id' );
1406+
1407+
$this->assertContains( 'client-1', $clients, 'Client 1 should be present in awareness state.' );
1408+
$this->assertContains( 'client-2', $clients, 'Client 2 should be present in awareness state.' );
1409+
}
1410+
13911411
/*
13921412
* Multiple rooms tests.
13931413
*/

0 commit comments

Comments
 (0)