2015-04-06 14:14:00 -04:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
2018-06-15 11:03:24 -04:00
|
|
|
import showModal from "discourse/lib/show-modal";
|
2018-06-04 21:34:41 -04:00
|
|
|
|
2015-04-06 14:14:00 -04:00
|
|
|
acceptance("Modal");
|
2014-09-08 16:52:49 -04:00
|
|
|
|
2018-07-19 06:12:00 -04:00
|
|
|
QUnit.test("modal", async assert => {
|
|
|
|
await visit("/");
|
2014-09-08 16:52:49 -04:00
|
|
|
|
2018-07-19 06:12:00 -04:00
|
|
|
assert.ok(
|
|
|
|
find(".d-modal:visible").length === 0,
|
|
|
|
"there is no modal at first"
|
|
|
|
);
|
2014-09-08 16:52:49 -04:00
|
|
|
|
2018-07-19 06:12:00 -04:00
|
|
|
await click(".login-button");
|
|
|
|
assert.ok(find(".d-modal:visible").length === 1, "modal should appear");
|
2014-09-08 16:52:49 -04:00
|
|
|
|
2018-07-19 06:12:00 -04:00
|
|
|
await click(".modal-outer-container");
|
|
|
|
assert.ok(
|
|
|
|
find(".d-modal:visible").length === 0,
|
|
|
|
"modal should disappear when you click outside"
|
|
|
|
);
|
2014-09-08 16:52:49 -04:00
|
|
|
|
2018-07-19 06:12:00 -04:00
|
|
|
await click(".login-button");
|
|
|
|
assert.ok(find(".d-modal:visible").length === 1, "modal should reappear");
|
2014-09-08 16:52:49 -04:00
|
|
|
|
2018-07-19 06:12:00 -04:00
|
|
|
await keyEvent("#main-outlet", "keydown", 27);
|
|
|
|
assert.ok(
|
|
|
|
find(".d-modal:visible").length === 0,
|
|
|
|
"ESC should close the modal"
|
|
|
|
);
|
|
|
|
|
|
|
|
Ember.TEMPLATES["modal/not-dismissable"] = Ember.HTMLBars.compile(
|
|
|
|
'{{#d-modal-body title="" class="" dismissable=false}}test{{/d-modal-body}}'
|
|
|
|
);
|
|
|
|
|
|
|
|
Ember.run(() => showModal("not-dismissable", {}));
|
|
|
|
|
|
|
|
assert.ok(find(".d-modal:visible").length === 1, "modal should appear");
|
|
|
|
|
|
|
|
await click(".modal-outer-container");
|
|
|
|
assert.ok(
|
|
|
|
find(".d-modal:visible").length === 1,
|
|
|
|
"modal should not disappear when you click outside"
|
|
|
|
);
|
|
|
|
await keyEvent("#main-outlet", "keydown", 27);
|
|
|
|
assert.ok(
|
|
|
|
find(".d-modal:visible").length === 1,
|
|
|
|
"ESC should not close the modal"
|
|
|
|
);
|
2017-08-30 15:29:51 -04:00
|
|
|
});
|