2018-06-15 23:03:24 +08:00
|
|
|
import AppEvents from "discourse/lib/app-events";
|
|
|
|
import createStore from "helpers/create-store";
|
|
|
|
import { autoLoadModules } from "discourse/initializers/auto-load-modules";
|
|
|
|
import TopicTrackingState from "discourse/models/topic-tracking-state";
|
2015-07-15 01:56:59 +08:00
|
|
|
|
|
|
|
export default function(name, opts) {
|
|
|
|
opts = opts || {};
|
|
|
|
|
2019-05-17 02:33:27 +08:00
|
|
|
if (opts.skip) {
|
|
|
|
return;
|
2019-05-17 02:15:37 +08:00
|
|
|
}
|
|
|
|
|
2015-07-15 01:56:59 +08:00
|
|
|
test(name, function(assert) {
|
2015-08-27 03:51:56 +08:00
|
|
|
const appEvents = AppEvents.create();
|
2016-03-22 02:16:05 +08:00
|
|
|
this.site = Discourse.Site.current();
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
this.registry.register("site-settings:main", Discourse.SiteSettings, {
|
|
|
|
instantiate: false
|
|
|
|
});
|
|
|
|
this.registry.register("app-events:main", appEvents, {
|
|
|
|
instantiate: false
|
|
|
|
});
|
|
|
|
this.registry.register("capabilities:main", Ember.Object);
|
|
|
|
this.registry.register("site:main", this.site, { instantiate: false });
|
|
|
|
this.registry.injection("component", "siteSettings", "site-settings:main");
|
|
|
|
this.registry.injection("component", "appEvents", "app-events:main");
|
|
|
|
this.registry.injection("component", "capabilities", "capabilities:main");
|
|
|
|
this.registry.injection("component", "site", "site:main");
|
2015-07-15 01:56:59 +08:00
|
|
|
|
2016-01-05 04:18:09 +08:00
|
|
|
this.siteSettings = Discourse.SiteSettings;
|
|
|
|
|
2016-11-08 04:11:56 +08:00
|
|
|
autoLoadModules(this.registry, this.registry);
|
2016-01-05 04:18:09 +08:00
|
|
|
|
2016-04-15 03:23:05 +08:00
|
|
|
const store = createStore();
|
|
|
|
if (!opts.anonymous) {
|
2018-06-15 23:03:24 +08:00
|
|
|
const currentUser = Discourse.User.create({ username: "eviltrout" });
|
2016-04-15 03:23:05 +08:00
|
|
|
this.currentUser = currentUser;
|
2018-06-15 23:03:24 +08:00
|
|
|
this.registry.register("current-user:main", this.currentUser, {
|
|
|
|
instantiate: false
|
|
|
|
});
|
|
|
|
this.registry.register(
|
|
|
|
"topic-tracking-state:main",
|
|
|
|
TopicTrackingState.create({ currentUser }),
|
|
|
|
{ instantiate: false }
|
|
|
|
);
|
2016-04-15 03:23:05 +08:00
|
|
|
}
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
this.registry.register("service:store", store, { instantiate: false });
|
2016-04-15 03:23:05 +08:00
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
if (opts.beforeEach) {
|
|
|
|
opts.beforeEach.call(this, store);
|
2016-01-05 04:18:09 +08:00
|
|
|
}
|
|
|
|
|
2016-11-09 02:40:35 +08:00
|
|
|
andThen(() => {
|
|
|
|
return this.render(opts.template);
|
|
|
|
});
|
2019-05-01 02:01:21 +08:00
|
|
|
andThen(() => {
|
2019-05-17 02:15:37 +08:00
|
|
|
opts.test.call(this, assert);
|
2019-05-01 02:01:21 +08:00
|
|
|
});
|
2015-07-15 01:56:59 +08:00
|
|
|
});
|
|
|
|
}
|