test: dedupe gateway browser discord and channel coverage

This commit is contained in:
Peter Steinberger
2026-02-22 17:11:42 +00:00
parent 34ea33f057
commit 296b19e413
29 changed files with 938 additions and 1041 deletions

View File

@@ -223,6 +223,12 @@ function buildExecApprovalPayload(container: DiscordUiContainer): MessagePayload
return { components };
}
function formatCommandPreview(commandText: string, maxChars: number): string {
const commandRaw =
commandText.length > maxChars ? `${commandText.slice(0, maxChars)}...` : commandText;
return commandRaw.replace(/`/g, "\u200b`");
}
function createExecApprovalRequestContainer(params: {
request: ExecApprovalRequest;
cfg: OpenClawConfig;
@@ -230,8 +236,7 @@ function createExecApprovalRequestContainer(params: {
actionRow?: Row<Button>;
}): ExecApprovalContainer {
const commandText = params.request.request.command;
const commandRaw = commandText.length > 1000 ? `${commandText.slice(0, 1000)}...` : commandText;
const commandPreview = commandRaw.replace(/`/g, "\u200b`");
const commandPreview = formatCommandPreview(commandText, 1000);
const expiresAtSeconds = Math.max(0, Math.floor(params.request.expiresAtMs / 1000));
return new ExecApprovalContainer({
@@ -255,8 +260,7 @@ function createResolvedContainer(params: {
accountId: string;
}): ExecApprovalContainer {
const commandText = params.request.request.command;
const commandRaw = commandText.length > 500 ? `${commandText.slice(0, 500)}...` : commandText;
const commandPreview = commandRaw.replace(/`/g, "\u200b`");
const commandPreview = formatCommandPreview(commandText, 500);
const decisionLabel =
params.decision === "allow-once"
@@ -289,8 +293,7 @@ function createExpiredContainer(params: {
accountId: string;
}): ExecApprovalContainer {
const commandText = params.request.request.command;
const commandRaw = commandText.length > 500 ? `${commandText.slice(0, 500)}...` : commandText;
const commandPreview = commandRaw.replace(/`/g, "\u200b`");
const commandPreview = formatCommandPreview(commandText, 500);
return new ExecApprovalContainer({
cfg: params.cfg,