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