@@ -12,6 +12,9 @@ const resolveControlUiLinksMock = vi.hoisted(() =>
|
12 | 12 | ); |
13 | 13 | const isSystemdUnavailableDetailMock = vi.hoisted(() => vi.fn(() => false)); |
14 | 14 | const renderSystemdUnavailableHintsMock = vi.hoisted(() => vi.fn<() => string[]>(() => [])); |
| 15 | +const isWSLEnvMock = vi.hoisted(() => |
| 16 | +vi.fn((env?: Record<string, string | undefined>) => Boolean(env?.WSL_DISTRO_NAME)), |
| 17 | +); |
15 | 18 | |
16 | 19 | vi.mock("../../runtime.js", () => ({ |
17 | 20 | defaultRuntime: runtime, |
@@ -55,7 +58,7 @@ vi.mock("../../daemon/systemd-hints.js", () => ({
|
55 | 58 | })); |
56 | 59 | |
57 | 60 | vi.mock("../../infra/wsl.js", () => ({ |
58 | | -isWSLEnv: () => false, |
| 61 | +isWSLEnv: isWSLEnvMock, |
59 | 62 | })); |
60 | 63 | |
61 | 64 | vi.mock("./shared.js", () => ({ |
@@ -93,6 +96,7 @@ describe("printDaemonStatus", () => {
|
93 | 96 | resolveControlUiLinksMock.mockClear(); |
94 | 97 | isSystemdUnavailableDetailMock.mockReset().mockReturnValue(false); |
95 | 98 | renderSystemdUnavailableHintsMock.mockReset().mockReturnValue([]); |
| 99 | +isWSLEnvMock.mockClear(); |
96 | 100 | }); |
97 | 101 | |
98 | 102 | it("prints stale gateway pid guidance when runtime does not own the listener", () => { |
@@ -179,6 +183,50 @@ describe("printDaemonStatus", () => {
|
179 | 183 | expectMockLineContains(runtime.log, "protocol mismatch after rollback"); |
180 | 184 | }); |
181 | 185 | |
| 186 | +it("uses service command env for WSL systemd unavailable hints", () => { |
| 187 | +const originalPlatform = process.platform; |
| 188 | +Object.defineProperty(process, "platform", { value: "linux" }); |
| 189 | +isSystemdUnavailableDetailMock.mockReturnValue(true); |
| 190 | +renderSystemdUnavailableHintsMock.mockReturnValue(["wsl hint"]); |
| 191 | +try { |
| 192 | +printDaemonStatus( |
| 193 | +{ |
| 194 | +service: { |
| 195 | +label: "systemd", |
| 196 | +loaded: true, |
| 197 | +loadedText: "loaded", |
| 198 | +notLoadedText: "not loaded", |
| 199 | +runtime: { |
| 200 | +status: "unknown", |
| 201 | +detail: "System has not been booted with systemd as init system", |
| 202 | +}, |
| 203 | +command: { |
| 204 | +programArguments: [], |
| 205 | +environment: { WSL_DISTRO_NAME: "Ubuntu" }, |
| 206 | +}, |
| 207 | +}, |
| 208 | +rpc: { |
| 209 | +ok: false, |
| 210 | +error: "unavailable", |
| 211 | +url: "ws://127.0.0.1:18789", |
| 212 | +}, |
| 213 | +extraServices: [], |
| 214 | +}, |
| 215 | +{ json: false }, |
| 216 | +); |
| 217 | +} finally { |
| 218 | +Object.defineProperty(process, "platform", { value: originalPlatform }); |
| 219 | +} |
| 220 | + |
| 221 | +expect(isWSLEnvMock).toHaveBeenCalledWith({ WSL_DISTRO_NAME: "Ubuntu" }); |
| 222 | +expect(renderSystemdUnavailableHintsMock).toHaveBeenCalledWith({ |
| 223 | +wsl: true, |
| 224 | +kind: "generic_unavailable", |
| 225 | +container: false, |
| 226 | +}); |
| 227 | +expectMockLineContains(runtime.error, "wsl hint"); |
| 228 | +}); |
| 229 | + |
182 | 230 | it("prints stale updater launchd job guidance", () => { |
183 | 231 | printDaemonStatus( |
184 | 232 | { |
|