2021-06-08 23:54:12 +08:00
|
|
|
import {
|
|
|
|
acceptance,
|
|
|
|
query,
|
|
|
|
queryAll,
|
|
|
|
} from "discourse/tests/helpers/qunit-helpers";
|
2019-11-26 01:51:01 +08:00
|
|
|
|
2020-10-21 01:56:52 +08:00
|
|
|
acceptance("Rendering polls with pie charts", function (needs) {
|
|
|
|
needs.user();
|
|
|
|
needs.settings({
|
|
|
|
poll_enabled: true,
|
|
|
|
poll_groupable_user_fields: "something",
|
|
|
|
});
|
2019-11-26 01:51:01 +08:00
|
|
|
|
2020-10-31 00:37:32 +08:00
|
|
|
test("Displays the pie chart", async function (assert) {
|
2020-10-21 01:56:52 +08:00
|
|
|
await visit("/t/-/topic_with_pie_chart_poll");
|
2019-11-26 01:51:01 +08:00
|
|
|
|
2021-06-08 23:54:12 +08:00
|
|
|
const poll = query(".poll");
|
2019-11-26 01:51:01 +08:00
|
|
|
|
2020-10-21 01:56:52 +08:00
|
|
|
assert.equal(
|
2021-06-08 23:54:12 +08:00
|
|
|
query(".info-number", poll).innerHTML,
|
2020-10-21 01:56:52 +08:00
|
|
|
"2",
|
|
|
|
"it should display the right number of voters"
|
|
|
|
);
|
2019-11-26 01:51:01 +08:00
|
|
|
|
2020-10-21 01:56:52 +08:00
|
|
|
assert.equal(
|
2020-10-29 04:36:01 +08:00
|
|
|
queryAll(".info-number", poll)[1].innerHTML,
|
2020-10-21 01:56:52 +08:00
|
|
|
"5",
|
|
|
|
"it should display the right number of votes"
|
|
|
|
);
|
2019-11-26 01:51:01 +08:00
|
|
|
|
2020-10-21 01:56:52 +08:00
|
|
|
assert.equal(
|
|
|
|
poll.classList.contains("pie"),
|
|
|
|
true,
|
|
|
|
"pie class is present on poll div"
|
|
|
|
);
|
2019-11-26 01:51:01 +08:00
|
|
|
|
2020-10-21 01:56:52 +08:00
|
|
|
assert.equal(
|
2020-10-29 04:36:01 +08:00
|
|
|
queryAll(".poll-results-chart", poll).length,
|
2020-10-21 01:56:52 +08:00
|
|
|
1,
|
|
|
|
"Renders the chart div instead of bar container"
|
|
|
|
);
|
|
|
|
});
|
2019-11-26 01:51:01 +08:00
|
|
|
});
|