2019-01-24 01:27:21 +08:00
|
|
|
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
|
|
|
import { clearPopupMenuOptionsCallback } from "discourse/controllers/composer";
|
|
|
|
|
2019-11-26 01:51:01 +08:00
|
|
|
acceptance("Rendering polls with bar charts - mobile", {
|
2019-01-24 01:27:21 +08:00
|
|
|
loggedIn: true,
|
|
|
|
mobileView: true,
|
|
|
|
settings: { poll_enabled: true },
|
|
|
|
beforeEach() {
|
|
|
|
clearPopupMenuOptionsCallback();
|
2020-09-05 02:01:14 +08:00
|
|
|
},
|
2019-01-24 01:27:21 +08:00
|
|
|
});
|
|
|
|
|
2020-09-05 02:01:14 +08:00
|
|
|
test("Public number poll", async (assert) => {
|
2019-02-28 02:16:24 +08:00
|
|
|
await visit("/t/-/13");
|
2019-01-24 01:27:21 +08:00
|
|
|
|
|
|
|
const polls = find(".poll");
|
|
|
|
assert.equal(polls.length, 1, "it should render the poll correctly");
|
|
|
|
|
|
|
|
await click("button.toggle-results");
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find(".poll-voters:first li").length,
|
|
|
|
25,
|
|
|
|
"it should display the right number of voters"
|
|
|
|
);
|
|
|
|
|
2019-04-04 04:17:05 +08:00
|
|
|
assert.notOk(
|
2019-01-24 01:27:21 +08:00
|
|
|
find(".poll-voters:first li:first a").attr("href"),
|
2019-04-04 04:17:05 +08:00
|
|
|
"user URL does not exist"
|
2019-01-24 01:27:21 +08:00
|
|
|
);
|
|
|
|
|
2019-02-28 02:16:24 +08:00
|
|
|
// eslint-disable-next-line
|
|
|
|
server.get("/polls/voters.json", () => {
|
|
|
|
const body = {
|
|
|
|
voters: Array.from(new Array(10), (_, i) => ({
|
|
|
|
id: 500 + i,
|
|
|
|
username: `bruce${500 + i}`,
|
|
|
|
avatar_template: "/images/avatar.png",
|
2020-09-05 02:01:14 +08:00
|
|
|
name: "Bruce Wayne",
|
|
|
|
})),
|
2019-02-28 02:16:24 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
return [200, { "Content-Type": "application/json" }, body];
|
|
|
|
});
|
|
|
|
|
2019-01-24 01:27:21 +08:00
|
|
|
await click(".poll-voters-toggle-expand:first a");
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find(".poll-voters:first li").length,
|
|
|
|
35,
|
|
|
|
"it should display the right number of voters"
|
|
|
|
);
|
|
|
|
});
|