discourse/plugins/poll/test/javascripts/acceptance/polls-bar-chart-test-mobile...

54 lines
1.3 KiB
Plaintext
Raw Normal View History

2019-01-23 12:27:21 -05:00
import { acceptance } from "helpers/qunit-helpers";
import { clearPopupMenuOptionsCallback } from "discourse/controllers/composer";
acceptance("Rendering polls with bar charts - mobile", {
2019-01-23 12:27:21 -05:00
loggedIn: true,
mobileView: true,
settings: { poll_enabled: true },
beforeEach() {
clearPopupMenuOptionsCallback();
}
});
test("Public number poll", async assert => {
2019-02-27 13:16:24 -05:00
await visit("/t/-/13");
2019-01-23 12:27:21 -05: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"
);
assert.notOk(
2019-01-23 12:27:21 -05:00
find(".poll-voters:first li:first a").attr("href"),
"user URL does not exist"
2019-01-23 12:27:21 -05:00
);
2019-02-27 13:16:24 -05: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",
name: "Bruce Wayne"
}))
};
return [200, { "Content-Type": "application/json" }, body];
});
2019-01-23 12:27:21 -05: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"
);
});