FIX: Correctly render title-less poll widgets (#10837)

`RawHtml` does not like receiving undefined values as `html`.
This commit is contained in:
Jarek Radosz 2020-10-06 19:27:03 +02:00 committed by GitHub
parent f4c7c7bff3
commit 34c99da205
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -356,7 +356,9 @@ createWidget("discourse-poll-container", {
} else if (options) { } else if (options) {
const contents = []; const contents = [];
contents.push(new RawHtml({ html: attrs.titleHTML })); if (attrs.titleHTML) {
contents.push(new RawHtml({ html: attrs.titleHTML }));
}
if (!checkUserGroups(this.currentUser, poll)) { if (!checkUserGroups(this.currentUser, poll)) {
contents.push( contents.push(

View File

@ -1,6 +1,9 @@
import I18n from "I18n"; import I18n from "I18n";
import EmberObject from "@ember/object"; import EmberObject from "@ember/object";
import { moduleForWidget, widgetTest } from "discourse/tests/helpers/widget-test"; import {
moduleForWidget,
widgetTest,
} from "discourse/tests/helpers/widget-test";
moduleForWidget("discourse-poll"); moduleForWidget("discourse-poll");
@ -71,6 +74,14 @@ widgetTest("can vote", {
assert.equal(requests, 1); assert.equal(requests, 1);
assert.equal(find(".chosen").length, 1); assert.equal(find(".chosen").length, 1);
assert.equal(find(".chosen").text(), "100%yes"); assert.equal(find(".chosen").text(), "100%yes");
assert.equal(find(".toggle-results").text(), "Show vote");
await click(".toggle-results");
assert.equal(
find("li[data-poll-option-id='1f972d1df351de3ce35a787c89faad29']").length,
1
);
assert.equal(find(".toggle-results").text(), "Show results");
}, },
}); });