FIX: Updating the category was not updating the UI
This commit is contained in:
parent
b1da9ac875
commit
e912b698ac
|
@ -35,6 +35,7 @@
|
||||||
"exists",
|
"exists",
|
||||||
"visible",
|
"visible",
|
||||||
"invisible",
|
"invisible",
|
||||||
|
"selectDropdown",
|
||||||
"asyncTestDiscourse",
|
"asyncTestDiscourse",
|
||||||
"fixture",
|
"fixture",
|
||||||
"find",
|
"find",
|
||||||
|
|
|
@ -40,18 +40,18 @@ const Topic = RestModel.extend({
|
||||||
return ({ type: 'topic', id: this.get('id') });
|
return ({ type: 'topic', id: this.get('id') });
|
||||||
}.property('id'),
|
}.property('id'),
|
||||||
|
|
||||||
category: function() {
|
_categoryIdChanged: function() {
|
||||||
const categoryId = this.get('category_id');
|
this.set('category', Discourse.Category.findById(this.get('category_id')));
|
||||||
if (categoryId) {
|
}.observes('category_id').on('init'),
|
||||||
return Discourse.Category.list().findProperty('id', categoryId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
_categoryNameChanged: function() {
|
||||||
const categoryName = this.get('categoryName');
|
const categoryName = this.get('categoryName');
|
||||||
|
let category;
|
||||||
if (categoryName) {
|
if (categoryName) {
|
||||||
return Discourse.Category.list().findProperty('name', categoryName);
|
category = Discourse.Category.list().findProperty('name', categoryName);
|
||||||
}
|
}
|
||||||
return null;
|
this.set('category', category);
|
||||||
}.property('category_id', 'categoryName'),
|
}.observes('categoryName'),
|
||||||
|
|
||||||
categoryClass: function() {
|
categoryClass: function() {
|
||||||
return 'category-' + this.get('category.fullSlug');
|
return 'category-' + this.get('category.fullSlug');
|
||||||
|
@ -407,7 +407,6 @@ Topic.reopenClass({
|
||||||
// The title can be cleaned up server side
|
// The title can be cleaned up server side
|
||||||
props.title = result.basic_topic.title;
|
props.title = result.basic_topic.title;
|
||||||
props.fancy_title = result.basic_topic.fancy_title;
|
props.fancy_title = result.basic_topic.fancy_title;
|
||||||
|
|
||||||
topic.setProperties(props);
|
topic.setProperties(props);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
|
|
||||||
{{plugin-outlet "edit-topic"}}
|
{{plugin-outlet "edit-topic"}}
|
||||||
|
|
||||||
{{d-button action="finishedEditingTopic" class="btn-primary btn-small no-text" icon="check"}}
|
{{d-button action="finishedEditingTopic" class="btn-primary btn-small no-text submit-edit" icon="check"}}
|
||||||
{{d-button action="cancelEditingTopic" class="btn-small no-text" icon="times"}}
|
{{d-button action="cancelEditingTopic" class="btn-small no-text cancel-edit" icon="times"}}
|
||||||
{{else}}
|
{{else}}
|
||||||
<h1>
|
<h1>
|
||||||
{{#unless is_warning}}
|
{{#unless is_warning}}
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
{{#if details.loaded}}
|
{{#if details.loaded}}
|
||||||
{{topic-status topic=model}}
|
{{topic-status topic=model}}
|
||||||
<a href='{{unbound url}}' {{action "jumpTop"}}>
|
<a href='{{unbound url}}' {{action "jumpTop"}} class='fancy-title'>
|
||||||
{{{fancy_title}}}
|
{{{fancy_title}}}
|
||||||
</a>
|
</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { acceptance } from "helpers/qunit-helpers";
|
||||||
|
acceptance("Topic - Anonymous");
|
||||||
|
|
||||||
|
test("Enter a Topic", () => {
|
||||||
|
visit("/t/internationalization-localization/280/1");
|
||||||
|
andThen(() => {
|
||||||
|
ok(exists("#topic"), "The topic was rendered");
|
||||||
|
ok(exists("#topic .cooked"), "The topic has cooked posts");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Enter without an id", () => {
|
||||||
|
visit("/t/internationalization-localization");
|
||||||
|
andThen(() => {
|
||||||
|
ok(exists("#topic"), "The topic was rendered");
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,17 +1,33 @@
|
||||||
import { acceptance } from "helpers/qunit-helpers";
|
import { acceptance } from "helpers/qunit-helpers";
|
||||||
acceptance("View Topic");
|
acceptance("Topic", { loggedIn: true });
|
||||||
|
|
||||||
|
test("Showing and hiding the edit controls", () => {
|
||||||
|
visit("/t/internationalization-localization/280");
|
||||||
|
|
||||||
|
click('#topic-title .fa-pencil');
|
||||||
|
|
||||||
test("Enter a Topic", () => {
|
|
||||||
visit("/t/internationalization-localization/280/1");
|
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
ok(exists("#topic"), "The topic was rendered");
|
ok(exists('#edit-title'), 'it shows the editing controls');
|
||||||
ok(exists("#topic .cooked"), "The topic has cooked posts");
|
});
|
||||||
|
|
||||||
|
fillIn('#edit-title', 'this is the new title');
|
||||||
|
click('#topic-title .cancel-edit');
|
||||||
|
andThen(() => {
|
||||||
|
ok(!exists('#edit-title'), 'it hides the editing controls');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Enter without an id", () => {
|
test("Updating the topic title and category", () => {
|
||||||
visit("/t/internationalization-localization");
|
visit("/t/internationalization-localization/280");
|
||||||
|
click('#topic-title .fa-pencil');
|
||||||
|
|
||||||
|
fillIn('#edit-title', 'this is the new title');
|
||||||
|
selectDropdown('.category-combobox', 4);
|
||||||
|
|
||||||
|
click('#topic-title .submit-edit');
|
||||||
|
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
ok(exists("#topic"), "The topic was rendered");
|
equal(find('#topic-title .badge-category').text(), 'faq', 'it displays the new category');
|
||||||
|
equal(find('.fancy-title').text().trim(), 'this is the new title', 'it displays the new title');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -28,6 +28,12 @@ function visible(selector) {
|
||||||
return find(selector + ":visible").length > 0;
|
return find(selector + ":visible").length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ember.Test.registerAsyncHelper('selectDropdown', function(app, selector, itemId) {
|
||||||
|
var $select2 = find(selector);
|
||||||
|
$select2.select2('val', itemId.toString());
|
||||||
|
$select2.trigger("change");
|
||||||
|
});
|
||||||
|
|
||||||
function invisible(selector) {
|
function invisible(selector) {
|
||||||
var $items = find(selector + ":visible");
|
var $items = find(selector + ":visible");
|
||||||
return $items.length === 0 ||
|
return $items.length === 0 ||
|
||||||
|
|
Loading…
Reference in New Issue