DEV: Use new qunit-dom's includesValue/doesNotIncludeValue (#30034)

This commit is contained in:
Jarek Radosz 2024-12-02 16:30:56 +01:00 committed by GitHub
parent 9bdd97db42
commit 72f3cd252f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 50 additions and 58 deletions

View File

@ -6,7 +6,6 @@ import { toggleCheckDraftPopup } from "discourse/services/composer";
import userFixtures from "discourse/tests/fixtures/user-fixtures";
import {
acceptance,
query,
selectText,
updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers";
@ -127,7 +126,7 @@ acceptance("Composer Actions", function (needs) {
assert.strictEqual(categoryChooserReplyArea.header().name(), "faq");
assert.dom(".action-title").hasText(i18n("topic.create_long"));
assert.true(query(".d-editor-input").value.includes(quote));
assert.dom(".d-editor-input").includesValue(quote);
});
test("reply_as_new_topic without a new_topic draft", async function (assert) {
@ -210,7 +209,7 @@ acceptance("Composer Actions", function (needs) {
await composerActions.expand();
assert.dom(".action-title").hasText(i18n("topic.create_long"));
assert.true(query(".d-editor-input").value.includes(quote));
assert.dom(".d-editor-input").includesValue(quote);
assert.strictEqual(composerActions.rowByIndex(0).value(), "reply_to_post");
assert.strictEqual(composerActions.rowByIndex(1).value(), "reply_to_topic");
assert.strictEqual(composerActions.rowByIndex(2).value(), "shared_draft");

View File

@ -1,7 +1,7 @@
import { click, fillIn, triggerKeyEvent, visit } from "@ember/test-helpers";
import { test } from "qunit";
import { withPluginApi } from "discourse/lib/plugin-api";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Composer - Image Preview", function (needs) {
needs.user({});
@ -339,10 +339,9 @@ acceptance("Composer - Image Preview", function (needs) {
.dom(".d-editor-input")
.hasValue(uploads.join("\n"), "Image should be removed from the editor");
assert.false(
query(".d-editor-input").value.includes("image_example_0"),
"does not have the first image"
);
assert
.dom(".d-editor-input")
.doesNotIncludeValue("image_example_0", "does not have the first image");
assert
.dom(".d-editor-input")

View File

@ -871,10 +871,9 @@ acceptance("Composer", function (needs) {
assert.dom(".d-modal__body").doesNotExist("abandon popup shouldn't come");
assert.true(
query(".d-editor-input").value.includes(longText),
"entered text should still be there"
);
assert
.dom(".d-editor-input")
.includesValue(longText, "entered text should still be there");
assert
.dom('.action-title a[href="/t/internationalization-localization/280"]')

View File

@ -627,12 +627,12 @@ acceptance("Search - Authenticated", function (needs) {
.dom(".d-editor-input")
.hasValue(/a link/, "still has the original composer content");
assert.true(
query(".d-editor-input").value.includes(
searchFixtures["search/query"].topics[0].slug
),
"adds link from search to composer"
);
assert
.dom(".d-editor-input")
.includesValue(
searchFixtures["search/query"].topics[0].slug,
"adds link from search to composer"
);
});
// see https://meta.discourse.org/t/keyboard-navigation-messes-up-the-search-menu/285405

View File

@ -1,7 +1,7 @@
import { click, currentURL, visit } from "@ember/test-helpers";
import { test } from "qunit";
import CategoryFixtures from "discourse/tests/fixtures/category-fixtures";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import { i18n } from "discourse-i18n";
@ -37,12 +37,12 @@ acceptance("Share and Invite modal", function (needs) {
.dom("#modal-alert.alert-warning")
.doesNotExist("it does not show the alert with restricted groups");
assert.true(
query("input.invite-link").value.includes(
"/t/internationalization-localization/280?u=eviltrout"
),
"it shows the topic sharing url"
);
assert
.dom("input.invite-link")
.includesValue(
"/t/internationalization-localization/280?u=eviltrout",
"shows the topic sharing url"
);
assert
.dom(".link-share-actions .invite")
@ -127,10 +127,12 @@ acceptance("Share url with badges disabled - desktop", function (needs) {
await visit("/t/internationalization-localization/280");
await click("#topic-footer-button-share-and-invite");
assert.false(
query("input.invite-link").value.includes("?u=eviltrout"),
"it doesn't add the username param when badges are disabled"
);
assert
.dom("input.invite-link")
.doesNotIncludeValue(
"?u=eviltrout",
"doesn't add the username param when badges are disabled"
);
});
});
@ -148,9 +150,11 @@ acceptance("With username in share links disabled - desktop", function (needs) {
await visit("/t/internationalization-localization/280");
await click("#topic-footer-button-share-and-invite");
assert.false(
query("input.invite-link").value.includes("?u=eviltrout"),
"it doesn't add the username param when username in share links are disabled"
);
assert
.dom("input.invite-link")
.doesNotIncludeValue(
"?u=eviltrout",
"doesn't add the username param when username in share links are disabled"
);
});
});

View File

@ -13,7 +13,6 @@ import {
acceptance,
chromeTest,
publishToMessageBus,
query,
selectText,
} from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
@ -372,11 +371,9 @@ acceptance("Topic featured links", function (needs) {
await selectText("#post_5 blockquote");
await click(".quote-button .insert-quote");
assert.true(
query(".d-editor-input").value.includes(
'quote="codinghorror said, post:3, topic:280"'
)
);
assert
.dom(".d-editor-input")
.includesValue('quote="codinghorror said, post:3, topic:280"');
});
test("Quoting a quote of a different topic keeps the original topic title", async function (assert) {
@ -384,11 +381,11 @@ acceptance("Topic featured links", function (needs) {
await selectText("#post_9 blockquote");
await click(".quote-button .insert-quote");
assert.true(
query(".d-editor-input").value.includes(
assert
.dom(".d-editor-input")
.includesValue(
'quote="A new topic with a link to another topic, post:3, topic:62"'
)
);
);
});
test("Quoting a quote with the Reply button keeps the original poster name", async function (assert) {
@ -396,11 +393,9 @@ acceptance("Topic featured links", function (needs) {
await selectText("#post_5 blockquote");
await click(".reply");
assert.true(
query(".d-editor-input").value.includes(
'quote="codinghorror said, post:3, topic:280"'
)
);
assert
.dom(".d-editor-input")
.includesValue('quote="codinghorror said, post:3, topic:280"');
});
// Using J/K on Firefox clean the text selection, so this won't work there
@ -412,11 +407,9 @@ acceptance("Topic featured links", function (needs) {
await triggerKeyEvent(document, "keypress", "J");
await triggerKeyEvent(document, "keypress", "T");
assert.true(
query(".d-editor-input").value.includes(
'quote="codinghorror said, post:3, topic:280"'
)
);
assert
.dom(".d-editor-input")
.includesValue('quote="codinghorror said, post:3, topic:280"');
}
);
@ -424,11 +417,9 @@ acceptance("Topic featured links", function (needs) {
await visit("/t/internationalization-localization/280");
await selectText("#post_5 .cooked");
await click(".quote-button .insert-quote");
assert.true(
query(".d-editor-input").value.includes(
'quote="pekka, post:5, topic:280, full:true"'
)
);
assert
.dom(".d-editor-input")
.includesValue('quote="pekka, post:5, topic:280, full:true"');
});
});