From ff15249f03fc5624237dbb61e938614b7f2abadf Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Thu, 8 Aug 2024 07:45:20 -0400 Subject: [PATCH] Make widget tests throw when a modal is shown (#12834) Instead of waiting for tests to time out if they show a dialog that they cannot interact with, throw an error immediately if a dialog is shown. --- test/stores/widgets/StopGapWidgetDriver-test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/stores/widgets/StopGapWidgetDriver-test.ts b/test/stores/widgets/StopGapWidgetDriver-test.ts index efe0fafe55..282ce23d6f 100644 --- a/test/stores/widgets/StopGapWidgetDriver-test.ts +++ b/test/stores/widgets/StopGapWidgetDriver-test.ts @@ -49,6 +49,7 @@ import { StopGapWidgetDriver } from "../../../src/stores/widgets/StopGapWidgetDr import { stubClient } from "../../test-utils"; import { ModuleRunner } from "../../../src/modules/ModuleRunner"; import dis from "../../../src/dispatcher/dispatcher"; +import Modal from "../../../src/Modal"; import SettingsStore from "../../../src/settings/SettingsStore"; describe("StopGapWidgetDriver", () => { @@ -68,6 +69,10 @@ describe("StopGapWidgetDriver", () => { "!1:example.org", ); + jest.spyOn(Modal, "createDialog").mockImplementation(() => { + throw new Error("Should not have to create a dialog"); + }); + beforeEach(() => { stubClient(); client = mocked(MatrixClientPeg.safeGet()); @@ -127,7 +132,6 @@ describe("StopGapWidgetDriver", () => { "org.matrix.msc4157.update_delayed_event", ]); - // As long as this resolves, we'll know that it didn't try to pop up a modal const approvedCapabilities = await driver.validateCapabilities(requestedCapabilities); expect(approvedCapabilities).toEqual(requestedCapabilities); });