mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-09 11:25:31 +08:00
This commit ensures that polls including @mentions of users with active user statuses are rendered correctly without errors. It introduces a document validation check before rendering components, adds fixtures for polls with mentions, and provides acceptance tests to verify proper rendering of polls containing @mentions.
54 lines
1.7 KiB
JavaScript
54 lines
1.7 KiB
JavaScript
import { visit } from "@ember/test-helpers";
|
|
import { test } from "qunit";
|
|
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
|
|
|
acceptance("Rendering polls with pie charts", function (needs) {
|
|
needs.user();
|
|
needs.settings({
|
|
poll_enabled: true,
|
|
poll_groupable_user_fields: "something",
|
|
});
|
|
|
|
test("Displays the pie chart", async function (assert) {
|
|
await visit("/t/-/topic_with_pie_chart_poll");
|
|
|
|
assert
|
|
.dom(".poll .poll-info_counts-count:first-child .info-number")
|
|
.hasText("2", "it should display the right number of voters");
|
|
|
|
assert
|
|
.dom(".poll .poll-info_counts-count:last-child .info-number")
|
|
.hasText("5", "it should display the right number of votes");
|
|
|
|
assert
|
|
.dom(".poll-outer")
|
|
.hasClass("pie", "pie class is present on poll div");
|
|
|
|
assert
|
|
.dom(".poll .poll-results-chart")
|
|
.exists({ count: 1 }, "Renders the chart div instead of bar container");
|
|
});
|
|
|
|
test("Renders results containing @mention correctly", async function (assert) {
|
|
// enable user status for the test to ensure the application renders without errors
|
|
this.siteSettings.enable_user_status = true;
|
|
|
|
await visit("/t/-/pie_chart_poll_with_mention");
|
|
|
|
assert
|
|
.dom(".poll .poll-info_counts-count:first-child .info-number")
|
|
.hasText("2", "it should display the right number of voters");
|
|
|
|
assert
|
|
.dom(".poll .poll-info_counts-count:last-child .info-number")
|
|
.hasText("5", "it should display the right number of votes");
|
|
|
|
assert
|
|
.dom(".poll-outer")
|
|
.hasClass("pie", "pie class is present on poll div");
|
|
|
|
assert
|
|
.dom(".poll .poll-results-chart")
|
|
.exists({ count: 1 }, "Renders the chart div instead of bar container");
|
|
});
|
|
});
|