Files
openclaw/test/scripts/telegram-e2e-userbot-skill.test.ts
de5e31b895 refactor(telegram): remove redundant test coverage (#155040)
Consolidate Telegram tests at their behavioral owners and remove redundant mock inventories and private test seams while retaining distinct routing, authorization, replay, media, and streaming regression checks.

Align retained delivery tests with the landed shared final-delivery lifecycle. Respect replyToMode off when finalizing a quoted preview so the answer is edited in place instead of deleted and re-sent.

Exact-head hosted CI passed. The PR records current-head Telegram Test Server proof with reverted controls and the remaining validation limitations.

Work session: https://team.openclaw.ai/chat/roboclaw/dashboard/7320cd5b-9414-4cf6-99fe-0abb9a51df58

Co-authored-by: obviyus <22031114+obviyus@users.noreply.github.com>
Co-authored-by: steipete <58493+steipete@users.noreply.github.com>
2026-09-23 00:50:06 -07:00

77 lines
2.8 KiB
TypeScript

import { spawnSync } from "node:child_process";
import fs from "node:fs";
import path from "node:path";
import { describe, expect, it } from "vitest";
import { parse } from "yaml";
import { resolveTestNodeExecPath } from "../../src/test-utils/node-process.js";
const scriptsDir = path.resolve(".agents/skills/telegram-e2e-userbot/scripts");
const testNodeExecPath = resolveTestNodeExecPath();
function requireSuccess(command: string, args: string[]) {
const result = spawnSync(command, args, {
cwd: process.cwd(),
encoding: "utf8",
timeout: 120_000,
});
expect(result.error, `${result.stdout}${result.stderr}`).toBeUndefined();
expect(`${result.stdout}${result.stderr}`).not.toContain("not ok");
expect(result.status, `${command} ${args.join(" ")}\n${result.stdout}${result.stderr}`).toBe(0);
}
describe("repository Telegram E2E skill", () => {
it("registers its UI metadata through the skill interface", () => {
const descriptor = parse(
fs.readFileSync(".agents/skills/telegram-e2e-userbot/agents/openai.yaml", "utf8"),
);
expect(Object.keys(descriptor)).toEqual(["interface"]);
expect(descriptor.interface.default_prompt).toContain("$telegram-e2e-userbot");
});
it("passes its Node test suite", () => {
const tests = fs
.readdirSync(scriptsDir)
.filter((entry) => entry.endsWith(".test.mjs"))
.toSorted()
.map((entry) => path.join(scriptsDir, entry));
expect(tests.length).toBeGreaterThan(0);
requireSuccess(testNodeExecPath, ["--test", ...tests]);
});
it.each(["pending", "exited"])("settles a %s triage fixture after readiness fails", (mode) => {
const preload = new URL("../fixtures/triage-fixture-startup.mjs", import.meta.url);
preload.searchParams.set("mode", mode);
const result = spawnSync(
testNodeExecPath,
[
"--import",
preload.href,
"--test",
"--test-isolation=none",
"--test-name-pattern=^emits interleaved visible and reasoning blocks$",
path.join(scriptsDir, "triage-mock-openai.test.mjs"),
],
{ cwd: process.cwd(), encoding: "utf8", timeout: 120_000 },
);
const output = `${result.stdout}${result.stderr}`;
expect(result.error, output).toBeUndefined();
expect(result.status, output).toBe(1);
expect(output).toContain("AssertionError");
expect(output).toContain("mock-openai listening");
expect(result.stderr).toContain(
`triage-fixture-exited:${mode === "exited" ? "42" : "SIGTERM"}`,
);
});
it("passes its Python test suite", () => {
const tests = fs
.readdirSync(scriptsDir)
.filter((entry) => entry.endsWith(".test.py"))
.toSorted();
expect(tests.length).toBeGreaterThan(0);
for (const test of tests) {
requireSuccess("python3", [path.join(scriptsDir, test)]);
}
});
});