mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 01:04:32 +00:00
feat(nodes): expose device diagnostics and notification actions
This commit is contained in:
@@ -174,6 +174,40 @@ describe("nodes notifications_list", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("nodes notifications_action", () => {
|
||||
it("invokes notifications.actions dismiss", async () => {
|
||||
callGateway.mockImplementation(async ({ method, params }) => {
|
||||
if (method === "node.list") {
|
||||
return mockNodeList(["notifications.actions"]);
|
||||
}
|
||||
if (method === "node.invoke") {
|
||||
expect(params).toMatchObject({
|
||||
nodeId: NODE_ID,
|
||||
command: "notifications.actions",
|
||||
params: {
|
||||
key: "n1",
|
||||
action: "dismiss",
|
||||
},
|
||||
});
|
||||
return { payload: { ok: true, key: "n1", action: "dismiss" } };
|
||||
}
|
||||
return unexpectedGatewayMethod(method);
|
||||
});
|
||||
|
||||
const result = await executeNodes({
|
||||
action: "notifications_action",
|
||||
node: NODE_ID,
|
||||
notificationKey: "n1",
|
||||
notificationAction: "dismiss",
|
||||
});
|
||||
|
||||
expect(result.content?.[0]).toMatchObject({
|
||||
type: "text",
|
||||
text: expect.stringContaining('"dismiss"'),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("nodes device_status and device_info", () => {
|
||||
it("invokes device.status and returns payload", async () => {
|
||||
callGateway.mockImplementation(async ({ method, params }) => {
|
||||
@@ -237,6 +271,71 @@ describe("nodes device_status and device_info", () => {
|
||||
text: expect.stringContaining('"systemName"'),
|
||||
});
|
||||
});
|
||||
|
||||
it("invokes device.permissions and returns payload", async () => {
|
||||
callGateway.mockImplementation(async ({ method, params }) => {
|
||||
if (method === "node.list") {
|
||||
return mockNodeList(["device.permissions"]);
|
||||
}
|
||||
if (method === "node.invoke") {
|
||||
expect(params).toMatchObject({
|
||||
nodeId: NODE_ID,
|
||||
command: "device.permissions",
|
||||
params: {},
|
||||
});
|
||||
return {
|
||||
payload: {
|
||||
permissions: {
|
||||
camera: { status: "granted", promptable: false },
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
return unexpectedGatewayMethod(method);
|
||||
});
|
||||
|
||||
const result = await executeNodes({
|
||||
action: "device_permissions",
|
||||
node: NODE_ID,
|
||||
});
|
||||
|
||||
expect(result.content?.[0]).toMatchObject({
|
||||
type: "text",
|
||||
text: expect.stringContaining('"permissions"'),
|
||||
});
|
||||
});
|
||||
|
||||
it("invokes device.health and returns payload", async () => {
|
||||
callGateway.mockImplementation(async ({ method, params }) => {
|
||||
if (method === "node.list") {
|
||||
return mockNodeList(["device.health"]);
|
||||
}
|
||||
if (method === "node.invoke") {
|
||||
expect(params).toMatchObject({
|
||||
nodeId: NODE_ID,
|
||||
command: "device.health",
|
||||
params: {},
|
||||
});
|
||||
return {
|
||||
payload: {
|
||||
memory: { pressure: "normal" },
|
||||
battery: { chargingType: "usb" },
|
||||
},
|
||||
};
|
||||
}
|
||||
return unexpectedGatewayMethod(method);
|
||||
});
|
||||
|
||||
const result = await executeNodes({
|
||||
action: "device_health",
|
||||
node: NODE_ID,
|
||||
});
|
||||
|
||||
expect(result.content?.[0]).toMatchObject({
|
||||
type: "text",
|
||||
text: expect.stringContaining('"memory"'),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("nodes run", () => {
|
||||
|
||||
Reference in New Issue
Block a user