mirror of
https://github.com/vector-im/element-call.git
synced 2026-10-16 23:45:50 +00:00
Always stop the widget transport when closing
close() sent io.element.close and then stopped the transport, so a rejected send skipped the stop. Both call sites this replaced stopped it unconditionally — ErrorView in a finally, GroupCallView outside its try/catch — because a host that never acknowledges the request would otherwise leave the messaging live and the close button doing nothing. Restore that with a finally.
This commit is contained in:
+31
-1
@@ -10,7 +10,7 @@ import { type WidgetApi } from "matrix-widget-api";
|
||||
import EventEmitter from "events";
|
||||
|
||||
import { createWidgetHostBridge, nullHostBridge } from "./HostBridge";
|
||||
import { type WidgetHelpers } from "./widget";
|
||||
import { ElementWidgetActions, type WidgetHelpers } from "./widget";
|
||||
|
||||
function mockWidget(api: Partial<WidgetApi>): WidgetHelpers {
|
||||
return {
|
||||
@@ -60,6 +60,36 @@ describe("createWidgetHostBridge", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("close", () => {
|
||||
test("asks the host to close, then stops the transport", async () => {
|
||||
const transport = {
|
||||
send: vi.fn().mockResolvedValue(undefined),
|
||||
stop: vi.fn(),
|
||||
};
|
||||
const bridge = createWidgetHostBridge(mockWidget({ transport } as never));
|
||||
|
||||
await bridge.close!();
|
||||
|
||||
expect(transport.send).toHaveBeenCalledWith(
|
||||
ElementWidgetActions.Close,
|
||||
{},
|
||||
);
|
||||
expect(transport.stop).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
test("stops the transport even when the host refuses to close", async () => {
|
||||
const transport = {
|
||||
send: vi.fn().mockRejectedValue(new Error("no")),
|
||||
stop: vi.fn(),
|
||||
};
|
||||
const bridge = createWidgetHostBridge(mockWidget({ transport } as never));
|
||||
|
||||
// Leaving the messaging live would leave the close affordance dead
|
||||
await expect(bridge.close!()).rejects.toThrow("no");
|
||||
expect(transport.stop).toHaveBeenCalledOnce();
|
||||
});
|
||||
});
|
||||
|
||||
describe("supportsReactions", () => {
|
||||
const capabilities = [
|
||||
"org.matrix.msc2762.send.event:m.reaction",
|
||||
|
||||
Reference in New Issue
Block a user