FIX: `expandAllPinned` was not resetting after visiting a category

This resulted in a bug where if you saw a pinned topic in a category,
then went back to latest, the same topic would show an excerpt even
though it shouldn't on the latest view.

See:
https://meta.discourse.org/t/pinned-post-excerpt-no-longer-appears-after-refreshing-the-page/106222
This commit is contained in:
Robin Ward 2019-01-14 13:00:27 -05:00
parent c8c84f462b
commit f75915efa4
5 changed files with 23 additions and 3 deletions

View File

@ -62,6 +62,7 @@
"triggerEvent": true,
"visible": true,
"visit": true,
"pauseTest": true
},
"rules": {
"block-scoped-var": 2,

View File

@ -113,6 +113,7 @@ export default function(filter, extras) {
model.get("for_period") ||
(filter.indexOf("top/") >= 0 ? filter.split("/")[1] : ""),
selected: [],
expandAllPinned: false,
expandGloballyPinned: true
};

View File

@ -68,4 +68,4 @@
<td class="num views {{topic.viewsHeat}}">{{number topic.views numberKey="views_long"}}</td>
{{raw "list/activity-column" topic=topic class="num" tagName="td"}}
{{raw "list/activity-column" topic=topic class="num" tagName="td"}}

View File

@ -1,5 +1,9 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Topic Discovery");
acceptance("Topic Discovery", {
settings: {
show_pinned_excerpt_desktop: true
}
});
QUnit.test("Visit Discovery Pages", async assert => {
await visit("/");
@ -59,3 +63,16 @@ QUnit.test("Visit Discovery Pages", async assert => {
"The featured topics are there too"
);
});
QUnit.test("Clearing state after leaving a category", async assert => {
await visit("/c/dev");
assert.ok(
exists(".topic-list-item[data-topic-id=11994] .topic-excerpt"),
"it expands pinned topics in a subcategory"
);
await visit("/");
assert.ok(
!exists(".topic-list-item[data-topic-id=11557] .topic-excerpt"),
"it doesn't expand all pinned in the latest category"
);
});

View File

@ -4962,7 +4962,8 @@ export default {
bumped: true,
bumped_at: "2014-01-16T11:04:32.000-05:00",
unseen: false,
pinned: false,
pinned: true,
excerpt: "Hello world",
visible: true,
closed: false,
archived: false,