fix tests
This commit is contained in:
@@ -250,10 +250,13 @@ test.skip("GroupCallView plays a leave sound synchronously in widget mode", asyn
|
|||||||
|
|
||||||
test("Should close widget when all other left and have time to play a sound", async () => {
|
test("Should close widget when all other left and have time to play a sound", async () => {
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
const widgetClosedCalled = Promise.withResolvers<void>();
|
let widgetClosedCalled = false;
|
||||||
|
const { promise: widgetClosedPromise, resolve: widgetClosedResolver } =
|
||||||
|
Promise.withResolvers<void>();
|
||||||
const widgetSendMock = vi.fn().mockImplementation((action: string) => {
|
const widgetSendMock = vi.fn().mockImplementation((action: string) => {
|
||||||
if (action === ElementWidgetActions.Close) {
|
if (action === ElementWidgetActions.Close) {
|
||||||
widgetClosedCalled.resolve();
|
widgetClosedCalled = true;
|
||||||
|
widgetClosedResolver();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const widgetStopMock = vi.fn().mockResolvedValue(undefined);
|
const widgetStopMock = vi.fn().mockResolvedValue(undefined);
|
||||||
@@ -280,17 +283,18 @@ test("Should close widget when all other left and have time to play a sound", as
|
|||||||
const leaveButton = getByText("SimulateOtherLeft");
|
const leaveButton = getByText("SimulateOtherLeft");
|
||||||
await user.click(leaveButton);
|
await user.click(leaveButton);
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
expect(widgetSendMock).not.toHaveBeenCalled();
|
expect(widgetClosedCalled).toBeFalsy();
|
||||||
resolvePlaySound.resolve();
|
resolvePlaySound.resolve();
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
|
|
||||||
// Expect the leave sound to be played but silent (volumeOverwrite = 0)
|
// Expect the leave sound to be played but silent (volumeOverwrite = 0)
|
||||||
// The allOthersLeft effect should already play a leave sound for the last user in the call.
|
// The allOthersLeft effect should already play a leave sound for the last user in the call.
|
||||||
expect(playSound).toHaveBeenCalledWith("left", 0);
|
expect(playSound).toHaveBeenCalledWith("left", 0);
|
||||||
await widgetClosedCalled.promise;
|
await widgetClosedPromise;
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
|
expect(widgetClosedCalled).toBeTruthy();
|
||||||
expect(widgetStopMock).toHaveBeenCalledOnce();
|
expect(widgetStopMock).toHaveBeenCalledOnce();
|
||||||
});
|
}, 80000);
|
||||||
|
|
||||||
test("Should close widget when all other left", async () => {
|
test("Should close widget when all other left", async () => {
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
|
|||||||
Reference in New Issue
Block a user