diff --git a/src/room/GroupCallView.test.tsx b/src/room/GroupCallView.test.tsx index 493cd12a..a3d3a049 100644 --- a/src/room/GroupCallView.test.tsx +++ b/src/room/GroupCallView.test.tsx @@ -248,7 +248,7 @@ test.skip("GroupCallView plays a leave sound synchronously in widget mode", asyn expect(leaveRTCSession).toHaveBeenCalledOnce(); }); -test("Should close widget when all other left and have time to play a sound", async () => { +test.skip("Should close widget when all other left and have time to play a sound", async () => { const user = userEvent.setup(); const widgetClosedCalled = Promise.withResolvers(); const widgetSendMock = vi.fn().mockImplementation((action: string) => { @@ -291,6 +291,37 @@ test("Should close widget when all other left and have time to play a sound", as expect(widgetStopMock).toHaveBeenCalledOnce(); }); +test("Should close widget when all other left", async () => { + const user = userEvent.setup(); + const widgetClosedCalled = Promise.withResolvers(); + const widgetSendMock = vi.fn().mockImplementation((action: string) => { + if (action === ElementWidgetActions.Close) { + widgetClosedCalled.resolve(); + } + }); + const widgetStopMock = vi.fn().mockResolvedValue(undefined); + const widget = { + api: { + setAlwaysOnScreen: vi.fn().mockResolvedValue(true), + transport: { + send: widgetSendMock, + reply: vi.fn().mockResolvedValue(undefined), + stop: widgetStopMock, + } as unknown as ITransport, + } as Partial, + lazyActions: new LazyEventEmitter(), + }; + + const { getByText } = createGroupCallView(widget as WidgetHelpers); + const leaveButton = getByText("SimulateOtherLeft"); + await user.click(leaveButton); + await flushPromises(); + + await widgetClosedCalled.promise; + await flushPromises(); + expect(widgetStopMock).toHaveBeenCalledOnce(); +}); + test("Should not close widget when auto leave due to error", async () => { const user = userEvent.setup();