@@ -26,6 +26,25 @@ function runAssert(home: string, channel: string, ...tokens: string[]) {
|
26 | 26 | ); |
27 | 27 | } |
28 | 28 | |
| 29 | +function runStatusAssert(channel: string, channelsStatus: unknown, statusText: string) { |
| 30 | +const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-status-assertions-")); |
| 31 | +try { |
| 32 | +const channelsStatusPath = path.join(tempDir, "channels-status.json"); |
| 33 | +const statusTextPath = path.join(tempDir, "status.txt"); |
| 34 | +fs.writeFileSync(channelsStatusPath, JSON.stringify(channelsStatus)); |
| 35 | +fs.writeFileSync(statusTextPath, statusText); |
| 36 | +return spawnSync( |
| 37 | +process.execPath, |
| 38 | +[assertionsPath, "assert-status-surfaces", channel, channelsStatusPath, statusTextPath], |
| 39 | +{ |
| 40 | +encoding: "utf8", |
| 41 | +}, |
| 42 | +); |
| 43 | +} finally { |
| 44 | +fs.rmSync(tempDir, { force: true, recursive: true }); |
| 45 | +} |
| 46 | +} |
| 47 | + |
29 | 48 | describe("npm onboard channel agent assertions", () => { |
30 | 49 | it("validates channel tokens in their canonical config fields", () => { |
31 | 50 | const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-channel-assertions-")); |
@@ -59,4 +78,50 @@ describe("npm onboard channel agent assertions", () => {
|
59 | 78 | fs.rmSync(tempDir, { force: true, recursive: true }); |
60 | 79 | } |
61 | 80 | }); |
| 81 | + |
| 82 | +it("validates configured channels in the plain status Channels section", () => { |
| 83 | +const result = runStatusAssert( |
| 84 | +"telegram", |
| 85 | +{ configuredChannels: ["telegram"] }, |
| 86 | +[ |
| 87 | +"# OpenClaw status", |
| 88 | +"", |
| 89 | +"# Overview", |
| 90 | +"OS macOS", |
| 91 | +"", |
| 92 | +"# Channels", |
| 93 | +"Channel State Detail", |
| 94 | +"telegram ok configured", |
| 95 | +"", |
| 96 | +"# Sessions", |
| 97 | +"No sessions", |
| 98 | +].join("\n"), |
| 99 | +); |
| 100 | + |
| 101 | +expect(result.status).toBe(0); |
| 102 | +}); |
| 103 | + |
| 104 | +it("rejects plain status output that mentions the channel outside the Channels section", () => { |
| 105 | +const result = runStatusAssert( |
| 106 | +"telegram", |
| 107 | +{ configuredChannels: ["telegram"] }, |
| 108 | +[ |
| 109 | +"# OpenClaw status", |
| 110 | +"", |
| 111 | +"# Overview", |
| 112 | +"OS macOS", |
| 113 | +"", |
| 114 | +"# Channels", |
| 115 | +"No channels configured", |
| 116 | +"", |
| 117 | +"# Sessions", |
| 118 | +"telegram appeared in an unrelated session note", |
| 119 | +].join("\n"), |
| 120 | +); |
| 121 | + |
| 122 | +expect(result.status).not.toBe(0); |
| 123 | +expect(result.stderr).toContain( |
| 124 | +"plain status output did not mention telegram in the Channels section", |
| 125 | +); |
| 126 | +}); |
62 | 127 | }); |