2021-06-08 23:54:12 +08:00
|
|
|
import {
|
|
|
|
acceptance,
|
2022-07-14 01:29:19 +08:00
|
|
|
count,
|
2021-06-08 23:54:12 +08:00
|
|
|
query,
|
|
|
|
} from "discourse/tests/helpers/qunit-helpers";
|
2021-06-09 22:58:55 +08:00
|
|
|
import { test } from "qunit";
|
|
|
|
import { visit } from "@ember/test-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
|
|
|
|
2021-11-08 17:26:28 +08:00
|
|
|
assert.strictEqual(
|
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
|
|
|
|
2021-11-08 17:26:28 +08:00
|
|
|
assert.strictEqual(
|
2022-07-14 01:29:19 +08:00
|
|
|
poll.querySelectorAll(".info-number")[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
|
|
|
|
2021-11-08 17:26:28 +08:00
|
|
|
assert.strictEqual(
|
2020-10-21 01:56:52 +08:00
|
|
|
poll.classList.contains("pie"),
|
|
|
|
true,
|
|
|
|
"pie class is present on poll div"
|
|
|
|
);
|
2019-11-26 01:51:01 +08:00
|
|
|
|
2021-11-08 17:26:28 +08:00
|
|
|
assert.strictEqual(
|
2022-07-14 01:29:19 +08:00
|
|
|
count(".poll-results-chart", poll),
|
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
|
|
|
});
|