FIX: banners not removing when unset (#22678)
Initializing an EmberObject with a null object leads to an exception. This commit stops that from happening, and introduces an acceptance test for adding/removing banner topics via message-bus. Co-authored-by: David Taylor <david@taylorhq.com>
This commit is contained in:
parent
125903f682
commit
e5bb4bbd59
|
@ -20,7 +20,11 @@ export default {
|
|||
},
|
||||
|
||||
@bind
|
||||
onMessage(data = {}) {
|
||||
this.site.set("banner", EmberObject.create(data));
|
||||
onMessage(data) {
|
||||
if (data) {
|
||||
this.site.set("banner", EmberObject.create(data));
|
||||
} else {
|
||||
this.site.set("banner", null);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
import {
|
||||
acceptance,
|
||||
publishToMessageBus,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { test } from "qunit";
|
||||
import { visit } from "@ember/test-helpers";
|
||||
|
||||
acceptance("Site Banner", function () {
|
||||
test("shows and hides correctly", async function (assert) {
|
||||
await visit("/");
|
||||
|
||||
assert.dom("#banner").doesNotExist();
|
||||
|
||||
await publishToMessageBus("/site/banner", {
|
||||
html: "hello world",
|
||||
key: 12,
|
||||
url: "/t/12",
|
||||
});
|
||||
|
||||
assert.dom("#banner #banner-content").hasText("hello world");
|
||||
|
||||
await publishToMessageBus("/site/banner", null);
|
||||
|
||||
assert.dom("#banner").doesNotExist();
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue