discourse/plugins/poll/test/javascripts/acceptance/poll-pie-chart-test.js.es6
Jarek Radosz cd4f251891
FEATURE: Poll breakdown 2.0 (#10345)
The poll breakdown modal replaces the grouped pie charts feature.

Includes:

* MODAL: Untangle `onSelectPanel`
Previously modal-tab component would call on click the onSelectPanel callback with itself (modal-tab) as `this` which severely limited its usefulness. Now showModal binds the callback to its controller.

"The PR includes a fix/change to d-modal (b7f6ec6) that hasn't been extracted to a separate PR because it's not currently possible to test a change like this in abstract, i.e. with dynamically created controllers/components in tests. The percentage/count toggle test for the poll breakdown feature is essentially a test for that d-modal modification."
2020-08-06 17:57:06 +02:00

37 lines
834 B
JavaScript

import { acceptance } from "helpers/qunit-helpers";
acceptance("Rendering polls with pie charts - desktop", {
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"
);
});