11import { beforeEach , describe , expect , it , vi } from 'vitest' ;
2+ import { type as osType } from '@tauri-apps/plugin-os' ;
23import {
34 buildTauriSsoRedirectUrl ,
45 parseTauriOidcCallback ,
@@ -12,10 +13,28 @@ vi.mock('@tauri-apps/plugin-os', () => ({
1213} ) ) ;
1314
1415beforeEach ( ( ) => {
16+ vi . unstubAllEnvs ( ) ;
17+ vi . mocked ( osType ) . mockReturnValue ( 'android' ) ;
1518 localStorage . clear ( ) ;
1619} ) ;
1720
1821describe ( 'buildTauriSsoRedirectUrl' , ( ) => {
22+ it ( 'uses the registered deep-link callback in production desktop builds' , ( ) => {
23+ vi . stubEnv ( 'DEV' , false ) ;
24+ vi . mocked ( osType ) . mockReturnValue ( 'linux' ) ;
25+
26+ const url = new URL ( buildTauriSsoRedirectUrl ( 'https://hs.example' ) ) ;
27+
28+ expect ( url . protocol ) . toBe ( 'sable:' ) ;
29+ expect ( url . hostname ) . toBe ( 'login' ) ;
30+ expect ( url . pathname ) . toBe ( '/lp/sso-callback' ) ;
31+ expect ( url . searchParams . get ( 'server' ) ) . toBe ( 'https://hs.example' ) ;
32+ const nonce = url . searchParams . get ( 'sso_nonce' ) ;
33+ expect ( nonce ) . toBeTruthy ( ) ;
34+ expect ( takeTauriSsoNonce ( ) ) . toBe ( nonce ) ;
35+ expect ( takeTauriSsoNonce ( ) ) . toBeUndefined ( ) ;
36+ } ) ;
37+
1938 it ( 'embeds the server and stores the same nonce it puts in the url' , ( ) => {
2039 const url = new URL ( buildTauriSsoRedirectUrl ( 'https://hs.example' ) ) ;
2140 expect ( url . searchParams . get ( 'server' ) ) . toBe ( 'https://hs.example' ) ;
0 commit comments