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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.4 KiB
Plaintext
Raw Normal View History

2019-01-23 12:27:21 -05:00
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { clearPopupMenuOptionsCallback } from "discourse/controllers/composer";
acceptance("Rendering polls with bar charts - mobile", function (needs) {
needs.user();
needs.mobileView();
needs.settings({ poll_enabled: true });
needs.pretender((server, helper) => {
server.get("/polls/voters.json", () => {
return helper.response({
voters: Array.from(new Array(10), (_, i) => ({
id: 500 + i,
username: `bruce${500 + i}`,
avatar_template: "/images/avatar.png",
name: "Bruce Wayne",
})),
});
});
});
needs.hooks.beforeEach(() => {
clearPopupMenuOptionsCallback();
});
2019-01-23 12:27:21 -05:00
test("Public number poll", async (assert) => {
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");
2019-01-23 12:27:21 -05:00
await click("button.toggle-results");
2019-01-23 12:27:21 -05:00
assert.equal(
find(".poll-voters:first li").length,
25,
"it should display the right number of voters"
);
2019-01-23 12:27:21 -05:00
assert.notOk(
find(".poll-voters:first li:first a").attr("href"),
"user URL does not exist"
);
2019-01-23 12:27:21 -05:00
await click(".poll-voters-toggle-expand:first a");
2019-01-23 12:27:21 -05:00
assert.equal(
find(".poll-voters:first li").length,
35,
"it should display the right number of voters"
);
});
2019-01-23 12:27:21 -05:00
});