From f75915efa44c9810942dcf632b104c27ab348150 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 14 Jan 2019 13:00:27 -0500 Subject: [PATCH] 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 --- .eslintrc | 1 + .../discourse/routes/build-topic-route.js.es6 | 1 + .../templates/list/topic-list-item.raw.hbs | 2 +- .../acceptance/topic-discovery-test.js.es6 | 19 ++++++++++++++++++- .../fixtures/discovery_fixtures.js.es6 | 3 ++- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.eslintrc b/.eslintrc index 148fa3b11a3..0f2d2c87436 100644 --- a/.eslintrc +++ b/.eslintrc @@ -62,6 +62,7 @@ "triggerEvent": true, "visible": true, "visit": true, + "pauseTest": true }, "rules": { "block-scoped-var": 2, diff --git a/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 b/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 index 4bfb0ffeabf..72db37455bf 100644 --- a/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 +++ b/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 @@ -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 }; diff --git a/app/assets/javascripts/discourse/templates/list/topic-list-item.raw.hbs b/app/assets/javascripts/discourse/templates/list/topic-list-item.raw.hbs index 095518f07aa..5b45e1b45d9 100644 --- a/app/assets/javascripts/discourse/templates/list/topic-list-item.raw.hbs +++ b/app/assets/javascripts/discourse/templates/list/topic-list-item.raw.hbs @@ -68,4 +68,4 @@ {{number topic.views numberKey="views_long"}} -{{raw "list/activity-column" topic=topic class="num" tagName="td"}} \ No newline at end of file +{{raw "list/activity-column" topic=topic class="num" tagName="td"}} diff --git a/test/javascripts/acceptance/topic-discovery-test.js.es6 b/test/javascripts/acceptance/topic-discovery-test.js.es6 index 54e578b9a70..e060c94d66f 100644 --- a/test/javascripts/acceptance/topic-discovery-test.js.es6 +++ b/test/javascripts/acceptance/topic-discovery-test.js.es6 @@ -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" + ); +}); diff --git a/test/javascripts/fixtures/discovery_fixtures.js.es6 b/test/javascripts/fixtures/discovery_fixtures.js.es6 index 378a8b77307..1de2598980a 100644 --- a/test/javascripts/fixtures/discovery_fixtures.js.es6 +++ b/test/javascripts/fixtures/discovery_fixtures.js.es6 @@ -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,