-
Notifications
You must be signed in to change notification settings - Fork 57
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
LiveObjects SYNC sequence tests #1894
LiveObjects SYNC sequence tests #1894
Conversation
ccb1a06
to
0cdc7c7
Compare
6a56b3e
to
3fc1df0
Compare
3fc1df0
to
3ee12cd
Compare
WalkthroughThe changes in this pull request introduce several new functionalities and modifications across multiple files. A new Changes
Possibly related PRs
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
🧹 Outside diff range and nitpick comments (4)
src/plugins/liveobjects/livemap.ts (1)
63-65
: LGTM! Consider addingreadonly
modifier.The implementation of the
size()
method looks good. It correctly returns the size of the internalMap
object, which is consistent with the class structure and provides a useful accessor for the map's size.As a minor enhancement, consider adding the
readonly
modifier to the method signature:readonly size(): number { return this._dataRef.data.size; }This would explicitly indicate that the method doesn't modify the object's state, which can be helpful for TypeScript users and potentially enable certain optimizations.
test/common/modules/testapp_manager.js (1)
136-136
: LGTM! Consider adding a comment for clarity.The addition of the 'enableChannelState' feature flag to the
post_apps
object is straightforward and appears to be intentional. This change will affect the configuration of newly created test apps, potentially enabling a new feature or behavior in the test environment.Consider adding a brief comment explaining the purpose of this feature flag for future maintainers. For example:
// Enable channel state tracking for test apps testData.post_apps.featureFlags = ['enableChannelState'];This will help other developers understand the intention behind this configuration.
test/realtime/live_objects.test.js (2)
109-110
: Ensure client is properly closed after test completionAt lines 109-110, a client is created but not explicitly closed after the test finishes:
const client = RealtimeWithLiveObjects(helper);Ensure that the client is properly closed to prevent resource leaks. You can wrap the test logic with
helper.monitorConnectionThenCloseAndFinish
to manage the client lifecycle, which you've done correctly in other tests.
383-384
: Clarify assertion message for nested counter's valueIn lines 383-384, the assertion checks the value of a nested counter:
expect(counterFromReferencedMap.value()).to.equal(20, 'Check nested counter has correct value');Consider enhancing the assertion message to specify which counter is being checked for clarity:
- expect(counterFromReferencedMap.value()).to.equal(20, 'Check nested counter has correct value'); + expect(counterFromReferencedMap.value()).to.equal(20, 'Check that "counterFromReferencedMap" has the correct value');
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (5)
- src/plugins/liveobjects/livemap.ts (1 hunks)
- test/common/globals/named_dependencies.js (1 hunks)
- test/common/modules/live_objects_helper.js (1 hunks)
- test/common/modules/testapp_manager.js (1 hunks)
- test/realtime/live_objects.test.js (3 hunks)
🧰 Additional context used
🪛 Biome
test/common/modules/live_objects_helper.js
[error] 1-1: Redundant use strict directive.
The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.(lint/suspicious/noRedundantUseStrict)
[error] 171-171: The assignment should not be in an expression.
The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.(lint/suspicious/noAssignInExpressions)
🔇 Additional comments (2)
test/common/globals/named_dependencies.js (1)
29-32
: LGTM! New dependency added correctly.The new
live_objects_helper
entry has been added consistently with the existing pattern. Both browser and Node.js paths are provided, which is in line with the structure of other entries in this file.To ensure the correctness of the paths and the existence of the referenced module, please run the following verification script:
✅ Verification successful
Verification Successful:
live_objects_helper
module exists and paths are correct.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the existence of the live_objects_helper module # Test: Check if the file exists at the specified path if [ -f "test/common/modules/live_objects_helper.js" ]; then echo "live_objects_helper.js file found at the specified path." else echo "Error: live_objects_helper.js file not found at the specified path." exit 1 fi # Test: Search for any imports or requires of the new module echo "Searching for usage of live_objects_helper in the codebase:" rg --type js "require\(['\"]test/common/modules/live_objects_helper['\"]" || echo "No usage found. This might be expected if the module is not yet used in tests."Length of output: 554
src/plugins/liveobjects/livemap.ts (1)
63-65
: Well-integrated addition to the LiveMap classThe
size()
method is a valuable addition to theLiveMap
class. It's well-placed within the class structure and provides functionality that users would expect from a map-like object. This method enhances the usability of theLiveMap
class by allowing easy access to the size of the underlying map, which is a common operation in many use cases.The addition of this method aligns the
LiveMap
interface more closely with the standard JavaScriptMap
interface, which is a positive design choice for API consistency and user expectations.
3ee12cd
to
a64b155
Compare
a64b155
to
1510c81
Compare
d3e15d9
to
d637bd7
Compare
42c9d5c
to
566bf00
Compare
This PR is based on #1891, please review it first.
Adds LiveObjects integration tests for functionality introduced in #1887, #1890 and #1891.
NOTE: next Live Objects tests are expected to fail until https://ably.atlassian.net/browse/DTP-982 is fixed:
Failure is due to missing state object in STATE_SYNC sequence for a map which has zero values.
Summary by CodeRabbit
Summary by CodeRabbit
New Features
size()
method to theLiveMap
class for retrieving the size of the data map.live_objects_helper
dependency for testing.LiveObjectsHelper
class to manage LiveObjects state on channels.enableChannelState
for new app creation.Bug Fixes
Documentation