mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-08 19:12:22 +00:00
fix(qa): avoid telegram proof artifact collisions
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
spawnSync,
|
||||
type SpawnOptionsWithoutStdio,
|
||||
} from "node:child_process";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
@@ -270,6 +271,10 @@ function parseTcpPort(value: string, label: string) {
|
||||
return parsed;
|
||||
}
|
||||
|
||||
function createTelegramProofRunId() {
|
||||
return `${new Date().toISOString().replace(/[:.]/gu, "-")}-${randomUUID().slice(0, 8)}`;
|
||||
}
|
||||
|
||||
export function parseArgs(argvInput: string[]): Options {
|
||||
let argv = argvInput;
|
||||
argv = argv[0] === "--" ? argv.slice(1) : argv;
|
||||
@@ -285,7 +290,6 @@ export function parseArgs(argvInput: string[]): Options {
|
||||
"view",
|
||||
]);
|
||||
const command = commands.has(argv[0] ?? "") ? (argv.shift() as Options["command"]) : "probe";
|
||||
const stamp = new Date().toISOString().replace(/[:.]/gu, "-");
|
||||
const opts: Options = {
|
||||
crabboxClass: "standard",
|
||||
command,
|
||||
@@ -299,7 +303,7 @@ export function parseArgs(argvInput: string[]): Options {
|
||||
keepBox: false,
|
||||
mockResponseText: "OPENCLAW_E2E_OK",
|
||||
mockPort: 19_882,
|
||||
outputDir: path.join(DEFAULT_OUTPUT_ROOT, stamp),
|
||||
outputDir: path.join(DEFAULT_OUTPUT_ROOT, createTelegramProofRunId()),
|
||||
previewCropWidth: TELEGRAM_PROOF_CROP.cropWidth,
|
||||
previewFps: 24,
|
||||
previewWidth: 1920,
|
||||
|
||||
@@ -157,6 +157,20 @@ describe("telegram user Crabbox proof log polling", () => {
|
||||
expect(parseArgs(["--text", "-ping"]).text).toBe("-ping");
|
||||
});
|
||||
|
||||
it("uses unique default output dirs", () => {
|
||||
const firstOutputDir = parseArgs([]).outputDir;
|
||||
const secondOutputDir = parseArgs([]).outputDir;
|
||||
|
||||
expect(path.dirname(firstOutputDir)).toBe(
|
||||
path.join(".artifacts", "qa-e2e", "telegram-user-crabbox"),
|
||||
);
|
||||
expect(path.basename(firstOutputDir)).toMatch(
|
||||
/^\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}-\d{3}Z-[a-f0-9]{8}$/u,
|
||||
);
|
||||
expect(secondOutputDir).not.toBe(firstOutputDir);
|
||||
expect(parseArgs(["--output-dir", ".artifacts/custom"]).outputDir).toBe(".artifacts/custom");
|
||||
});
|
||||
|
||||
it("clamps proof timeout args before they reach Node timers", () => {
|
||||
expect(parseArgs(["--timeout-ms", String(MAX_TIMER_TIMEOUT_MS + 1)]).timeoutMs).toBe(
|
||||
MAX_TIMER_TIMEOUT_MS,
|
||||
|
||||
Reference in New Issue
Block a user