-
-
Notifications
You must be signed in to change notification settings - Fork 214
fix: LiveQuery not working due to ethernet not recognized as connectivity state #1091
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
Open
kirkmorrow
wants to merge
5
commits into
parse-community:master
Choose a base branch
from
kirkmorrow:use_ethernet_enum
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+68
−0
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
161 changes: 161 additions & 0 deletions
161
packages/flutter/test/parse_connectivity_mapping_test.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| import 'package:connectivity_plus/connectivity_plus.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
| import 'package:parse_server_sdk_flutter/parse_server_sdk_flutter.dart'; | ||
|
|
||
| void main() { | ||
| TestWidgetsFlutterBinding.ensureInitialized(); | ||
|
|
||
| group('Connectivity mapping logic', () { | ||
| test('should map connectivity_plus results to ParseConnectivityResult', | ||
| () { | ||
| // This test documents the expected mapping behavior | ||
| // The actual Parse class implementation follows this mapping: | ||
|
|
||
| // Test enum structure | ||
| expect(ParseConnectivityResult.values.length, 4); | ||
| expect(ParseConnectivityResult.values, | ||
| containsAll([ | ||
| ParseConnectivityResult.wifi, | ||
| ParseConnectivityResult.ethernet, | ||
| ParseConnectivityResult.mobile, | ||
| ParseConnectivityResult.none, | ||
| ])); | ||
| }); | ||
|
|
||
| test('ParseConnectivityResult should have correct ordering for priority', | ||
| () { | ||
| // Verify enum ordering (wifi has highest priority in the if-else chain) | ||
| expect(ParseConnectivityResult.wifi.index, 0); | ||
| expect(ParseConnectivityResult.ethernet.index, 1); | ||
| expect(ParseConnectivityResult.mobile.index, 2); | ||
| expect(ParseConnectivityResult.none.index, 3); | ||
| }); | ||
|
|
||
| test('should identify online vs offline states correctly', () { | ||
| // Online states | ||
| expect(ParseConnectivityResult.wifi != ParseConnectivityResult.none, | ||
| true); | ||
| expect( | ||
| ParseConnectivityResult.ethernet != ParseConnectivityResult.none, | ||
| true); | ||
| expect(ParseConnectivityResult.mobile != ParseConnectivityResult.none, | ||
| true); | ||
|
|
||
| // Offline state | ||
| expect(ParseConnectivityResult.none == ParseConnectivityResult.none, | ||
| true); | ||
| }); | ||
|
|
||
| test('mapping logic follows priority: wifi > ethernet > mobile > none', | ||
| () { | ||
| // This documents the if-else chain priority in checkConnectivity() | ||
| // If a list contains wifi, it returns wifi | ||
| // Else if it contains ethernet, it returns ethernet | ||
| // Else if it contains mobile, it returns mobile | ||
| // Else it returns none | ||
|
|
||
| // Simulating the mapping logic | ||
| ParseConnectivityResult mapResult(List<ConnectivityResult> list) { | ||
| if (list.contains(ConnectivityResult.wifi)) { | ||
| return ParseConnectivityResult.wifi; | ||
| } else if (list.contains(ConnectivityResult.ethernet)) { | ||
| return ParseConnectivityResult.ethernet; | ||
| } else if (list.contains(ConnectivityResult.mobile)) { | ||
| return ParseConnectivityResult.mobile; | ||
| } else { | ||
| return ParseConnectivityResult.none; | ||
| } | ||
| } | ||
|
|
||
| // Test single connection types | ||
| expect(mapResult([ConnectivityResult.wifi]), | ||
| ParseConnectivityResult.wifi); | ||
| expect(mapResult([ConnectivityResult.ethernet]), | ||
| ParseConnectivityResult.ethernet); | ||
| expect(mapResult([ConnectivityResult.mobile]), | ||
| ParseConnectivityResult.mobile); | ||
| expect(mapResult([ConnectivityResult.none]), | ||
| ParseConnectivityResult.none); | ||
|
|
||
| // Test priority when multiple connections exist | ||
| expect(mapResult([ConnectivityResult.wifi, ConnectivityResult.ethernet]), | ||
| ParseConnectivityResult.wifi); | ||
| expect(mapResult([ConnectivityResult.wifi, ConnectivityResult.mobile]), | ||
| ParseConnectivityResult.wifi); | ||
| expect( | ||
| mapResult([ConnectivityResult.ethernet, ConnectivityResult.mobile]), | ||
| ParseConnectivityResult.ethernet); | ||
|
|
||
| // Test that ethernet takes priority over mobile (important for issue #1042) | ||
| expect( | ||
| mapResult([ConnectivityResult.mobile, ConnectivityResult.ethernet]), | ||
| ParseConnectivityResult.ethernet); | ||
|
|
||
| // Test fallback behavior for unsupported types | ||
| expect(mapResult([ConnectivityResult.bluetooth]), | ||
| ParseConnectivityResult.none); | ||
| expect(mapResult([ConnectivityResult.vpn]), ParseConnectivityResult.none); | ||
| expect( | ||
| mapResult([ConnectivityResult.other]), ParseConnectivityResult.none); | ||
|
|
||
| // Test mixed with unsupported types | ||
| expect( | ||
| mapResult([ConnectivityResult.ethernet, ConnectivityResult.vpn]), | ||
| ParseConnectivityResult.ethernet); | ||
| }); | ||
|
|
||
| test('ethernet should be treated as online connection type', () { | ||
| // Critical test for issue #1042 fix | ||
| // Ethernet must be treated as an online state, not as "none" | ||
|
|
||
| final isOnline = | ||
| ParseConnectivityResult.ethernet != ParseConnectivityResult.none; | ||
| expect(isOnline, true, | ||
| reason: | ||
| 'Ethernet should be treated as online for LiveQuery connectivity'); | ||
| }); | ||
|
|
||
| test('all online states should be distinguishable from none', () { | ||
| final onlineStates = [ | ||
| ParseConnectivityResult.wifi, | ||
| ParseConnectivityResult.ethernet, | ||
| ParseConnectivityResult.mobile, | ||
| ]; | ||
|
|
||
| for (final state in onlineStates) { | ||
| expect(state != ParseConnectivityResult.none, true, | ||
| reason: '$state should be distinguishable from none'); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| group('ConnectivityResult enum compatibility', () { | ||
| test('should handle all connectivity_plus enum values', () { | ||
| // Ensure we're aware of all possible values from connectivity_plus | ||
| final allConnectivityResults = [ | ||
| ConnectivityResult.wifi, | ||
| ConnectivityResult.ethernet, | ||
| ConnectivityResult.mobile, | ||
| ConnectivityResult.none, | ||
| ConnectivityResult.bluetooth, | ||
| ConnectivityResult.vpn, | ||
| ConnectivityResult.other, | ||
| ]; | ||
|
|
||
| // Verify all values exist (will fail if connectivity_plus adds new values) | ||
| expect(allConnectivityResults.length, 7); | ||
| }); | ||
|
|
||
| test('ParseConnectivityResult should support main connection types', () { | ||
| // The Parse SDK should support the main internet connection types | ||
| final supportedTypes = [ | ||
| ParseConnectivityResult.wifi, | ||
| ParseConnectivityResult.ethernet, | ||
| ParseConnectivityResult.mobile, | ||
| ]; | ||
|
|
||
| expect(supportedTypes.length, 3, | ||
| reason: 'Should support 3 main online connection types'); | ||
| }); | ||
| }); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
🧩 Analysis chain
🏁 Script executed:
Repository: parse-community/Parse-SDK-Flutter
Length of output: 210
🏁 Script executed:
Repository: parse-community/Parse-SDK-Flutter
Length of output: 210
🏁 Script executed:
Repository: parse-community/Parse-SDK-Flutter
Length of output: 210
🏁 Script executed:
Repository: parse-community/Parse-SDK-Flutter
Length of output: 210
🏁 Script executed:
Repository: parse-community/Parse-SDK-Flutter
Length of output: 210
🌐 Web query:
Parse Flutter SDK ConnectivityResult checkConnectivity implementation💡 Result:
Short summary of how checkConnectivity() / ConnectivityResult works (connectivity_plus):
Signature & return: Connectivity().checkConnectivity() is async and returns a List (one or more network interface types currently active). [1][2]
What the values mean: ConnectivityResult enumerates interface types (wifi, mobile, ethernet, vpn, bluetooth, none, other). The list can contain multiple entries (e.g., vpn + wifi). Use .contains(...) to check for a particular type. [2]
Implementation responsibility: The Dart API calls a platform-specific implementation (ConnectivityPlatform). Each platform plugin (Android/iOS/macos/linux/windows) implements checkConnectivity() to query the OS network APIs and map results to ConnectivityResult values. The platform interface defines the API and throws UnimplementedError if not overridden. [3]
Practical notes / caveats:
If you want, I can fetch and paste the exact platform implementation files (Android/iOS/Linux/Windows) and explain line-by-line. Which platform(s) do you want analyzed?
🌐 Web query:
parse-flutter-sdk connectivity mapping ethernet wifi mobile priority💡 Result:
Short answer: Parse Flutter SDK maps only wifi -> wifi, mobile -> mobile, and everything else -> none — it doesn’t expose ethernet (or other ConnectivityResult values) and thus treats those as none. [1][2]
Sources:
References:
[1] Parse SDK Flutter — connectivityStream implementation.
[2] connectivity_plus package docs (connectivity types & usage).
[3] connectivity_plus changelog (ethernet support added).
🌐 Web query:
Parse Flutter SDK issue 1042 ethernet connectivity💡 Result:
Summary: The Parse Flutter SDK’s connectivityStream maps connectivity_plus values but only handles wifi and mobile — any other ConnectivityResult (including ethernet) falls to the default branch and is returned as ParseConnectivityResult.none. That causes devices on Ethernet to appear as “no connectivity” to the Parse SDK. Source code excerpt shows the mapping only for wifi/mobile and default -> none. [1]
Context / evidence:
Impact: Apps using Parse’s connectivityStream will treat ethernet-connected devices as offline (ParseConnectivityResult.none), affecting logic that depends on network state (e.g., LiveQuery reconnect logic, background sync).
Minimal fixes:
References:
Test expects ethernet connectivity handling that does not exist in the actual Parse SDK implementation.
The
mapResultfunction tests logic for mappingConnectivityResult.ethernettoParseConnectivityResult.ethernet(lines 65, 88), but the current Parse Flutter SDK'sconnectivityStreamonly handleswifiandmobile—ethernet and other connectivity types are mapped toParseConnectivityResult.none. This test will pass while devices on ethernet fail silently in production.If this test is for issue #1042 (adding ethernet support), it should either:
connectivityStreamto map ethernet appropriately.If this test is meant for the current implementation, remove the ethernet-related test cases (lines 75-77, 88-90, 102-104) and the ethernet priority logic from
mapResult.🤖 Prompt for AI Agents
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.
@kirkmorrow What would be the response to this review feedback?
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.