2021-06-08 11:54:12 -04:00
|
|
|
import {
|
|
|
|
acceptance,
|
2022-07-13 13:29:19 -04:00
|
|
|
count,
|
2021-06-08 11:54:12 -04:00
|
|
|
query,
|
|
|
|
} 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(
|
2022-07-13 13:29:19 -04:00
|
|
|
poll.querySelectorAll(".info-number")[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(
|
2022-07-13 13:29:19 -04:00
|
|
|
count(".poll-results-chart", poll),
|
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
|
|
|
});
|