@@ -3,6 +3,10 @@ import assert from 'node:assert/strict';
33import { readFile } from 'node:fs/promises' ;
44
55const bootstrapPath = new URL ( '../../src-tauri/src/bridge_bootstrap.js' , import . meta. url ) ;
6+ const chatTransportContractPath = new URL (
7+ '../../src-tauri/src/desktop_bridge_chat_transport_contract.json' ,
8+ import . meta. url ,
9+ ) ;
610
711test ( 'bridge bootstrap defines astrbotAppUpdater methods' , async ( ) => {
812 const source = await readFile ( bootstrapPath , 'utf8' ) ;
@@ -13,3 +17,17 @@ test('bridge bootstrap defines astrbotAppUpdater methods', async () => {
1317 assert . match ( source , / c h e c k F o r A p p U p d a t e : \s * \( \) \s * = > / ) ;
1418 assert . match ( source , / i n s t a l l A p p U p d a t e : \s * \( \) \s * = > / ) ;
1519} ) ;
20+
21+ test ( 'bridge bootstrap transport placeholders are backed by the shared contract' , async ( ) => {
22+ const [ source , rawContract ] = await Promise . all ( [
23+ readFile ( bootstrapPath , 'utf8' ) ,
24+ readFile ( chatTransportContractPath , 'utf8' ) ,
25+ ] ) ;
26+ const contract = JSON . parse ( rawContract ) ;
27+
28+ assert . equal ( typeof contract . storageKey , 'string' ) ;
29+ assert . equal ( typeof contract . websocketValue , 'string' ) ;
30+ assert . match ( source , / i f \( t y p e o f w i n d o w = = = ' u n d e f i n e d ' \) r e t u r n ; / ) ;
31+ assert . match ( source , / \{ C H A T _ T R A N S P O R T _ M O D E _ S T O R A G E _ K E Y \} / ) ;
32+ assert . match ( source , / \{ C H A T _ T R A N S P O R T _ M O D E _ W E B S O C K E T \} / ) ;
33+ } ) ;
0 commit comments