Skip to content

Commit fa614d0

Browse files
committed
fix(qa): tighten kitchen sink rpc proof
1 parent 1d2bebb commit fa614d0

2 files changed

Lines changed: 74 additions & 5 deletions

File tree

scripts/e2e/kitchen-sink-rpc-walk.mjs

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,36 @@ export function assertKitchenSinkTextInvokeResult(payload) {
12621262
}
12631263
}
12641264

1265+
export function assertCreatedKitchenSinkSession(payload, expectedKey = SESSION_KEY) {
1266+
const created = assertObjectPayload(payload, "sessions.create");
1267+
if (created.ok !== true || created.key !== expectedKey || !isNonEmptyString(created.sessionId)) {
1268+
throw new Error(
1269+
`sessions.create did not return the requested Kitchen Sink session: ${boundedJsonPreview(
1270+
payload,
1271+
)}`,
1272+
);
1273+
}
1274+
return created;
1275+
}
1276+
1277+
export function assertKitchenSinkUiDescriptors(payload) {
1278+
const descriptorPayload = assertObjectPayload(payload, "plugins.uiDescriptors");
1279+
if (descriptorPayload.ok !== true || !Array.isArray(descriptorPayload.descriptors)) {
1280+
throw new Error(
1281+
`plugins.uiDescriptors returned invalid payload: ${boundedJsonPreview(payload)}`,
1282+
);
1283+
}
1284+
const descriptor = descriptorPayload.descriptors.find((entry) => entry?.pluginId === PLUGIN_ID);
1285+
if (!descriptor) {
1286+
throw new Error(
1287+
`plugins.uiDescriptors did not report Kitchen Sink descriptor for ${PLUGIN_ID}: ${boundedJsonPreview(
1288+
descriptorPayload.descriptors,
1289+
)}`,
1290+
);
1291+
}
1292+
return descriptor;
1293+
}
1294+
12651295
export function assertDiagnosticStabilityClean(payload) {
12661296
const problems = [];
12671297
if (!payload || typeof payload !== "object") {
@@ -2016,6 +2046,7 @@ export async function main() {
20162046
{ key: SESSION_KEY, agentId: "main", label: "kitchen-sink-rpc" },
20172047
rpcOptions,
20182048
);
2049+
assertCreatedKitchenSinkSession(createdSession);
20192050
const effective = await retryRpcCall(
20202051
"tools.effective",
20212052
{ sessionKey: createdSession.key, agentId: "main" },
@@ -2059,11 +2090,7 @@ export async function main() {
20592090
assertTtsProviderCoverage(ttsStatus, "status");
20602091

20612092
const uiDescriptors = await retryRpcCall("plugins.uiDescriptors", {}, rpcOptions);
2062-
if (!uiDescriptors || typeof uiDescriptors !== "object") {
2063-
throw new Error(
2064-
`plugins.uiDescriptors returned invalid payload: ${boundedJsonPreview(uiDescriptors)}`,
2065-
);
2066-
}
2093+
assertKitchenSinkUiDescriptors(uiDescriptors);
20672094
const stability = await retryRpcCall("diagnostics.stability", {}, rpcOptions);
20682095
assertDiagnosticStabilityClean(stability);
20692096
await sampleInFlight?.catch(() => {});

test/scripts/kitchen-sink-rpc-walk.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ import {
1616
appendBoundedOutput,
1717
assertChannelAccountRunning,
1818
assertCommandResourceCeiling,
19+
assertCreatedKitchenSinkSession,
1920
assertDiagnosticStabilityClean,
2021
assertExpectedKitchenSinkToolEntries,
2122
assertGatewayHealthPayload,
2223
assertGatewayStatusPayload,
24+
assertKitchenSinkUiDescriptors,
2325
assertKitchenSinkSearchInvokeResult,
2426
assertKitchenSinkTextInvokeResult,
2527
assertResourceCeiling,
@@ -920,6 +922,46 @@ describe("kitchen-sink RPC command catalog assertions", () => {
920922
expect(error.message).not.toContain("DO_NOT_DUMP_TOOL_MIDDLE");
921923
expect(error.message.length).toBeLessThan(1400);
922924
});
925+
926+
it("requires sessions.create to return the requested Kitchen Sink session", () => {
927+
expect(() =>
928+
assertCreatedKitchenSinkSession({
929+
ok: true,
930+
key: "agent:main:kitchen-sink-rpc",
931+
sessionId: "session-1",
932+
}),
933+
).not.toThrow();
934+
935+
expect(() =>
936+
assertCreatedKitchenSinkSession({
937+
ok: true,
938+
key: "agent:main:stale-session",
939+
sessionId: "session-1",
940+
}),
941+
).toThrow("sessions.create did not return the requested Kitchen Sink session");
942+
expect(() =>
943+
assertCreatedKitchenSinkSession({
944+
ok: true,
945+
key: "agent:main:kitchen-sink-rpc",
946+
}),
947+
).toThrow("sessions.create did not return the requested Kitchen Sink session");
948+
});
949+
950+
it("requires Kitchen Sink UI descriptor coverage", () => {
951+
expect(() =>
952+
assertKitchenSinkUiDescriptors({
953+
ok: true,
954+
descriptors: [{ pluginId: "openclaw-kitchen-sink-fixture", id: "kitchen-sink-panel" }],
955+
}),
956+
).not.toThrow();
957+
958+
expect(() => assertKitchenSinkUiDescriptors({})).toThrow(
959+
"plugins.uiDescriptors returned invalid payload",
960+
);
961+
expect(() => assertKitchenSinkUiDescriptors({ ok: true, descriptors: [] })).toThrow(
962+
"plugins.uiDescriptors did not report Kitchen Sink descriptor",
963+
);
964+
});
923965
});
924966

925967
describe("kitchen-sink RPC diagnostics assertions", () => {

0 commit comments

Comments
 (0)