DEV: Do not skip pages when loading polls (#13649)

In some conditions, pages were skipped. This was implemented in the past
in f490a8d, but then reverted in 04ec543, because sometimes it was stuck
reloading the first page.

The code that loads more results was simplified and a lot of duplicate
code was removed. The logic to remove users who changed their vote was
also introduced again, but just for the regular polls.
This commit is contained in:
Bianca Nenciu
2021-07-07 13:06:08 +03:00
committed by GitHub
parent a1e5a6bbe0
commit 573a71fdd9
2 changed files with 143 additions and 147 deletions
@@ -2,7 +2,7 @@ import {
acceptance,
publishToMessageBus,
} from "discourse/tests/helpers/qunit-helpers";
import { skip } from "qunit";
import { test } from "qunit";
import { clearPopupMenuOptionsCallback } from "discourse/controllers/composer";
import { visit } from "@ember/test-helpers";
@@ -553,13 +553,17 @@ acceptance("Poll results", function (needs) {
});
});
skip("can load more voters", async function (assert) {
test("can load more voters", async function (assert) {
await visit("/t/-/load-more-poll-voters");
assert.equal(
find(".poll-container .results li:nth-child(1) .poll-voters li").length,
1
);
assert.equal(
find(".poll-container .results li:nth-child(2) .poll-voters li").length,
0
);
publishToMessageBus("/polls/134", {
post_id: "156",
@@ -579,10 +583,10 @@ acceptance("Poll results", function (needs) {
{
id: "d8c22ff912e03740d9bc19e133e581e0",
html: 'Option <span class="hashtag">#2</span>',
votes: 1,
votes: 2,
},
],
voters: 2,
voters: 3,
preloaded_voters: {
db753fe0bc4e72869ac1ad8765341764: [
{
@@ -611,14 +615,25 @@ acceptance("Poll results", function (needs) {
});
await visit("/t/-/load-more-poll-voters");
await click(".poll-voters-toggle-expand a");
assert.equal(
find(".poll-container .results li:nth-child(1) .poll-voters li").length,
0
1
);
assert.equal(
find(".poll-container .results li:nth-child(2) .poll-voters li").length,
1
);
await click(".poll-voters-toggle-expand a");
await visit("/t/-/load-more-poll-voters");
assert.equal(
find(".poll-container .results li:nth-child(1) .poll-voters li").length,
2
);
assert.equal(
find(".poll-container .results li:nth-child(2) .poll-voters li").length,
0
);
});
});