Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core/test: revert occupancy test changes #383

Merged
merged 1 commit into from
Oct 30, 2024
Merged

Conversation

AndyTWF
Copy link
Collaborator

@AndyTWF AndyTWF commented Oct 30, 2024

Context

N/A

Description

Now that underlying changes have been effected on the server, we no longer need to account for the +1 in occupancy, so these tests can be revereted to their previous state.

Checklist

  • QA'd by the author.
  • Unit tests created (if applicable).
  • Integration tests created (if applicable).
  • Follow coding style guidelines found here.
  • TypeDoc updated (if applicable).
  • (Optional) Update documentation for new features.
  • Browser tests created (if applicable).
  • In repo demo app updated (if applicable).

Testing Instructions (Optional)

N/A

Summary by CodeRabbit

  • Bug Fixes
    • Adjusted expected occupancy values in integration tests for chat room functionality to reflect accurate connection counts.
    • Updated metrics for the useOccupancy hook to ensure correct assertions and waiting conditions for occupancy events.

Now that underlying changes have been effected on the server, we no longer need
to account for the +1 in occupancy, so these tests can be revereted to their
previous state.
@AndyTWF AndyTWF requested a review from a team October 30, 2024 17:04
Copy link

coderabbitai bot commented Oct 30, 2024

Walkthrough

The changes involve modifications to the expected occupancy values in integration tests for the occupancy functionality within chat rooms. Specifically, adjustments were made to the expected number of connections and presence members in two test files: one for general occupancy tests and another for the useOccupancy hook. These updates ensure that the tests accurately reflect the current behavior of the occupancy system by correcting the anticipated counts of connections and presence members.

Changes

File Change Summary
test/core/occupancy.integration.test.ts Updated expected occupancy values: connections changed from 3 to 2; after leaving, changed from 1 to 0.
test/react/hooks/use-occupancy.integration.test.tsx Adjusted expected connections from 4 to 3; presenceMembers remains at 2; updated assertions accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ChatRoom
    participant OccupancySystem

    User->>ChatRoom: Join
    ChatRoom->>OccupancySystem: Update occupancy (connections: 2)
    OccupancySystem-->>ChatRoom: Confirm occupancy updated
    ChatRoom-->>User: Notify occupancy updated (connections: 2)

    User->>ChatRoom: Leave
    ChatRoom->>OccupancySystem: Update occupancy (connections: 0)
    OccupancySystem-->>ChatRoom: Confirm occupancy updated
    ChatRoom-->>User: Notify occupancy updated (connections: 0)
Loading

🐰 In the meadow, hopping around,
With changes made, new values found.
Connections count, we’ve set it right,
Two for presence, oh what a sight!
Testing our chat, with joy we cheer,
Occupancy clear, the path is near! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Oct 30, 2024

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 92.55% (🎯 92%) 2696 / 2913
🟢 Statements 92.55% (🎯 92%) 2696 / 2913
🟢 Functions 92.57% (🎯 92%) 212 / 229
🟢 Branches 93.9% (🎯 93%) 755 / 804
File CoverageNo changed files found.
Generated in workflow #1656 for commit ecb6c03 by the Vitest Coverage Report Action

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
test/react/hooks/use-occupancy.integration.test.tsx (1)

64-64: LGTM! The occupancy expectations are correctly adjusted.

The changes align with the PR objectives to revert the occupancy test changes following server-side updates.

Consider adding a comment explaining how the expected occupancy values (3 connections, 2 presence members) are calculated:

+ // Expected occupancy:
+ // - connections: 3 (one connection each from chatClient, chatClientTwo, and chatClientThree)
+ // - presenceMembers: 2 (from roomTwo and roomThree presence.enter())
const expectedOccupancy = { connections: 3, presenceMembers: 2 };

Also applies to: 70-70, 73-74

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 24b03d5 and ecb6c03.

📒 Files selected for processing (2)
  • test/core/occupancy.integration.test.ts (3 hunks)
  • test/react/hooks/use-occupancy.integration.test.tsx (1 hunks)
🔇 Additional comments (3)
test/core/occupancy.integration.test.ts (3)

101-105: LGTM: Clean state after detachment.

The expected count of 0 connections after all clients detach is correct, ensuring proper cleanup.


143-146: LGTM: Consistent with previous test case.

The expected connection count of 2 maintains consistency with the earlier test case and correctly reflects the number of attached clients.


90-92: LGTM: Connection count matches expected behavior.

The expected connection count of 2 is correct:

  1. Main client connection (1)
  2. Subscriber client connection (1)

Let's verify this behavior is consistent with the server implementation:

✅ Verification successful

Let me analyze the test files to understand the connection count patterns better.


Connection count of 2 is consistent across integration tests

The verification confirms that the connection count of 2 is correct and consistent with the test scenario where:

  1. A main client attaches to the channel
  2. A subscriber client attaches and enters presence

The test assertions align with similar scenarios in other integration tests, where each client connection is counted individually. The change from 3 to 2 connections reflects the correct behavior after server-side updates.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any other tests that might be asserting different connection counts
# to ensure consistency across the test suite
rg -l "connections.*:" test/ | xargs rg "connections:.*[0-9]+"

Length of output: 2858


Script:

#!/bin/bash
# Get more context around the integration tests to understand the test scenarios
rg -B 5 -A 5 "connections: [23]," test/core/occupancy.integration.test.ts

Length of output: 686

@AndyTWF AndyTWF enabled auto-merge October 30, 2024 17:12
Copy link
Contributor

@splindsay-92 splindsay-92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AndyTWF AndyTWF merged commit 6cf4901 into main Oct 30, 2024
9 checks passed
@AndyTWF AndyTWF deleted the occupancy-test-fix-revert branch October 30, 2024 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants