Skip to content

Commit

Permalink
Merge pull request #383 from ably/occupancy-test-fix-revert
Browse files Browse the repository at this point in the history
core/test: revert occupancy test changes
  • Loading branch information
AndyTWF authored Oct 30, 2024
2 parents 24b03d5 + ecb6c03 commit 6cf4901
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions test/core/occupancy.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ describe('occupancy', () => {
await subscriberRealtimeChannel.presence.enter({ foo: 'bar' });

// Wait for the occupancy to reach the expected occupancy
// We get an extra 1 from inside Realtime, so expect 3
await waitForExpectedInstantaneousOccupancy(room, {
connections: 3,
connections: 2,
presenceMembers: 1,
});

Expand All @@ -99,9 +98,9 @@ describe('occupancy', () => {
await subscriberRealtimeChannel.detach();
await realtimeChannel.detach();

// We'll get 1 connection from the channel until resources clean up in realtime, so expect that and end here
// Everything should be back to 0
await waitForExpectedInstantaneousOccupancy(room, {
connections: 1,
connections: 0,
presenceMembers: 0,
});
});
Expand Down Expand Up @@ -141,7 +140,7 @@ describe('occupancy', () => {
await waitForExpectedInbandOccupancy(
occupancyUpdates,
{
connections: 3,
connections: 2,
presenceMembers: 1,
},
TEST_TIMEOUT,
Expand Down
6 changes: 3 additions & 3 deletions test/react/hooks/use-occupancy.integration.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ describe('useOccupancy', () => {
render(<TestProvider />);

// if we already have expected occupancy, then we don't need to wait for the event
const expectedOccupancy = { connections: 4, presenceMembers: 2 };
const expectedOccupancy = { connections: 3, presenceMembers: 2 };
if (dequal(expectedOccupancy, occupancyState)) {
return;
}

// we don't have the requested occupancy yet, so wait for the occupancy events to be received
await waitForExpectedInbandOccupancy(occupancyEvents, { connections: 4, presenceMembers: 2 }, 20000);
await waitForExpectedInbandOccupancy(occupancyEvents, { connections: 3, presenceMembers: 2 }, 20000);

// check the occupancy metrics
expect(occupancyState.connections).toBe(4);
expect(occupancyState.connections).toBe(3);
expect(occupancyState.presenceMembers).toBe(2);
});
});

0 comments on commit 6cf4901

Please sign in to comment.