discourse/plugins/poll/test/javascripts/acceptance/poll-pie-chart-test.js.es6
Robin Ward ef7d99b0a8 REFACTOR: Move test setup to a module
This is long overdue. We had a lot of (not linted) code to initialize
our test suite as part of the Ruby `test_helper.js` bundle.

This refactor moves that out to a `setup-tests` module, which imports
all the modules properly, rather than using `require`.

It also removes the global `server` variable which some tests were using
for pretender. Those tests are fixed, and in the case of widget tests,
support for a `pretend()` was added, which mimics our acceptance tests.

One problematic test was removed, which overwrites `/posts` - this could
break tons of other tests depending on order.
2020-10-08 15:11:51 -04:00

37 lines
843 B
JavaScript

import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Rendering polls with pie charts", {
loggedIn: true,
settings: { poll_enabled: true, poll_groupable_user_fields: "something" },
});
test("Displays the pie chart", async (assert) => {
await visit("/t/-/topic_with_pie_chart_poll");
const poll = find(".poll")[0];
assert.equal(
find(".info-number", poll)[0].innerHTML,
"2",
"it should display the right number of voters"
);
assert.equal(
find(".info-number", poll)[1].innerHTML,
"5",
"it should display the right number of votes"
);
assert.equal(
poll.classList.contains("pie"),
true,
"pie class is present on poll div"
);
assert.equal(
find(".poll-results-chart", poll).length,
1,
"Renders the chart div instead of bar container"
);
});