2023-10-11 02:38:59 +08:00
|
|
|
import { visit } from "@ember/test-helpers";
|
|
|
|
import { test } from "qunit";
|
2024-06-24 04:34:15 +08:00
|
|
|
import { acceptance } 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
|
|
|
|
2024-06-24 04:34:15 +08:00
|
|
|
assert
|
|
|
|
.dom(".poll .poll-info_counts-count:first-child .info-number")
|
|
|
|
.hasText("2", "it should display the right number of voters");
|
2019-11-26 01:51:01 +08:00
|
|
|
|
2024-06-24 04:34:15 +08:00
|
|
|
assert
|
|
|
|
.dom(".poll .poll-info_counts-count:last-child .info-number")
|
|
|
|
.hasText("5", "it should display the right number of votes");
|
2019-11-26 01:51:01 +08:00
|
|
|
|
2024-07-04 19:34:48 +08:00
|
|
|
assert.dom(".poll-outer").hasClass("pie", "pie class is present on poll div");
|
2019-11-26 01:51:01 +08:00
|
|
|
|
2024-06-24 04:34:15 +08:00
|
|
|
assert
|
|
|
|
.dom(".poll .poll-results-chart")
|
|
|
|
.exists({ count: 1 }, "Renders the chart div instead of bar container");
|
2020-10-21 01:56:52 +08:00
|
|
|
});
|
2019-11-26 01:51:01 +08:00
|
|
|
});
|