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