DEV: De-jQ sidebar tests (#18050)

And fix a typo
This commit is contained in:
Jarek Radosz 2022-08-23 18:30:07 +02:00 committed by GitHub
parent fd2d9a4ba3
commit e21d2ac217
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 25 deletions

View File

@ -258,31 +258,31 @@ acceptance("Sidebar - Plugin API", function (needs) {
); );
assert.strictEqual( assert.strictEqual(
links[0].children.item(0).style.color, links[0].children[0].style.color,
"rgb(255, 0, 0)", "rgb(255, 0, 0)",
"has correct prefix color" "has correct prefix color"
); );
assert.strictEqual( assert.strictEqual(
$(links[0].children.item(0).children.item(0)).hasClass("d-icon-hashtag"), links[0].children[0].children[0].classList.contains("d-icon-hashtag"),
true, true,
"displays prefix icon" "displays prefix icon"
); );
assert.strictEqual( assert.strictEqual(
$(links[0].children.item(0).children.item(1)).hasClass("d-icon-lock"), links[0].children[0].children[1].classList.contains("d-icon-lock"),
true, true,
"displays prefix icon badge" "displays prefix icon badge"
); );
assert.strictEqual( assert.strictEqual(
$(links[0].children.item(2).children.item(0)).hasClass("d-icon-circle"), links[0].children[2].children[0].classList.contains("d-icon-circle"),
true, true,
"displays suffix icon" "displays suffix icon"
); );
assert.strictEqual( assert.strictEqual(
$(links[1].children[1])[0].textContent.trim(), links[1].children[1].textContent.trim(),
"dev channel text", "dev channel text",
"displays second link with correct text" "displays second link with correct text"
); );
@ -294,19 +294,19 @@ acceptance("Sidebar - Plugin API", function (needs) {
); );
assert.strictEqual( assert.strictEqual(
links[1].children.item(0).style.color, links[1].children[0].style.color,
"", "",
"has no color style when value is invalid" "has no color style when value is invalid"
); );
assert.strictEqual( assert.strictEqual(
$(links[1].children)[0].textContent.trim(), links[1].children[0].textContent.trim(),
"test text", "test text",
"displays prefix text" "displays prefix text"
); );
assert.strictEqual( assert.strictEqual(
$(links[2].children[1])[0].textContent.trim(), links[2].children[1].textContent.trim(),
"fun channel text", "fun channel text",
"displays third link with correct text" "displays third link with correct text"
); );
@ -318,7 +318,7 @@ acceptance("Sidebar - Plugin API", function (needs) {
); );
assert.strictEqual( assert.strictEqual(
$(links[2].children.item(0).children).attr("src"), links[2].children[0].children[0].getAttribute("src"),
"/test.png", "/test.png",
"uses correct prefix image url" "uses correct prefix image url"
); );
@ -477,22 +477,22 @@ acceptance("Sidebar - Plugin API", function (needs) {
await visit("/"); await visit("/");
const customlatestSectionLink = query( const customLatestSectionLink = query(
".sidebar-section-community .sidebar-section-link-latest" ".sidebar-section-community .sidebar-section-link-latest"
); );
assert.ok( assert.ok(
customlatestSectionLink, customLatestSectionLink,
"adds custom latest section link to community section" "adds custom latest section link to community section"
); );
assert.ok( assert.ok(
customlatestSectionLink.href.endsWith("/latest"), customLatestSectionLink.href.endsWith("/latest"),
"sets the right href attribute for the custom latest section link" "sets the right href attribute for the custom latest section link"
); );
assert.strictEqual( assert.strictEqual(
customlatestSectionLink.textContent.trim(), customLatestSectionLink.textContent.trim(),
I18n.t("filters.latest.title"), I18n.t("filters.latest.title"),
"displays the right text for custom latest section link" "displays the right text for custom latest section link"
); );

View File

@ -162,11 +162,9 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) {
".sidebar-section-categories .sidebar-section-link" ".sidebar-section-categories .sidebar-section-link"
); );
const categoryNames = []; const categoryNames = [...categorySectionLinks].map((categorySectionLink) =>
categorySectionLink.textContent.trim()
categorySectionLinks.each((_index, categorySectionLink) => { );
categoryNames.push(categorySectionLink.textContent.trim());
});
assert.deepEqual( assert.deepEqual(
categoryNames, categoryNames,

View File

@ -126,11 +126,9 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) {
".sidebar-section-tags .sidebar-section-link" ".sidebar-section-tags .sidebar-section-link"
); );
const tagNames = []; const tagNames = [...tagSectionLinks].map((tagSectionLink) =>
tagSectionLink.textContent.trim()
tagSectionLinks.each((_index, tagSectionLink) => { );
tagNames.push(tagSectionLink.textContent.trim());
});
assert.deepEqual( assert.deepEqual(
tagNames, tagNames,

View File

@ -1,5 +1,4 @@
import I18n from "I18n"; import I18n from "I18n";
import { test } from "qunit"; import { test } from "qunit";
import { click, visit } from "@ember/test-helpers"; import { click, visit } from "@ember/test-helpers";
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
@ -13,7 +12,7 @@ acceptance(
enable_experimental_sidebar_hamburger: false, enable_experimental_sidebar_hamburger: false,
}); });
test("clicking header hamburger icon displays old hamburger drodown", async function (assert) { test("clicking header hamburger icon displays old hamburger dropdown", async function (assert) {
await visit("/"); await visit("/");
await click(".hamburger-dropdown"); await click(".hamburger-dropdown");