discourse/plugins/poll/test/javascripts/acceptance/polls-bar-chart-test-mobile.js.es6
Robin Ward 61f5d501cb
DEV: Migrate to Ember CLI (#11932)
This encompasses a lot of work done over the last year, much of which
has already been merged into master. This is the final set of changes
required to get Ember CLI running locally for development.

From here on it will be bug fixes / enhancements.

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
Co-authored-by: romanrizzi <rizziromanalejandro@gmail.com>

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
Co-authored-by: romanrizzi <rizziromanalejandro@gmail.com>
2021-02-03 14:22:20 -05:00

52 lines
1.4 KiB
JavaScript

import { acceptance, queryAll } 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();
});
test("Public number poll", async function (assert) {
await visit("/t/-/13");
const polls = queryAll(".poll");
assert.equal(polls.length, 1, "it should render the poll correctly");
await click("button.toggle-results");
assert.equal(
queryAll(".poll-voters:nth-of-type(1) li").length,
25,
"it should display the right number of voters"
);
assert.notOk(
queryAll(".poll-voters:nth-of-type(1) li:nth-of-type(1) a").attr("href"),
"user URL does not exist"
);
await click(".poll-voters-toggle-expand:nth-of-type(1) a");
assert.equal(
queryAll(".poll-voters:nth-of-type(1) li").length,
35,
"it should display the right number of voters"
);
});
});