mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 00:20:54 +08:00
DEV: Fix no-loose-assertions lint (#29965)
and enable some of qunit lints
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import { click, visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||
|
||||
acceptance("Poll breakdown", function (needs) {
|
||||
needs.user();
|
||||
@ -80,9 +80,10 @@ acceptance("Poll breakdown", function (needs) {
|
||||
"renders a chart for each of the groups in group_results response"
|
||||
);
|
||||
|
||||
assert.ok(
|
||||
query(".poll-breakdown-chart-container > canvas").$chartjs,
|
||||
"$chartjs is defined on the pie charts"
|
||||
assert.notStrictEqual(
|
||||
document.querySelector(".poll-breakdown-chart-container > canvas")
|
||||
.$chartjs,
|
||||
undefined
|
||||
);
|
||||
});
|
||||
|
||||
@ -92,26 +93,20 @@ acceptance("Poll breakdown", function (needs) {
|
||||
|
||||
await click("button.show-breakdown");
|
||||
|
||||
assert.strictEqual(
|
||||
query(".poll-breakdown-option-count").textContent.trim(),
|
||||
"40.0%",
|
||||
"displays the correct vote percentage"
|
||||
);
|
||||
assert
|
||||
.dom(".poll-breakdown-option-count")
|
||||
.hasText("40.0%", "displays the correct vote percentage");
|
||||
|
||||
await click(".modal-tabs .count");
|
||||
|
||||
assert.strictEqual(
|
||||
query(".poll-breakdown-option-count").textContent.trim(),
|
||||
"2",
|
||||
"displays the correct vote count"
|
||||
);
|
||||
assert
|
||||
.dom(".poll-breakdown-option-count")
|
||||
.hasText("2", "displays the correct vote count");
|
||||
|
||||
await click(".modal-tabs .percentage");
|
||||
|
||||
assert.strictEqual(
|
||||
query(".poll-breakdown-option-count").textContent.trim(),
|
||||
"40.0%",
|
||||
"displays the percentage again"
|
||||
);
|
||||
assert
|
||||
.dom(".poll-breakdown-option-count")
|
||||
.hasText("40.0%", "displays the percentage again");
|
||||
});
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { click, visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||
|
||||
acceptance("Rendering polls with bar charts - desktop", function (needs) {
|
||||
needs.user();
|
||||
@ -41,71 +41,55 @@ acceptance("Rendering polls with bar charts - desktop", function (needs) {
|
||||
test("Polls", async function (assert) {
|
||||
await visit("/t/-/15");
|
||||
|
||||
const polls = queryAll(".poll");
|
||||
assert.dom(".poll").exists({ count: 2 }, "renders the polls correctly");
|
||||
|
||||
assert.strictEqual(polls.length, 2, "it should render the polls correctly");
|
||||
const polls = document.querySelectorAll(".poll");
|
||||
assert
|
||||
.dom(".info-number", polls[0])
|
||||
.hasText("2", "displays the right number of votes");
|
||||
|
||||
assert.strictEqual(
|
||||
queryAll(".info-number", polls[0]).text(),
|
||||
"2",
|
||||
"it should display the right number of votes"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
queryAll(".info-number", polls[1]).text(),
|
||||
"3",
|
||||
"it should display the right number of votes"
|
||||
);
|
||||
assert
|
||||
.dom(".info-number", polls[1])
|
||||
.hasText("3", "displays the right number of votes");
|
||||
});
|
||||
|
||||
test("Public poll", async function (assert) {
|
||||
await visit("/t/-/14");
|
||||
|
||||
const polls = queryAll(".poll");
|
||||
assert.strictEqual(polls.length, 1, "it should render the poll correctly");
|
||||
assert.dom(".poll").exists({ count: 1 }, "renders the poll correctly");
|
||||
|
||||
await click("button.toggle-results");
|
||||
|
||||
assert.strictEqual(
|
||||
queryAll(".poll-voters:nth-of-type(1) li").length,
|
||||
25,
|
||||
"it should display the right number of voters"
|
||||
);
|
||||
assert
|
||||
.dom(".poll-voters:nth-of-type(1) li")
|
||||
.exists({ count: 25 }, "displays the right number of voters");
|
||||
|
||||
await click(".poll-voters-toggle-expand:nth-of-type(1) a");
|
||||
|
||||
assert.strictEqual(
|
||||
queryAll(".poll-voters:nth-of-type(1) li").length,
|
||||
26,
|
||||
"it should display the right number of voters"
|
||||
);
|
||||
assert
|
||||
.dom(".poll-voters:nth-of-type(1) li")
|
||||
.exists({ count: 26 }, "displays the right number of voters");
|
||||
});
|
||||
|
||||
test("Public number poll", async function (assert) {
|
||||
await visit("/t/-/13");
|
||||
|
||||
const polls = queryAll(".poll");
|
||||
assert.strictEqual(polls.length, 1, "it should render the poll correctly");
|
||||
assert.dom(".poll").exists({ count: 1 }, "renders the poll correctly");
|
||||
|
||||
await click("button.toggle-results");
|
||||
|
||||
assert.strictEqual(
|
||||
queryAll(".poll-voters:nth-of-type(1) li").length,
|
||||
25,
|
||||
"it should display the right number of voters"
|
||||
);
|
||||
assert
|
||||
.dom(".poll-voters:nth-of-type(1) li")
|
||||
.exists({ count: 25 }, "displays the right number of voters");
|
||||
|
||||
assert.notOk(
|
||||
queryAll(".poll-voters:nth-of-type(1) li:nth-of-type(1) a").attr("href"),
|
||||
"user URL does not exist"
|
||||
);
|
||||
assert
|
||||
.dom(".poll-voters:nth-of-type(1) li:nth-of-type(1) a")
|
||||
.doesNotHaveAttribute("href", "user URL does not exist");
|
||||
|
||||
await click(".poll-voters-toggle-expand:nth-of-type(1) a");
|
||||
|
||||
assert.strictEqual(
|
||||
queryAll(".poll-voters:nth-of-type(1) li").length,
|
||||
30,
|
||||
"it should display the right number of voters"
|
||||
);
|
||||
assert
|
||||
.dom(".poll-voters:nth-of-type(1) li")
|
||||
.exists({ count: 30 }, "displays the right number of voters");
|
||||
});
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { click, visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||
|
||||
acceptance("Rendering polls with bar charts - mobile", function (needs) {
|
||||
needs.user();
|
||||
@ -22,28 +22,22 @@ acceptance("Rendering polls with bar charts - mobile", function (needs) {
|
||||
test("Public number poll", async function (assert) {
|
||||
await visit("/t/-/13");
|
||||
|
||||
const polls = queryAll(".poll");
|
||||
assert.strictEqual(polls.length, 1, "it should render the poll correctly");
|
||||
assert.dom(".poll").exists({ count: 1 }, "renders the poll correctly");
|
||||
|
||||
await click("button.toggle-results");
|
||||
|
||||
assert.strictEqual(
|
||||
queryAll(".poll-voters:nth-of-type(1) li").length,
|
||||
25,
|
||||
"it should display the right number of voters"
|
||||
);
|
||||
assert
|
||||
.dom(".poll-voters:nth-of-type(1) li")
|
||||
.exists({ count: 25 }, "displays the right number of voters");
|
||||
|
||||
assert.notOk(
|
||||
queryAll(".poll-voters:nth-of-type(1) li:nth-of-type(1) a").attr("href"),
|
||||
"user URL does not exist"
|
||||
);
|
||||
assert
|
||||
.dom(".poll-voters:nth-of-type(1) li:nth-of-type(1) a")
|
||||
.doesNotHaveAttribute("href", "user URL does not exist");
|
||||
|
||||
await click(".poll-voters-toggle-expand:nth-of-type(1) a");
|
||||
|
||||
assert.strictEqual(
|
||||
queryAll(".poll-voters:nth-of-type(1) li").length,
|
||||
35,
|
||||
"it should display the right number of voters"
|
||||
);
|
||||
assert
|
||||
.dom(".poll-voters:nth-of-type(1) li")
|
||||
.exists({ count: 35 }, "displays the right number of voters");
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user