mirror of
https://github.com/discourse/discourse.git
synced 2026-08-06 00:15:24 +08:00
This fixes topic voting to make sure the UI shows by the topic title when the topic is loaded in nested mode. Also fixes a weird header-registeration bug so that on scroll the topic title goes in the header after nested replies is disabled for a topic.
75 lines
2 KiB
Text
Vendored
75 lines
2 KiB
Text
Vendored
import { render } from "@ember/test-helpers";
|
|
import { module, test } from "qunit";
|
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
|
import TopicTitleVoting from "discourse/plugins/discourse-topic-voting/discourse/connectors/topic-title/topic-title-voting";
|
|
|
|
function buildTopic(overrides = {}) {
|
|
return {
|
|
id: 1,
|
|
can_vote: true,
|
|
closed: false,
|
|
is_nested_view: false,
|
|
postStream: {
|
|
firstPostPresent: false,
|
|
loaded: false,
|
|
},
|
|
user_voted: false,
|
|
vote_count: 0,
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
module("Integration | Connector | TopicTitleVoting", function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
hooks.beforeEach(function () {
|
|
this.siteSettings.topic_voting_show_who_voted = false;
|
|
});
|
|
|
|
test("renders after the first post is present in the flat topic stream", async function (assert) {
|
|
this.outletArgs = {
|
|
model: buildTopic({
|
|
postStream: {
|
|
firstPostPresent: true,
|
|
loaded: true,
|
|
},
|
|
}),
|
|
};
|
|
|
|
await render(
|
|
<template><TopicTitleVoting @outletArgs={{this.outletArgs}} /></template>
|
|
);
|
|
|
|
assert
|
|
.dom(".title-voting .voting-wrapper")
|
|
.exists("the vote box renders in the topic title");
|
|
});
|
|
|
|
test("does not render before the first post is present in the flat topic stream", async function (assert) {
|
|
this.outletArgs = {
|
|
model: buildTopic(),
|
|
};
|
|
|
|
await render(
|
|
<template><TopicTitleVoting @outletArgs={{this.outletArgs}} /></template>
|
|
);
|
|
|
|
assert
|
|
.dom(".title-voting .voting-wrapper")
|
|
.doesNotExist("the flat topic guard is preserved");
|
|
});
|
|
|
|
test("renders for nested topics before the flat topic stream is loaded", async function (assert) {
|
|
this.outletArgs = {
|
|
model: buildTopic({ is_nested_view: true }),
|
|
};
|
|
|
|
await render(
|
|
<template><TopicTitleVoting @outletArgs={{this.outletArgs}} /></template>
|
|
);
|
|
|
|
assert
|
|
.dom(".title-voting .voting-wrapper")
|
|
.exists("nested topics can render the vote box from topic metadata");
|
|
});
|
|
});
|