mirror of
https://github.com/discourse/discourse.git
synced 2025-09-08 12:06:51 +08:00
Convert Discourse.Post
to ES6 and use Store model
- Includes acceptance tests for composer (post, edit) - Supports acceptance testing of bootbox
This commit is contained in:
parent
19a9a8b408
commit
22ffcba8e6
19 changed files with 747 additions and 440 deletions
|
@ -1,20 +1,59 @@
|
|||
/* global asyncTest */
|
||||
|
||||
import sessionFixtures from 'fixtures/session-fixtures';
|
||||
import siteFixtures from 'fixtures/site_fixtures';
|
||||
import HeaderView from 'discourse/views/header';
|
||||
|
||||
function currentUser() {
|
||||
return Discourse.User.create(sessionFixtures['/session/current.json'].current_user);
|
||||
}
|
||||
|
||||
function logIn() {
|
||||
Discourse.User.resetCurrent(currentUser());
|
||||
}
|
||||
|
||||
const Plugin = $.fn.modal;
|
||||
const Modal = Plugin.Constructor;
|
||||
|
||||
function AcceptanceModal(option, _relatedTarget) {
|
||||
return this.each(function () {
|
||||
var $this = $(this);
|
||||
var data = $this.data('bs.modal');
|
||||
var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option === 'object' && option);
|
||||
|
||||
if (!data) $this.data('bs.modal', (data = new Modal(this, options)));
|
||||
data.$body = $('#ember-testing');
|
||||
|
||||
if (typeof option === 'string') data[option](_relatedTarget);
|
||||
else if (options.show) data.show(_relatedTarget);
|
||||
});
|
||||
}
|
||||
|
||||
window.bootbox.$body = $('#ember-testing');
|
||||
$.fn.modal = AcceptanceModal;
|
||||
|
||||
var oldAvatar = Discourse.Utilities.avatarImg;
|
||||
|
||||
function acceptance(name, options) {
|
||||
module("Acceptance: " + name, {
|
||||
setup: function() {
|
||||
Ember.run(Discourse, Discourse.advanceReadiness);
|
||||
|
||||
// Don't render avatars in acceptance tests, it's faster and no 404s
|
||||
Discourse.Utilities.avatarImg = () => "";
|
||||
|
||||
// For now don't do scrolling stuff in Test Mode
|
||||
Ember.CloakedCollectionView.scrolled = Ember.K;
|
||||
HeaderView.reopen({examineDockHeader: Ember.K});
|
||||
|
||||
var siteJson = siteFixtures['site.json'].site;
|
||||
if (options) {
|
||||
if (options.setup) {
|
||||
options.setup.call(this);
|
||||
}
|
||||
|
||||
if (options.user) {
|
||||
Discourse.User.resetCurrent(Discourse.User.create(options.user));
|
||||
if (options.loggedIn) {
|
||||
logIn();
|
||||
}
|
||||
|
||||
if (options.settings) {
|
||||
|
@ -34,6 +73,7 @@ function acceptance(name, options) {
|
|||
options.teardown.call(this);
|
||||
}
|
||||
|
||||
Discourse.Utilities.avatarImg = oldAvatar;
|
||||
Discourse.reset();
|
||||
}
|
||||
});
|
||||
|
@ -61,4 +101,4 @@ function fixture(selector) {
|
|||
return $("#qunit-fixture");
|
||||
}
|
||||
|
||||
export { acceptance, controllerFor, asyncTestDiscourse, fixture };
|
||||
export { acceptance, controllerFor, asyncTestDiscourse, fixture, logIn, currentUser };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue