mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
Plugin Outlets need their arguments to be explicit
This commit is contained in:
@ -0,0 +1,47 @@
|
||||
import { acceptance } from "helpers/qunit-helpers";
|
||||
import { extraConnectorClass } from 'discourse/lib/plugin-connectors';
|
||||
|
||||
const PREFIX = "javascripts/single-test/connectors";
|
||||
acceptance("Plugin Outlet - Connector Class", {
|
||||
setup() {
|
||||
extraConnectorClass('user-profile-primary/hello', {
|
||||
actions: {
|
||||
sayHello() {
|
||||
this.set('hello', 'hello!');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
extraConnectorClass('user-profile-primary/dont-render', {
|
||||
shouldRender(args) {
|
||||
return args.model.get('username') !== 'eviltrout';
|
||||
}
|
||||
});
|
||||
|
||||
Ember.TEMPLATES[`${PREFIX}/user-profile-primary/hello`] = Ember.HTMLBars.compile(
|
||||
`<span class='hello-username'>{{model.username}}</span>
|
||||
<button class='say-hello' {{action "sayHello"}}></button>
|
||||
<span class='hello-result'>{{hello}}</span>`
|
||||
);
|
||||
Ember.TEMPLATES[`${PREFIX}/user-profile-primary/dont-render`] = Ember.HTMLBars.compile(
|
||||
`I'm not rendered!`
|
||||
);
|
||||
},
|
||||
|
||||
teardown() {
|
||||
delete Ember.TEMPLATES[`${PREFIX}/user-profile-primary/hello`];
|
||||
delete Ember.TEMPLATES[`${PREFIX}/user-profile-primary/dont-render`];
|
||||
}
|
||||
});
|
||||
|
||||
test("Renders a template into the outlet", assert => {
|
||||
visit("/users/eviltrout");
|
||||
andThen(() => {
|
||||
assert.ok(find('.user-profile-primary-outlet.hello').length === 1, 'it has class names');
|
||||
assert.ok(!find('.user-profile-primary-outlet.dont-render').length, "doesn't render");
|
||||
});
|
||||
click('.say-hello');
|
||||
andThen(() => {
|
||||
assert.equal(find('.hello-result').text(), 'hello!', 'actions delegate properly');
|
||||
});
|
||||
});
|
@ -1,5 +1,5 @@
|
||||
import { acceptance } from "helpers/qunit-helpers";
|
||||
import { clearCache } from 'discourse/helpers/plugin-outlet';
|
||||
import { clearCache } from 'discourse/lib/plugin-connectors';
|
||||
|
||||
const HELLO = 'javascripts/multi-test/connectors/user-profile-primary/hello';
|
||||
const GOODBYE = 'javascripts/multi-test/connectors/user-profile-primary/goodbye';
|
||||
|
@ -4,9 +4,7 @@ const CONNECTOR = 'javascripts/single-test/connectors/user-profile-primary/hello
|
||||
acceptance("Plugin Outlet - Single Template", {
|
||||
setup() {
|
||||
Ember.TEMPLATES[CONNECTOR] = Ember.HTMLBars.compile(
|
||||
`<span class='hello-username'>{{model.username}}</span>
|
||||
<button class='hello-check-email' {{action "checkEmail" model}}></button>
|
||||
<span class='hello-email'>{{model.email}}</span>`
|
||||
`<span class='hello-username'>{{model.username}}</span>`
|
||||
);
|
||||
},
|
||||
|
||||
@ -21,8 +19,4 @@ test("Renders a template into the outlet", assert => {
|
||||
assert.ok(find('.user-profile-primary-outlet.hello').length === 1, 'it has class names');
|
||||
assert.equal(find('.hello-username').text(), 'eviltrout', 'it renders into the outlet');
|
||||
});
|
||||
click('.hello-check-email');
|
||||
andThen(() => {
|
||||
assert.equal(find('.hello-email').text(), 'eviltrout@example.com', 'actions delegate properly');
|
||||
});
|
||||
});
|
||||
|
@ -5,9 +5,10 @@ import siteFixtures from 'fixtures/site-fixtures';
|
||||
import HeaderComponent from 'discourse/components/site-header';
|
||||
import { forceMobile, resetMobile } from 'discourse/lib/mobile';
|
||||
import { resetPluginApi } from 'discourse/lib/plugin-api';
|
||||
import { clearCache as clearOutletCache } from 'discourse/helpers/plugin-outlet';
|
||||
import { clearCache as clearOutletCache, resetExtraClasses } from 'discourse/lib/plugin-connectors';
|
||||
import { clearHTMLCache } from 'discourse/helpers/custom-html';
|
||||
|
||||
|
||||
function currentUser() {
|
||||
return Discourse.User.create(sessionFixtures['/session/current.json'].current_user);
|
||||
}
|
||||
@ -44,6 +45,7 @@ function acceptance(name, options) {
|
||||
// For now don't do scrolling stuff in Test Mode
|
||||
HeaderComponent.reopen({examineDockHeader: Ember.K});
|
||||
|
||||
resetExtraClasses();
|
||||
const siteJson = siteFixtures['site.json'].site;
|
||||
if (options) {
|
||||
if (options.setup) {
|
||||
@ -80,6 +82,7 @@ function acceptance(name, options) {
|
||||
Discourse.User.resetCurrent();
|
||||
Discourse.Site.resetCurrent(Discourse.Site.create(jQuery.extend(true, {}, fixtures['site.json'].site)));
|
||||
|
||||
resetExtraClasses();
|
||||
clearOutletCache();
|
||||
clearHTMLCache();
|
||||
resetPluginApi();
|
||||
|
Reference in New Issue
Block a user