2019-01-24 01:27:21 +08:00
|
|
|
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
|
|
|
import { clearPopupMenuOptionsCallback } from "discourse/controllers/composer";
|
2020-10-29 04:36:01 +08:00
|
|
|
import { queryAll } from "discourse/tests/helpers/qunit-helpers";
|
2019-01-24 01:27:21 +08:00
|
|
|
|
2020-10-21 01:56:52 +08:00
|
|
|
acceptance("Rendering polls with bar charts - mobile", function (needs) {
|
|
|
|
needs.user();
|
|
|
|
needs.mobileView();
|
|
|
|
needs.settings({ poll_enabled: true });
|
|
|
|
needs.pretender((server, helper) => {
|
2020-10-08 05:08:19 +08:00
|
|
|
server.get("/polls/voters.json", () => {
|
2020-10-21 01:56:52 +08:00
|
|
|
return helper.response({
|
2020-10-08 05:08:19 +08:00
|
|
|
voters: Array.from(new Array(10), (_, i) => ({
|
|
|
|
id: 500 + i,
|
|
|
|
username: `bruce${500 + i}`,
|
|
|
|
avatar_template: "/images/avatar.png",
|
|
|
|
name: "Bruce Wayne",
|
|
|
|
})),
|
2020-10-21 01:56:52 +08:00
|
|
|
});
|
2020-10-08 05:08:19 +08:00
|
|
|
});
|
2020-10-21 01:56:52 +08:00
|
|
|
});
|
|
|
|
needs.hooks.beforeEach(() => {
|
|
|
|
clearPopupMenuOptionsCallback();
|
|
|
|
});
|
2019-01-24 01:27:21 +08:00
|
|
|
|
2020-10-31 00:37:32 +08:00
|
|
|
test("Public number poll", async function (assert) {
|
2020-10-21 01:56:52 +08:00
|
|
|
await visit("/t/-/13");
|
2019-01-24 01:27:21 +08:00
|
|
|
|
2020-10-29 04:36:01 +08:00
|
|
|
const polls = queryAll(".poll");
|
2020-10-21 01:56:52 +08:00
|
|
|
assert.equal(polls.length, 1, "it should render the poll correctly");
|
2019-01-24 01:27:21 +08:00
|
|
|
|
2020-10-21 01:56:52 +08:00
|
|
|
await click("button.toggle-results");
|
2019-01-24 01:27:21 +08:00
|
|
|
|
2020-10-21 01:56:52 +08:00
|
|
|
assert.equal(
|
2020-10-29 04:36:01 +08:00
|
|
|
queryAll(".poll-voters:first li").length,
|
2020-10-21 01:56:52 +08:00
|
|
|
25,
|
|
|
|
"it should display the right number of voters"
|
|
|
|
);
|
2019-01-24 01:27:21 +08:00
|
|
|
|
2020-10-21 01:56:52 +08:00
|
|
|
assert.notOk(
|
2020-10-29 04:36:01 +08:00
|
|
|
queryAll(".poll-voters:first li:first a").attr("href"),
|
2020-10-21 01:56:52 +08:00
|
|
|
"user URL does not exist"
|
|
|
|
);
|
2019-01-24 01:27:21 +08:00
|
|
|
|
2020-10-21 01:56:52 +08:00
|
|
|
await click(".poll-voters-toggle-expand:first a");
|
2019-01-24 01:27:21 +08:00
|
|
|
|
2020-10-21 01:56:52 +08:00
|
|
|
assert.equal(
|
2020-10-29 04:36:01 +08:00
|
|
|
queryAll(".poll-voters:first li").length,
|
2020-10-21 01:56:52 +08:00
|
|
|
35,
|
|
|
|
"it should display the right number of voters"
|
|
|
|
);
|
|
|
|
});
|
2019-01-24 01:27:21 +08:00
|
|
|
});
|