FIX: ensures pinned-options header is showing correct state (#9156)
This commit is contained in:
@@ -2,12 +2,12 @@ import selectKit from "helpers/select-kit-helper";
|
||||
import componentTest from "helpers/component-test";
|
||||
import Topic from "discourse/models/topic";
|
||||
|
||||
const buildTopic = function() {
|
||||
const buildTopic = function(pinned = true) {
|
||||
return Topic.create({
|
||||
id: 1234,
|
||||
title: "Qunit Test Topic",
|
||||
deleted: false,
|
||||
pinned: true
|
||||
pinned
|
||||
});
|
||||
};
|
||||
|
||||
@@ -18,21 +18,38 @@ moduleForComponent("select-kit/pinned-options", {
|
||||
}
|
||||
});
|
||||
|
||||
componentTest("updating the content refreshes the list", {
|
||||
template: "{{pinned-options value=pinned topic=topic}}",
|
||||
componentTest("unpinning", {
|
||||
template: "{{pinned-options value=topic.pinned topic=topic}}",
|
||||
|
||||
beforeEach() {
|
||||
this.siteSettings.automatically_unpin_topics = false;
|
||||
this.set("topic", buildTopic());
|
||||
this.set("pinned", "pinned");
|
||||
},
|
||||
|
||||
async test(assert) {
|
||||
assert.equal(this.subject.header().name(), "pinned");
|
||||
|
||||
// we do it manually as clearPin is an ajax call
|
||||
await this.set("pinned", false);
|
||||
await this.subject.expand();
|
||||
await this.subject.selectRowByValue("unpinned");
|
||||
|
||||
assert.equal(this.subject.header().name(), "unpinned");
|
||||
}
|
||||
});
|
||||
|
||||
componentTest("pinning", {
|
||||
template: "{{pinned-options value=topic.pinned topic=topic}}",
|
||||
|
||||
beforeEach() {
|
||||
this.siteSettings.automatically_unpin_topics = false;
|
||||
this.set("topic", buildTopic(false));
|
||||
},
|
||||
|
||||
async test(assert) {
|
||||
assert.equal(this.subject.header().name(), "unpinned");
|
||||
|
||||
await this.subject.expand();
|
||||
await this.subject.selectRowByValue("pinned");
|
||||
|
||||
assert.equal(this.subject.header().name(), "pinned");
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user