Skip to content

Commit a2f0c71

Browse files
committed
refactor: Don't use EventChannel to wait for initial link handling
We can do this with AppLinks' stream instead
1 parent 7d12a9f commit a2f0c71

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

packages/supabase_flutter/test/supabase_flutter_test.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'package:app_links/app_links.dart';
2-
import 'package:flutter/services.dart';
32
import 'package:flutter_test/flutter_test.dart';
43
import 'package:supabase_flutter/supabase_flutter.dart';
54

@@ -95,7 +94,6 @@ void main() {
9594

9695
group('Deep Link with PKCE code', () {
9796
late final PkceHttpClient pkceHttpClient;
98-
late final EventChannel appLinksEventChannel;
9997
late final bool mockEventChannel;
10098

10199
/// Check if the current version of AppLinks uses an explicit call to get
@@ -119,7 +117,7 @@ void main() {
119117
// getting the initial link. Otherwise we want to mock the event channel
120118
// and put the initial link there.
121119
mockEventChannel = appLinksExposesInitialLinkInStream();
122-
appLinksEventChannel = mockAppLink(
120+
mockAppLink(
123121
mockMethodChannel: !mockEventChannel,
124122
mockEventChannel: mockEventChannel,
125123
initialLink: 'com.supabase://callback/?code=my-code-verifier',
@@ -142,10 +140,10 @@ void main() {
142140
test(
143141
'Having `code` as the query parameter triggers `getSessionFromUrl` call on initialize',
144142
() async {
145-
// Wait for the initial app link to be handled, as this is an async process
143+
// Wait for the initial app link to be handled, as this is an async
144+
// process when mocking the event channel.
146145
if (mockEventChannel) {
147-
final stream = appLinksEventChannel.receiveBroadcastStream();
148-
await stream.first;
146+
await AppLinks().uriLinkStream.first;
149147
}
150148
expect(pkceHttpClient.requestCount, 1);
151149
expect(pkceHttpClient.lastRequestBody['auth_code'], 'my-code-verifier');

packages/supabase_flutter/test/widget_test_stubs.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class MockEmptyLocalStorage extends LocalStorage {
9797
/// Registers the mock handler for app_links
9898
///
9999
/// Returns the [EventChannel] used to mock the incoming links.
100-
EventChannel mockAppLink({
100+
void mockAppLink({
101101
bool mockMethodChannel = false,
102102
bool mockEventChannel = false,
103103
String? initialLink,
@@ -126,8 +126,6 @@ EventChannel mockAppLink({
126126
),
127127
);
128128
}
129-
130-
return eventChannel;
131129
}
132130

133131
class MockAsyncStorage extends GotrueAsyncStorage {

0 commit comments

Comments
 (0)