2021-11-13 09:31:42 -05:00
|
|
|
import { click, visit } from "@ember/test-helpers";
|
2023-10-10 14:38:59 -04:00
|
|
|
import { test } from "qunit";
|
2024-11-28 05:22:27 -05:00
|
|
|
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
2019-01-23 12:27:21 -05:00
|
|
|
|
2020-10-20 13:56:52 -04:00
|
|
|
acceptance("Rendering polls with bar charts - mobile", function (needs) {
|
|
|
|
needs.user();
|
|
|
|
needs.mobileView();
|
|
|
|
needs.settings({ poll_enabled: true });
|
|
|
|
needs.pretender((server, helper) => {
|
2020-10-07 17:08:19 -04:00
|
|
|
server.get("/polls/voters.json", () => {
|
2020-10-20 13:56:52 -04:00
|
|
|
return helper.response({
|
2020-10-07 17:08:19 -04:00
|
|
|
voters: Array.from(new Array(10), (_, i) => ({
|
|
|
|
id: 500 + i,
|
|
|
|
username: `bruce${500 + i}`,
|
|
|
|
avatar_template: "/images/avatar.png",
|
|
|
|
name: "Bruce Wayne",
|
|
|
|
})),
|
2020-10-20 13:56:52 -04:00
|
|
|
});
|
2020-10-07 17:08:19 -04:00
|
|
|
});
|
2020-10-20 13:56:52 -04:00
|
|
|
});
|
2019-01-23 12:27:21 -05:00
|
|
|
|
2020-10-30 12:37:32 -04:00
|
|
|
test("Public number poll", async function (assert) {
|
2020-10-20 13:56:52 -04:00
|
|
|
await visit("/t/-/13");
|
2019-01-23 12:27:21 -05:00
|
|
|
|
2024-11-28 05:22:27 -05:00
|
|
|
assert.dom(".poll").exists({ count: 1 }, "renders the poll correctly");
|
2019-01-23 12:27:21 -05:00
|
|
|
|
2020-10-20 13:56:52 -04:00
|
|
|
await click("button.toggle-results");
|
2019-01-23 12:27:21 -05:00
|
|
|
|
2024-11-28 05:22:27 -05:00
|
|
|
assert
|
|
|
|
.dom(".poll-voters:nth-of-type(1) li")
|
|
|
|
.exists({ count: 25 }, "displays the right number of voters");
|
2019-01-23 12:27:21 -05:00
|
|
|
|
2024-11-28 05:22:27 -05:00
|
|
|
assert
|
|
|
|
.dom(".poll-voters:nth-of-type(1) li:nth-of-type(1) a")
|
|
|
|
.doesNotHaveAttribute("href", "user URL does not exist");
|
2019-01-23 12:27:21 -05:00
|
|
|
|
2021-02-03 14:22:20 -05:00
|
|
|
await click(".poll-voters-toggle-expand:nth-of-type(1) a");
|
2019-01-23 12:27:21 -05:00
|
|
|
|
2024-11-28 05:22:27 -05:00
|
|
|
assert
|
|
|
|
.dom(".poll-voters:nth-of-type(1) li")
|
|
|
|
.exists({ count: 35 }, "displays the right number of voters");
|
2020-10-20 13:56:52 -04:00
|
|
|
});
|
2019-01-23 12:27:21 -05:00
|
|
|
});
|