fix(test): dedupe kitchen sink command assertions · openclaw/openclaw@6eb46ce
vincentkoc
·
2026-05-25
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -524,11 +524,11 @@ function valuesForKey(value, key) {
|
524 | 524 | return values; |
525 | 525 | } |
526 | 526 | |
527 | | -function extractPluginCommandNames(payload) { |
| 527 | +export function extractPluginCommandNames(payload) { |
528 | 528 | const commands = Array.isArray(payload?.commands) ? payload.commands : []; |
529 | 529 | const names = []; |
530 | 530 | for (const entry of commands) { |
531 | | -if (entry?.source !== "plugin" && entry?.pluginId !== PLUGIN_ID) { |
| 531 | +if (entry?.source !== "plugin") { |
532 | 532 | continue; |
533 | 533 | } |
534 | 534 | names.push(entry?.name, entry?.nativeName); |
@@ -539,6 +539,7 @@ function extractPluginCommandNames(payload) {
|
539 | 539 | return names |
540 | 540 | .filter(isNonEmptyString) |
541 | 541 | .map((name) => name.replace(/^\//u, "")) |
| 542 | +.filter((name, index, all) => all.indexOf(name) === index) |
542 | 543 | .toSorted((left, right) => left.localeCompare(right)); |
543 | 544 | } |
544 | 545 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -4,6 +4,7 @@ import path from "node:path";
|
4 | 4 | import { describe, expect, it, vi } from "vitest"; |
5 | 5 | import { |
6 | 6 | assertResourceCeiling, |
| 7 | +extractPluginCommandNames, |
7 | 8 | fetchJson, |
8 | 9 | findDistCallGatewayModuleFiles, |
9 | 10 | sampleProcess, |
@@ -47,6 +48,27 @@ describe("kitchen-sink RPC caller loading", () => {
|
47 | 48 | }); |
48 | 49 | }); |
49 | 50 | |
| 51 | +describe("kitchen-sink RPC command catalog assertions", () => { |
| 52 | +it("keeps plugin commands and deduplicates aliases", () => { |
| 53 | +expect( |
| 54 | +extractPluginCommandNames({ |
| 55 | +commands: [ |
| 56 | +{ |
| 57 | +source: "core", |
| 58 | +name: "/kitchen-sink", |
| 59 | +}, |
| 60 | +{ |
| 61 | +source: "plugin", |
| 62 | +name: "/kitchen", |
| 63 | +nativeName: "kitchen", |
| 64 | +textAliases: ["/kitchen-sink", "kitchen-sink"], |
| 65 | +}, |
| 66 | +], |
| 67 | +}), |
| 68 | +).toEqual(["kitchen", "kitchen-sink"]); |
| 69 | +}); |
| 70 | +}); |
| 71 | + |
50 | 72 | describe("kitchen-sink RPC process sampling", () => { |
51 | 73 | it("samples RSS on Windows instead of silently disabling the resource guard", async () => { |
52 | 74 | const calls: Array<{ command: string; args: string[] }> = []; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。