mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Remove most of jQuery usage from tests (#17474)
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
import {
|
||||
acceptance,
|
||||
query,
|
||||
queryAll,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
|
||||
import I18n from "I18n";
|
||||
import { clearPopupMenuOptionsCallback } from "discourse/controllers/composer";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
@@ -23,7 +19,7 @@ acceptance("Details Button", function (needs) {
|
||||
await popupMenu.selectRowByValue("insertDetails");
|
||||
|
||||
assert.strictEqual(
|
||||
queryAll(".d-editor-input").val(),
|
||||
query(".d-editor-input").value,
|
||||
`\n[details="${I18n.t("composer.details_title")}"]\n${I18n.t(
|
||||
"composer.details_text"
|
||||
)}\n[/details]\n`,
|
||||
@@ -40,7 +36,7 @@ acceptance("Details Button", function (needs) {
|
||||
await popupMenu.selectRowByValue("insertDetails");
|
||||
|
||||
assert.strictEqual(
|
||||
queryAll(".d-editor-input").val(),
|
||||
query(".d-editor-input").value,
|
||||
`\n[details="${I18n.t(
|
||||
"composer.details_title"
|
||||
)}"]\nThis is my title\n[/details]\n`,
|
||||
@@ -67,7 +63,7 @@ acceptance("Details Button", function (needs) {
|
||||
await popupMenu.selectRowByValue("insertDetails");
|
||||
|
||||
assert.strictEqual(
|
||||
queryAll(".d-editor-input").val(),
|
||||
query(".d-editor-input").value,
|
||||
`Before \n[details="${I18n.t(
|
||||
"composer.details_title"
|
||||
)}"]\nsome text in between\n[/details]\n After`,
|
||||
@@ -94,7 +90,7 @@ acceptance("Details Button", function (needs) {
|
||||
await popupMenu.selectRowByValue("insertDetails");
|
||||
|
||||
assert.strictEqual(
|
||||
queryAll(".d-editor-input").val(),
|
||||
query(".d-editor-input").value,
|
||||
`Before \n\n[details="${I18n.t(
|
||||
"composer.details_title"
|
||||
)}"]\nsome text in between\n[/details]\n\n After`,
|
||||
@@ -129,7 +125,7 @@ acceptance("Details Button", function (needs) {
|
||||
await popupMenu.selectRowByValue("insertDetails");
|
||||
|
||||
assert.strictEqual(
|
||||
queryAll(".d-editor-input").val(),
|
||||
query(".d-editor-input").value,
|
||||
`\n[details="${I18n.t(
|
||||
"composer.details_title"
|
||||
)}"]\n${multilineInput}\n[/details]\n`,
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
import {
|
||||
acceptance,
|
||||
query,
|
||||
queryAll,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { test } from "qunit";
|
||||
import { click, fillIn, visit } from "@ember/test-helpers";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
@@ -13,9 +9,9 @@ acceptance("Local Dates - composer", function (needs) {
|
||||
|
||||
test("composer bbcode", async function (assert) {
|
||||
const getAttr = (attr) => {
|
||||
return queryAll(
|
||||
return query(
|
||||
".d-editor-preview .discourse-local-date.cooked-date"
|
||||
).attr(`data-${attr}`);
|
||||
).getAttribute(`data-${attr}`);
|
||||
};
|
||||
|
||||
await visit("/");
|
||||
|
||||
@@ -2,7 +2,7 @@ import { cloneJSON } from "discourse-common/lib/object";
|
||||
import topicFixtures from "discourse/tests/fixtures/topic";
|
||||
import {
|
||||
acceptance,
|
||||
queryAll,
|
||||
query,
|
||||
selectText,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { test } from "qunit";
|
||||
@@ -15,17 +15,17 @@ acceptance("Local Dates - quoting", function (needs) {
|
||||
needs.pretender((server, helper) => {
|
||||
const topicResponse = cloneJSON(topicFixtures["/t/280/1.json"]);
|
||||
const firstPost = topicResponse.post_stream.posts[0];
|
||||
firstPost.cooked += `<div class='select-local-date-test'>This is a test <span data-date="2022-06-17" data-time="10:00:00" class="discourse-local-date cooked-date past" data-displayed-timezone="Australia/Perth" data-timezone="Australia/Brisbane" data-email-preview="2022-06-17T00:00:00Z UTC" aria-label="Brisbane Friday, June 17, 2022
|
||||
firstPost.cooked += `<div class='select-local-date-test'>This is a test <span data-date="2022-06-17" data-time="10:00:00" class="discourse-local-date cooked-date past" data-displayed-timezone="Australia/Perth" data-timezone="Australia/Brisbane" data-email-preview="2022-06-17T00:00:00Z UTC" aria-label="Brisbane Friday, June 17, 2022
|
||||
<br />
|
||||
<svg class='fa d-icon d-icon-clock svg-icon svg-string'
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<use href="#clock" />
|
||||
</svg> 10:00 AM, Paris Friday, June 17, 2022
|
||||
</svg> 10:00 AM, Paris Friday, June 17, 2022
|
||||
<br />
|
||||
<svg class='fa d-icon d-icon-clock svg-icon svg-string'
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<use href="#clock" />
|
||||
</svg> 2:00 AM, Los Angeles Thursday, June 16, 2022
|
||||
</svg> 2:00 AM, Los Angeles Thursday, June 16, 2022
|
||||
<br />
|
||||
<svg class='fa d-icon d-icon-clock svg-icon svg-string'
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
@@ -48,7 +48,7 @@ acceptance("Local Dates - quoting", function (needs) {
|
||||
await selectText("#post_1 .select-local-date-test");
|
||||
await click(".insert-quote");
|
||||
assert.strictEqual(
|
||||
queryAll(".d-editor-input").val().trim(),
|
||||
query(".d-editor-input").value.trim(),
|
||||
`[quote=\"Uwe Keim, post:1, topic:280, username:uwe_keim\"]
|
||||
This is a test [date=2022-06-17 time=10:00:00 timezone="Australia/Brisbane" displayedTimezone="Australia/Perth"]
|
||||
[/quote]`,
|
||||
@@ -87,7 +87,7 @@ acceptance("Local Dates - quoting range", function (needs) {
|
||||
await selectText("#post_1 .select-local-date-test");
|
||||
await click(".insert-quote");
|
||||
assert.strictEqual(
|
||||
queryAll(".d-editor-input").val().trim(),
|
||||
query(".d-editor-input").value.trim(),
|
||||
`[quote=\"Uwe Keim, post:1, topic:280, username:uwe_keim\"]
|
||||
Some text [date-range from=2022-06-17T09:30:00 to=2022-06-18T10:30:00 format="LL" timezone="Australia/Brisbane" timezones="Africa/Accra|Australia/Brisbane|Europe/Paris"]
|
||||
[/quote]`,
|
||||
@@ -129,7 +129,7 @@ acceptance(
|
||||
await selectText("#post_1 .select-local-date-test");
|
||||
await click(".insert-quote");
|
||||
assert.strictEqual(
|
||||
queryAll(".d-editor-input").val().trim(),
|
||||
query(".d-editor-input").value.trim(),
|
||||
`[quote=\"Uwe Keim, post:1, topic:280, username:uwe_keim\"]
|
||||
Testing countdown [date=2022-06-21 time=09:30:00 format="LL" timezone="Australia/Brisbane" countdown="true"]
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
acceptance,
|
||||
count,
|
||||
query,
|
||||
queryAll,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { test } from "qunit";
|
||||
import { visit } from "@ember/test-helpers";
|
||||
@@ -25,7 +25,7 @@ acceptance("Rendering polls with pie charts", function (needs) {
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
queryAll(".info-number", poll)[1].innerHTML,
|
||||
poll.querySelectorAll(".info-number")[1].innerHTML,
|
||||
"5",
|
||||
"it should display the right number of votes"
|
||||
);
|
||||
@@ -37,7 +37,7 @@ acceptance("Rendering polls with pie charts", function (needs) {
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
queryAll(".poll-results-chart", poll).length,
|
||||
count(".poll-results-chart", poll),
|
||||
1,
|
||||
"Renders the chart div instead of bar container"
|
||||
);
|
||||
|
||||
@@ -196,8 +196,9 @@ discourseModule("Unit | Controller | poll-ui-builder", function () {
|
||||
controller.currentUser = { staff: false };
|
||||
controller.notifyPropertyChange("pollResults");
|
||||
|
||||
assert.ok(
|
||||
controller.pollResults.filterBy("value", "staff_only").length === 0,
|
||||
assert.strictEqual(
|
||||
controller.pollResults.filterBy("value", "staff_only").length,
|
||||
0,
|
||||
"staff_only is not present"
|
||||
);
|
||||
});
|
||||
@@ -212,8 +213,9 @@ discourseModule("Unit | Controller | poll-ui-builder", function () {
|
||||
controller.currentUser = { staff: true };
|
||||
controller.notifyPropertyChange("pollResults");
|
||||
|
||||
assert.ok(
|
||||
controller.pollResults.filterBy("value", "staff_only").length === 1,
|
||||
assert.strictEqual(
|
||||
controller.pollResults.filterBy("value", "staff_only").length,
|
||||
1,
|
||||
"staff_only is present"
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user