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.
This commit is contained in:
Andrew Ferrazzutti 2024-08-08 07:45:20 -04:00 committed by GitHub
parent 11cc174d23
commit ff15249f03
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);
});