Skip to content

Commit a500ad9

Browse files
committed
Add a test for a discarded message.
1 parent 51265c5 commit a500ad9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/ClientWidgetApi-test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,20 @@ describe("ClientWidgetApi", () => {
11101110
await clientWidgetApi.feedToDevice(event, encrypted);
11111111
expect(transport.send).toHaveBeenCalledWith(WidgetApiToWidgetAction.SendToDevice, { ...event, encrypted });
11121112
});
1113+
it("ignores messages not allowed by capabilities", async () => {
1114+
const event: IToDeviceMessage = {
1115+
content: { foo: "bar" },
1116+
type: "org.example.othertype",
1117+
sender: "@alice:example.org",
1118+
};
1119+
// Give the widget capabilities to receive from just one room
1120+
await loadIframe(["org.matrix.msc3819.receive.to_device:org.example.mytype"]);
1121+
// Clear all prior messages.
1122+
jest.mocked(transport.send).mockClear();
1123+
// Event from the matching room should be forwarded
1124+
await clientWidgetApi.feedToDevice(event, false);
1125+
expect(transport.send).not.toHaveBeenCalled();
1126+
});
11131127
});
11141128

11151129
describe("update_delayed_event action", () => {

0 commit comments

Comments
 (0)