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:
parent
11cc174d23
commit
ff15249f03
1 changed files with 5 additions and 1 deletions
|
@ -49,6 +49,7 @@ import { StopGapWidgetDriver } from "../../../src/stores/widgets/StopGapWidgetDr
|
||||||
import { stubClient } from "../../test-utils";
|
import { stubClient } from "../../test-utils";
|
||||||
import { ModuleRunner } from "../../../src/modules/ModuleRunner";
|
import { ModuleRunner } from "../../../src/modules/ModuleRunner";
|
||||||
import dis from "../../../src/dispatcher/dispatcher";
|
import dis from "../../../src/dispatcher/dispatcher";
|
||||||
|
import Modal from "../../../src/Modal";
|
||||||
import SettingsStore from "../../../src/settings/SettingsStore";
|
import SettingsStore from "../../../src/settings/SettingsStore";
|
||||||
|
|
||||||
describe("StopGapWidgetDriver", () => {
|
describe("StopGapWidgetDriver", () => {
|
||||||
|
@ -68,6 +69,10 @@ describe("StopGapWidgetDriver", () => {
|
||||||
"!1:example.org",
|
"!1:example.org",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
jest.spyOn(Modal, "createDialog").mockImplementation(() => {
|
||||||
|
throw new Error("Should not have to create a dialog");
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
stubClient();
|
stubClient();
|
||||||
client = mocked(MatrixClientPeg.safeGet());
|
client = mocked(MatrixClientPeg.safeGet());
|
||||||
|
@ -127,7 +132,6 @@ describe("StopGapWidgetDriver", () => {
|
||||||
"org.matrix.msc4157.update_delayed_event",
|
"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);
|
const approvedCapabilities = await driver.validateCapabilities(requestedCapabilities);
|
||||||
expect(approvedCapabilities).toEqual(requestedCapabilities);
|
expect(approvedCapabilities).toEqual(requestedCapabilities);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue