@@ -36,6 +36,22 @@ describe("ElectronShell", () => {
3636 } ) . pipe ( Effect . provide ( ElectronShell . layer ) ) ,
3737 ) ;
3838
39+ it . effect ( "opens remote SSH editor URLs" , ( ) =>
40+ Effect . gen ( function * ( ) {
41+ openExternalMock . mockResolvedValue ( undefined ) ;
42+
43+ const electronShell = yield * ElectronShell . ElectronShell ;
44+ const result = yield * electronShell . openExternal (
45+ "vscode://vscode-remote/ssh-remote+example.com/home/user/project" ,
46+ ) ;
47+
48+ assert . equal ( result , true ) ;
49+ assert . deepEqual ( openExternalMock . mock . calls , [
50+ [ "vscode://vscode-remote/ssh-remote+example.com/home/user/project" ] ,
51+ ] ) ;
52+ } ) . pipe ( Effect . provide ( ElectronShell . layer ) ) ,
53+ ) ;
54+
3955 it . effect ( "does not open unsafe external URLs" , ( ) =>
4056 Effect . gen ( function * ( ) {
4157 const electronShell = yield * ElectronShell . ElectronShell ;
@@ -46,6 +62,20 @@ describe("ElectronShell", () => {
4662 } ) . pipe ( Effect . provide ( ElectronShell . layer ) ) ,
4763 ) ;
4864
65+ it . effect ( "does not open non-remote editor URLs" , ( ) =>
66+ Effect . gen ( function * ( ) {
67+ openExternalMock . mockResolvedValue ( undefined ) ;
68+
69+ const electronShell = yield * ElectronShell . ElectronShell ;
70+ const result = yield * electronShell . openExternal (
71+ "vscode://ms-python.python/some-command?argument=attacker" ,
72+ ) ;
73+
74+ assert . equal ( result , false ) ;
75+ assert . equal ( openExternalMock . mock . calls . length , 0 ) ;
76+ } ) . pipe ( Effect . provide ( ElectronShell . layer ) ) ,
77+ ) ;
78+
4979 it . effect ( "returns false when Electron rejects openExternal" , ( ) =>
5080 Effect . gen ( function * ( ) {
5181 openExternalMock . mockRejectedValue ( new Error ( "open failed" ) ) ;
0 commit comments