Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Make widget tests throw when a modal is shown (#12834)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AndrewFerr authored Aug 8, 2024
1 parent 11cc174 commit ff15249
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/stores/widgets/StopGapWidgetDriver-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand All @@ -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());
Expand Down Expand Up @@ -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);
});
Expand Down

0 comments on commit ff15249

Please sign in to comment.