mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Show footer at the end of topic list (#16519)
Previously it wouldn't show up after all items were loaded.
This commit is contained in:
parent
f3ef69e27d
commit
5d00f7bc0a
@ -36,11 +36,13 @@ const controllerOpts = {
|
|||||||
// We want them to bubble in DiscoveryTopicsController
|
// We want them to bubble in DiscoveryTopicsController
|
||||||
@action
|
@action
|
||||||
loadingBegan() {
|
loadingBegan() {
|
||||||
|
this.set("application.showFooter", false);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
@action
|
@action
|
||||||
loadingComplete() {
|
loadingComplete() {
|
||||||
|
this.set("application.showFooter", this.loadedAllItems);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ import TopicList from "discourse/models/topic-list";
|
|||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import { defaultHomepage } from "discourse/lib/utilities";
|
import { defaultHomepage } from "discourse/lib/utilities";
|
||||||
import { hash } from "rsvp";
|
import { hash } from "rsvp";
|
||||||
import { next } from "@ember/runloop";
|
|
||||||
import showModal from "discourse/lib/show-modal";
|
import showModal from "discourse/lib/show-modal";
|
||||||
import getURL from "discourse-common/lib/get-url";
|
import getURL from "discourse-common/lib/get-url";
|
||||||
import Session from "discourse/models/session";
|
import Session from "discourse/models/session";
|
||||||
@ -153,12 +152,6 @@ const DiscoveryCategoriesRoute = DiscourseRoute.extend(OpenComposer, {
|
|||||||
this.openComposer(this.controllerFor("discovery/categories"));
|
this.openComposer(this.controllerFor("discovery/categories"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@action
|
|
||||||
didTransition() {
|
|
||||||
next(() => this.controllerFor("application").set("showFooter", true));
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default DiscoveryCategoriesRoute;
|
export default DiscoveryCategoriesRoute;
|
||||||
|
@ -3,13 +3,16 @@ import {
|
|||||||
exists,
|
exists,
|
||||||
publishToMessageBus,
|
publishToMessageBus,
|
||||||
query,
|
query,
|
||||||
queryAll,
|
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
import DiscourseURL from "discourse/lib/url";
|
import DiscourseURL from "discourse/lib/url";
|
||||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||||
import sinon from "sinon";
|
import sinon from "sinon";
|
||||||
import { test } from "qunit";
|
import { skip, test } from "qunit";
|
||||||
import { click, currentURL, visit } from "@ember/test-helpers";
|
import { click, currentURL, settled, visit } from "@ember/test-helpers";
|
||||||
|
import { cloneJSON } from "discourse-common/lib/object";
|
||||||
|
import discoveryFixtures from "discourse/tests/fixtures/discovery-fixtures";
|
||||||
|
import { ScrollingDOMMethods } from "discourse/mixins/scrolling";
|
||||||
|
import { configureEyeline } from "discourse/lib/eyeline";
|
||||||
|
|
||||||
acceptance("Topic Discovery", function (needs) {
|
acceptance("Topic Discovery", function (needs) {
|
||||||
needs.settings({
|
needs.settings({
|
||||||
@ -18,18 +21,21 @@ acceptance("Topic Discovery", function (needs) {
|
|||||||
|
|
||||||
test("Visit Discovery Pages", async function (assert) {
|
test("Visit Discovery Pages", async function (assert) {
|
||||||
await visit("/");
|
await visit("/");
|
||||||
assert.ok($("body.navigation-topics").length, "has the default navigation");
|
assert.ok(
|
||||||
|
document.querySelectorAll("body.navigation-topics").length,
|
||||||
|
"has the default navigation"
|
||||||
|
);
|
||||||
assert.ok(exists(".topic-list"), "The list of topics was rendered");
|
assert.ok(exists(".topic-list"), "The list of topics was rendered");
|
||||||
assert.ok(exists(".topic-list .topic-list-item"), "has topics");
|
assert.ok(exists(".topic-list .topic-list-item"), "has topics");
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
queryAll("a[data-user-card=eviltrout] img.avatar").attr("title"),
|
query("a[data-user-card=eviltrout] img.avatar").getAttribute("title"),
|
||||||
"Evil Trout - Most Posts",
|
"Evil Trout - Most Posts",
|
||||||
"it shows user's full name in avatar title"
|
"it shows user's full name in avatar title"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
queryAll("a[data-user-card=eviltrout] img.avatar").attr("loading"),
|
query("a[data-user-card=eviltrout] img.avatar").getAttribute("loading"),
|
||||||
"lazy",
|
"lazy",
|
||||||
"it adds loading=`lazy` to topic list avatars"
|
"it adds loading=`lazy` to topic list avatars"
|
||||||
);
|
);
|
||||||
@ -39,25 +45,28 @@ acceptance("Topic Discovery", function (needs) {
|
|||||||
assert.ok(exists(".topic-list .topic-list-item"), "has topics");
|
assert.ok(exists(".topic-list .topic-list-item"), "has topics");
|
||||||
assert.ok(!exists(".category-list"), "doesn't render subcategories");
|
assert.ok(!exists(".category-list"), "doesn't render subcategories");
|
||||||
assert.ok(
|
assert.ok(
|
||||||
$("body.category-bug").length,
|
document.querySelectorAll("body.category-bug").length,
|
||||||
"has a custom css class for the category id on the body"
|
"has a custom css class for the category id on the body"
|
||||||
);
|
);
|
||||||
|
|
||||||
await visit("/categories");
|
await visit("/categories");
|
||||||
assert.ok($("body.navigation-categories").length, "has the body class");
|
|
||||||
assert.ok(
|
assert.ok(
|
||||||
$("body.category-bug").length === 0,
|
document.querySelectorAll("body.navigation-categories").length,
|
||||||
|
"has the body class"
|
||||||
|
);
|
||||||
|
assert.ok(
|
||||||
|
document.querySelectorAll("body.category-bug").length === 0,
|
||||||
"removes the custom category class"
|
"removes the custom category class"
|
||||||
);
|
);
|
||||||
assert.ok(exists(".category"), "has a list of categories");
|
assert.ok(exists(".category"), "has a list of categories");
|
||||||
assert.ok(
|
assert.ok(
|
||||||
$("body.categories-list").length,
|
document.querySelectorAll("body.categories-list").length,
|
||||||
"has a custom class to indicate categories"
|
"has a custom class to indicate categories"
|
||||||
);
|
);
|
||||||
|
|
||||||
await visit("/top");
|
await visit("/top");
|
||||||
assert.ok(
|
assert.ok(
|
||||||
$("body.categories-list").length === 0,
|
document.querySelectorAll("body.categories-list").length === 0,
|
||||||
"removes the `categories-list` class"
|
"removes the `categories-list` class"
|
||||||
);
|
);
|
||||||
assert.ok(exists(".topic-list .topic-list-item"), "has topics");
|
assert.ok(exists(".topic-list .topic-list-item"), "has topics");
|
||||||
@ -179,3 +188,41 @@ acceptance("Topic Discovery", function (needs) {
|
|||||||
assertShowingLatest();
|
assertShowingLatest();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
acceptance("Topic Discovery | Footer", function (needs) {
|
||||||
|
needs.hooks.beforeEach(function () {
|
||||||
|
ScrollingDOMMethods.bindOnScroll.restore();
|
||||||
|
configureEyeline({
|
||||||
|
skipUpdate: false,
|
||||||
|
rootElement: "#ember-testing",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
needs.hooks.afterEach(function () {
|
||||||
|
configureEyeline();
|
||||||
|
});
|
||||||
|
|
||||||
|
needs.pretender((server, helper) => {
|
||||||
|
server.get("/c/dev/7/l/latest.json", () => {
|
||||||
|
const json = cloneJSON(discoveryFixtures["/c/dev/7/l/latest.json"]);
|
||||||
|
json.topic_list.more_topics_url = "/c/dev/7/l/latest.json?page=2";
|
||||||
|
return helper.response(json);
|
||||||
|
});
|
||||||
|
|
||||||
|
server.get("/c/dev/7/l/latest.json?page=2", () => {
|
||||||
|
const json = cloneJSON(discoveryFixtures["/c/dev/7/l/latest.json"]);
|
||||||
|
json.topic_list.more_topics_url = null;
|
||||||
|
return helper.response(json);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO: Needs scroll support in tests
|
||||||
|
skip("No footer, then shows footer when all loaded", async function (assert) {
|
||||||
|
await visit("/c/dev");
|
||||||
|
assert.ok(!exists(".custom-footer-content"));
|
||||||
|
|
||||||
|
document.querySelector("#ember-testing-container").scrollTop = 100000; // scroll to bottom
|
||||||
|
await settled();
|
||||||
|
assert.ok(exists(".custom-footer-content"));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user