@@ -79,13 +79,14 @@ void main() {
7979 authOptions: FlutterAuthClientOptions (
8080 localStorage: MockExpiredStorage (),
8181 pkceAsyncStorage: MockAsyncStorage (),
82+ autoRefreshToken: false ,
8283 ),
8384 );
8485 });
8586
86- test ('initial session contains the error ' , () async {
87+ test ('emits exception when no auto refresh ' , () async {
8788 // Give it a delay to wait for recoverSession to throw
88- await Future .delayed (const Duration (milliseconds: 10 ));
89+ await Future .delayed (const Duration (milliseconds: 100 ));
8990
9091 await expectLater (Supabase .instance.client.auth.onAuthStateChange,
9192 emitsError (isA <AuthException >()));
@@ -113,65 +114,6 @@ void main() {
113114 });
114115 });
115116
116- group ('Deep Link with PKCE code' , () {
117- late final PkceHttpClient pkceHttpClient;
118- late final bool mockEventChannel;
119-
120- /// Check if the current version of AppLinks uses an explicit call to get
121- /// the initial link. This is only the case before version 6.0.0, where we
122- /// can find the getInitialAppLink function.
123- ///
124- /// CI pipeline is set so that it tests both app_links newer and older than v6.0.0
125- bool appLinksExposesInitialLinkInStream () {
126- try {
127- // before app_links 6.0.0
128- (AppLinks () as dynamic ).getInitialAppLink;
129- return false ;
130- } on NoSuchMethodError catch (_) {
131- return true ;
132- }
133- }
134-
135- setUp (() async {
136- pkceHttpClient = PkceHttpClient ();
137-
138- // Add initial deep link with a `code` parameter, use method channel if
139- // we are in a version of AppLinks that use the explcit method for
140- // getting the initial link. Otherwise we want to mock the event channel
141- // and put the initial link there.
142- mockEventChannel = appLinksExposesInitialLinkInStream ();
143- mockAppLink (
144- mockMethodChannel: ! mockEventChannel,
145- mockEventChannel: mockEventChannel,
146- initialLink: 'com.supabase://callback/?code=my-code-verifier' ,
147- );
148- await Supabase .initialize (
149- url: supabaseUrl,
150- anonKey: supabaseKey,
151- debug: false ,
152- httpClient: pkceHttpClient,
153- authOptions: FlutterAuthClientOptions (
154- localStorage: MockEmptyLocalStorage (),
155- pkceAsyncStorage: MockAsyncStorage ()
156- ..setItem (
157- key: 'supabase.auth.token-code-verifier' ,
158- value: 'raw-code-verifier' ),
159- ),
160- );
161- });
162-
163- test (
164- 'Having `code` as the query parameter triggers `getSessionFromUrl` call on initialize' ,
165- () async {
166- // Wait for the initial app link to be handled, as this is an async
167- // process when mocking the event channel.
168- if (mockEventChannel) {
169- await Future .delayed (const Duration (milliseconds: 500 ));
170- }
171- expect (pkceHttpClient.requestCount, 1 );
172- expect (pkceHttpClient.lastRequestBody['auth_code' ], 'my-code-verifier' );
173- });
174- });
175117 group ('EmptyLocalStorage' , () {
176118 late EmptyLocalStorage localStorage;
177119
0 commit comments