@@ -2,6 +2,8 @@ import { afterEach, describe, expect, test } from "bun:test";
22import {
33 buildWindowsTaskXml ,
44 evaluateWindowsSchedulerInstallVerification ,
5+ formatWindowsSchedulerServiceStatus ,
6+ inspectWindowsSchedulerServiceStatus ,
57 probeWindowsSchedulerTask ,
68 setQuerySchtasksForTests ,
79 windowsSchedulerCsvIncludesTask ,
@@ -44,6 +46,26 @@ describe("probeWindowsSchedulerTask", () => {
4446 expect ( windowsSchedulerTaskInstalled ( "opencodex-proxy" ) ) . toBe ( true ) ;
4547 } ) ;
4648
49+ test ( "recognizes the task without exposing mojibake from localized table output" , ( ) => {
50+ Object . defineProperty ( process , "platform" , { configurable : true , value : "win32" } ) ;
51+ const localizedTable = [
52+ "����: \\" ,
53+ "�۾� �̸� ���� ���� �ð� ����" ,
54+ "======================================== ====================== ===============" ,
55+ "opencodex-proxy N/A �غ�" ,
56+ ] . join ( "\n" ) ;
57+ setQuerySchtasksForTests ( ( ) => localizedTable ) ;
58+
59+ const result = formatWindowsSchedulerServiceStatus (
60+ probeWindowsSchedulerTask ( "opencodex-proxy" ) ,
61+ { status : "running" , port : 10100 } ,
62+ ) ;
63+
64+ expect ( result ) . toBe ( "✅ service installed (Task Scheduler); OpenCodex proxy running on port 10100." ) ;
65+ expect ( result ) . not . toContain ( "����" ) ;
66+ expect ( result ) . not . toContain ( "�۾�" ) ;
67+ } ) ;
68+
4769 test ( "falls back to CSV listing when the specific query fails" , ( ) => {
4870 Object . defineProperty ( process , "platform" , { configurable : true , value : "win32" } ) ;
4971 setQuerySchtasksForTests ( ( args ) => {
@@ -83,6 +105,34 @@ describe("probeWindowsSchedulerTask", () => {
83105 } ) ;
84106} ) ;
85107
108+ describe ( "formatWindowsSchedulerServiceStatus" , ( ) => {
109+ test ( "reports task and identity-checked proxy state independently" , ( ) => {
110+ expect ( formatWindowsSchedulerServiceStatus ( { status : "present" } , { status : "not-running" } ) )
111+ . toBe ( "⚠️ service installed (Task Scheduler); OpenCodex proxy not running." ) ;
112+ expect ( formatWindowsSchedulerServiceStatus ( { status : "present" } , { status : "unknown" } ) )
113+ . toBe ( "⚠️ service installed (Task Scheduler); OpenCodex proxy status unknown." ) ;
114+ expect ( formatWindowsSchedulerServiceStatus ( { status : "absent" } , { status : "running" , port : 3593 } ) )
115+ . toBe ( "❌ service not installed (Task Scheduler); OpenCodex proxy is running independently on port 3593." ) ;
116+ expect ( formatWindowsSchedulerServiceStatus ( { status : "absent" } , { status : "not-running" } ) )
117+ . toBe ( "❌ service not installed (Task Scheduler)." ) ;
118+ expect ( formatWindowsSchedulerServiceStatus ( { status : "unknown" , detail : "����" } , { status : "running" , port : 10100 } ) )
119+ . toBe ( "⚠️ Task Scheduler registration unknown; OpenCodex proxy running on port 10100." ) ;
120+ expect ( formatWindowsSchedulerServiceStatus ( { status : "unknown" , detail : "����" } , { status : "not-running" } ) )
121+ . toBe ( "⚠️ service status unknown (Task Scheduler query failed); OpenCodex proxy not running." ) ;
122+ } ) ;
123+
124+ test ( "keeps scheduler and runtime probe failures locale-independent" , async ( ) => {
125+ const status = await inspectWindowsSchedulerServiceStatus ( {
126+ probeTask : ( ) => { throw new Error ( "���� ����" ) ; } ,
127+ findProxy : async ( ) => { throw new Error ( "connection failure" ) ; } ,
128+ } ) ;
129+
130+ expect ( status ) . toBe ( "⚠️ service status unknown (Task Scheduler and proxy checks failed)." ) ;
131+ expect ( status ) . not . toContain ( "����" ) ;
132+ expect ( status ) . not . toContain ( "connection failure" ) ;
133+ } ) ;
134+ } ) ;
135+
86136describe ( "evaluateWindowsSchedulerInstallVerification" , ( ) => {
87137 const wscript = "C:\\Windows\\System32\\wscript.exe" ;
88138 const launcher = "C:\\Users\\Test\\.opencodex\\opencodex-service-launcher.vbs" ;
0 commit comments