@@ -149,7 +149,7 @@ describe('Auth Module', () => {
149149
150150 // Verify the redirect URL was set correctly
151151 expect ( mockLocation . href ) . toBe (
152- `${ serverUrl } /login?from_url=${ encodeURIComponent ( nextUrl ) } &app_id= ${ appId } `
152+ `/login?from_url=${ encodeURIComponent ( nextUrl ) } `
153153 ) ;
154154
155155 // Restore window
@@ -169,7 +169,7 @@ describe('Auth Module', () => {
169169
170170 // Verify the redirect URL uses current URL
171171 expect ( mockLocation . href ) . toBe (
172- `${ serverUrl } /login?from_url=${ encodeURIComponent ( currentUrl ) } &app_id= ${ appId } `
172+ `/login?from_url=${ encodeURIComponent ( currentUrl ) } `
173173 ) ;
174174
175175 // Restore window
@@ -192,7 +192,7 @@ describe('Auth Module', () => {
192192 expect ( scope . isDone ( ) ) . toBe ( true ) ;
193193
194194 // Call logout
195- await base44 . auth . logout ( ) ;
195+ base44 . auth . logout ( ) ;
196196
197197 // Mock another me() call to verify no Authorization header is sent
198198 scope . get ( `/api/apps/${ appId } /entities/User/me` )
@@ -214,15 +214,18 @@ describe('Auth Module', () => {
214214 } ;
215215 const originalWindow = global . window ;
216216 global . window = {
217- localStorage : mockLocalStorage
217+ localStorage : mockLocalStorage ,
218+ location : {
219+ reload : vi . fn ( )
220+ }
218221 } ;
219222
220223 // Set a token to localStorage first
221224 base44 . auth . setToken ( 'test-token' , true ) ;
222225 expect ( mockLocalStorage . setItem ) . toHaveBeenCalledWith ( 'base44_access_token' , 'test-token' ) ;
223226
224227 // Call logout
225- await base44 . auth . logout ( ) ;
228+ base44 . auth . logout ( ) ;
226229
227230 // Verify token was removed from localStorage
228231 expect ( mockLocalStorage . removeItem ) . toHaveBeenCalledWith ( 'base44_access_token' ) ;
@@ -241,11 +244,14 @@ describe('Auth Module', () => {
241244 const consoleSpy = vi . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
242245 const originalWindow = global . window ;
243246 global . window = {
244- localStorage : mockLocalStorage
247+ localStorage : mockLocalStorage ,
248+ location : {
249+ reload : vi . fn ( )
250+ }
245251 } ;
246252
247253 // Call logout - should not throw
248- await expect ( base44 . auth . logout ( ) ) . resolves . toBeUndefined ( ) ;
254+ base44 . auth . logout ( ) ;
249255
250256 // Verify error was logged
251257 expect ( consoleSpy ) . toHaveBeenCalledWith ( 'Failed to remove token from localStorage:' , expect . any ( Error ) ) ;
@@ -264,14 +270,34 @@ describe('Auth Module', () => {
264270 } ;
265271
266272 const redirectUrl = 'https://example.com/logout-success' ;
267- await base44 . auth . logout ( redirectUrl ) ;
273+ base44 . auth . logout ( redirectUrl ) ;
268274
269275 // Verify redirect
270276 expect ( mockLocation . href ) . toBe ( redirectUrl ) ;
271277
272278 // Restore window
273279 global . window = originalWindow ;
274280 } ) ;
281+
282+ test ( 'should reload page when no redirect URL is provided' , async ( ) => {
283+ // Mock window object with reload function
284+ const mockReload = vi . fn ( ) ;
285+ const originalWindow = global . window ;
286+ global . window = {
287+ location : {
288+ reload : mockReload
289+ }
290+ } ;
291+
292+ // Call logout without redirect URL
293+ base44 . auth . logout ( ) ;
294+
295+ // Verify page reload was called
296+ expect ( mockReload ) . toHaveBeenCalledTimes ( 1 ) ;
297+
298+ // Restore window
299+ global . window = originalWindow ;
300+ } ) ;
275301 } ) ;
276302
277303 describe ( 'setToken()' , ( ) => {
0 commit comments