DEV: Use qunit-dom's hasValue wherever possible (#30018)

This commit is contained in:
Jarek Radosz 2024-12-01 20:37:24 +01:00 committed by GitHub
parent efa2589204
commit 6e4baaf092
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
31 changed files with 473 additions and 545 deletions

View File

@ -1,6 +1,6 @@
import { click, currentURL, fillIn, visit } from "@ember/test-helpers"; import { click, currentURL, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { i18n } from "discourse-i18n"; import { i18n } from "discourse-i18n";
acceptance("Admin - Themes - Install modal", function (needs) { acceptance("Admin - Themes - Install modal", function (needs) {
@ -20,11 +20,7 @@ acceptance("Admin - Themes - Install modal", function (needs) {
await click(".install-theme-content .inputs .advanced-repo"); await click(".install-theme-content .inputs .advanced-repo");
await fillIn(branchInput, "tests-passed"); await fillIn(branchInput, "tests-passed");
assert.dom(urlInput).hasValue(themeUrl, "url input is filled"); assert.dom(urlInput).hasValue(themeUrl, "url input is filled");
assert.strictEqual( assert.dom(branchInput).hasValue("tests-passed", "branch input is filled");
query(branchInput).value,
"tests-passed",
"branch input is filled"
);
assert.dom(publicKey).exists("shows public key"); assert.dom(publicKey).exists("shows public key");
await click(".d-modal__footer .d-modal-cancel"); await click(".d-modal__footer .d-modal-cancel");

View File

@ -4,7 +4,6 @@ import {
acceptance, acceptance,
fakeTime, fakeTime,
loggedInUser, loggedInUser,
query,
queryAll, queryAll,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper"; import selectKit from "discourse/tests/helpers/select-kit-helper";
@ -56,10 +55,7 @@ acceptance("Admin - Suspend User", function (needs) {
await click(".dialog-footer .btn-default"); await click(".dialog-footer .btn-default");
assert.dom(".suspend-user-modal").exists(); assert.dom(".suspend-user-modal").exists();
assert.strictEqual( assert.dom(".suspend-message").hasValue("this is an email reason why");
query(".suspend-message").value,
"this is an email reason why"
);
await click(".d-modal-cancel"); await click(".d-modal-cancel");
assert.dom(".dialog-body").exists(); assert.dom(".dialog-body").exists();

View File

@ -67,30 +67,22 @@ acceptance("Composer - editor mentions", function (needs) {
await visit("/"); await visit("/");
await click("#create-topic"); await click("#create-topic");
const editor = query(".d-editor-input"); await simulateKeys(query(".d-editor-input"), "abc @u\r");
await simulateKeys(editor, "abc @u\r"); assert
.dom(".d-editor-input")
assert.strictEqual( .hasValue("abc @user ", "replaces mention correctly");
editor.value,
"abc @user ",
"should replace mention correctly"
);
}); });
test("selecting user mentions after deleting characters", async function (assert) { test("selecting user mentions after deleting characters", async function (assert) {
await visit("/"); await visit("/");
await click("#create-topic"); await click("#create-topic");
const editor = query(".d-editor-input"); await simulateKeys(query(".d-editor-input"), "abc @user a\b\b\r");
await simulateKeys(editor, "abc @user a\b\b\r"); assert
.dom(".d-editor-input")
assert.strictEqual( .hasValue("abc @user ", "replaces mention correctly");
editor.value,
"abc @user ",
"should replace mention correctly"
);
}); });
test("selecting user mentions after deleting characters mid sentence", async function (assert) { test("selecting user mentions after deleting characters mid sentence", async function (assert) {
@ -103,11 +95,9 @@ acceptance("Composer - editor mentions", function (needs) {
await setCaretPosition(editor, 9); await setCaretPosition(editor, 9);
await simulateKeys(editor, "\b\b\r"); await simulateKeys(editor, "\b\b\r");
assert.strictEqual( assert
editor.value, .dom(".d-editor-input")
"abc @user 123", .hasValue("abc @user 123", "replaces mention correctly");
"should replace mention correctly"
);
}); });
test("shows status on search results when mentioning a user", async function (assert) { test("shows status on search results when mentioning a user", async function (assert) {

View File

@ -1,6 +1,6 @@
import { click, fillIn, visit } from "@ember/test-helpers"; import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Composer - Image Grid", function (needs) { acceptance("Composer - Image Grid", function (needs) {
needs.user(); needs.user();
@ -30,8 +30,9 @@ acceptance("Composer - Image Grid", function (needs) {
".button-wrapper[data-image-index='0'] .wrap-image-grid-button" ".button-wrapper[data-image-index='0'] .wrap-image-grid-button"
); );
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
`[grid]\n${uploads.join("\n")}\n[/grid]`, `[grid]\n${uploads.join("\n")}\n[/grid]`,
"Image grid toggles on" "Image grid toggles on"
); );
@ -40,11 +41,9 @@ acceptance("Composer - Image Grid", function (needs) {
".button-wrapper[data-image-index='0'] .wrap-image-grid-button" ".button-wrapper[data-image-index='0'] .wrap-image-grid-button"
); );
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
uploads.join("\n"), .hasValue(uploads.join("\n"), "Image grid toggles off");
"Image grid toggles off"
);
const multipleImages = `![zorro|10x10](upload://zorro.png) ![z2|20x20](upload://zorrito.png)\nand a second group of images\n\n${uploads.join( const multipleImages = `![zorro|10x10](upload://zorro.png) ![z2|20x20](upload://zorrito.png)\nand a second group of images\n\n${uploads.join(
"\n" "\n"
@ -53,8 +52,7 @@ acceptance("Composer - Image Grid", function (needs) {
await click(".image-wrapper:first-child .wrap-image-grid-button"); await click(".image-wrapper:first-child .wrap-image-grid-button");
assert.strictEqual( assert.dom(".d-editor-input").hasValue(
query(".d-editor-input").value,
`[grid]![zorro|10x10](upload://zorro.png) ![z2|20x20](upload://zorrito.png)[/grid] `[grid]![zorro|10x10](upload://zorro.png) ![z2|20x20](upload://zorrito.png)[/grid]
and a second group of images and a second group of images
@ -66,11 +64,9 @@ and a second group of images
await click(".image-wrapper:nth-of-type(1) .wrap-image-grid-button"); await click(".image-wrapper:nth-of-type(1) .wrap-image-grid-button");
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
multipleImages, .hasValue(multipleImages, "First image grid toggles off");
"First image grid toggles off"
);
// Second group of images is in paragraph 2 // Second group of images is in paragraph 2
assert assert
@ -83,8 +79,7 @@ and a second group of images
await click(".d-editor-preview p:nth-child(2) .wrap-image-grid-button"); await click(".d-editor-preview p:nth-child(2) .wrap-image-grid-button");
assert.strictEqual( assert.dom(".d-editor-input").hasValue(
query(".d-editor-input").value,
`![zorro|10x10](upload://zorro.png) ![z2|20x20](upload://zorrito.png) `![zorro|10x10](upload://zorro.png) ![z2|20x20](upload://zorrito.png)
and a second group of images and a second group of images

View File

@ -26,11 +26,9 @@ acceptance("Composer - Image Preview", function (needs) {
}); });
const assertImageResized = (assert, uploads) => { const assertImageResized = (assert, uploads) => {
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
uploads.join("\n"), .hasValue(uploads.join("\n"), "resizes uploaded image");
"it resizes uploaded image"
);
}; };
test("Image resizing buttons", async function (assert) { test("Image resizing buttons", async function (assert) {
@ -337,11 +335,9 @@ acceptance("Composer - Image Preview", function (needs) {
//click on the remove button of the first image //click on the remove button of the first image
await click(".button-wrapper[data-image-index='0'] .delete-image-button"); await click(".button-wrapper[data-image-index='0'] .delete-image-button");
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
uploads.join("\n"), .hasValue(uploads.join("\n"), "Image should be removed from the editor");
"Image should be removed from the editor"
);
assert.false( assert.false(
query(".d-editor-input").value.includes("image_example_0"), query(".d-editor-input").value.includes("image_example_0"),
@ -395,8 +391,9 @@ acceptance("Composer - Image Preview - Plugin API", function (needs) {
await click(".custom-button-class"); await click(".custom-button-class");
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
"custom button change", "custom button change",
"The custom button changes the editor input" "The custom button changes the editor input"
); );

View File

@ -212,8 +212,9 @@ acceptance("Composer", function (needs) {
await triggerKeyEvent(textarea, "keydown", "B", metaModifier); await triggerKeyEvent(textarea, "keydown", "B", metaModifier);
const example = i18n(`composer.bold_text`); const example = i18n(`composer.bold_text`);
assert.strictEqual( assert
query("#reply-control .d-editor-input").value.trim(), .dom("#reply-control .d-editor-input")
.hasValue(
`this is the *content* of a post**${example}**`, `this is the *content* of a post**${example}**`,
"supports keyboard shortcuts" "supports keyboard shortcuts"
); );
@ -349,8 +350,9 @@ acceptance("Composer", function (needs) {
await click(".d-modal__footer button.keep-editing"); await click(".d-modal__footer button.keep-editing");
assert.dom(".discard-draft-modal.modal").doesNotExist(); assert.dom(".discard-draft-modal.modal").doesNotExist();
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
"this is the content of my reply", "this is the content of my reply",
"composer does not switch when using Keep Editing button" "composer does not switch when using Keep Editing button"
); );
@ -360,8 +362,9 @@ acceptance("Composer", function (needs) {
await click(".d-modal__footer button.discard-draft"); await click(".d-modal__footer button.discard-draft");
assert.dom(".discard-draft-modal.modal").doesNotExist(); assert.dom(".discard-draft-modal.modal").doesNotExist();
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
query(".topic-post:nth-of-type(1) .cooked > p").innerText, query(".topic-post:nth-of-type(1) .cooked > p").innerText,
"composer has contents of post to be edited" "composer has contents of post to be edited"
); );
@ -380,8 +383,9 @@ acceptance("Composer", function (needs) {
await click(".d-modal__footer button.keep-editing"); await click(".d-modal__footer button.keep-editing");
assert.dom(".discard-draft-modal.modal").doesNotExist(); assert.dom(".discard-draft-modal.modal").doesNotExist();
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
"this is the content of my reply", "this is the content of my reply",
"composer does not switch when using Keep Editing button" "composer does not switch when using Keep Editing button"
); );
@ -434,11 +438,9 @@ acceptance("Composer", function (needs) {
await click(".d-modal__footer button.discard-draft"); await click(".d-modal__footer button.discard-draft");
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
"", .hasNoValue("discards draft and reset composer textarea");
"discards draft and reset composer textarea"
);
}); });
test("Create an enqueued Reply", async function (assert) { test("Create an enqueued Reply", async function (assert) {
@ -486,8 +488,10 @@ acceptance("Composer", function (needs) {
await click(".topic-post:nth-of-type(1) button.show-more-actions"); await click(".topic-post:nth-of-type(1) button.show-more-actions");
await click(".topic-post:nth-of-type(1) button.edit"); await click(".topic-post:nth-of-type(1) button.edit");
assert.true( assert
query(".d-editor-input").value.startsWith("Any plans to support"), .dom(".d-editor-input")
.hasValue(
/^Any plans to support/,
"populates the input with the post text" "populates the input with the post text"
); );
@ -538,13 +542,17 @@ acceptance("Composer", function (needs) {
await visit("/t/this-is-a-test-topic/9"); await visit("/t/this-is-a-test-topic/9");
await click(".topic-post:nth-of-type(1) button.edit"); await click(".topic-post:nth-of-type(1) button.edit");
assert.true( assert
query(".d-editor-input").value.startsWith("This is the first post."), .dom(".d-editor-input")
.hasValue(
/^This is the first post\./,
"populates the input with the post text" "populates the input with the post text"
); );
await click(".topic-post:nth-of-type(2) button.edit"); await click(".topic-post:nth-of-type(2) button.edit");
assert.true( assert
query(".d-editor-input").value.startsWith("This is the second post."), .dom(".d-editor-input")
.hasValue(
/^This is the second post\./,
"populates the input with the post text" "populates the input with the post text"
); );
}); });
@ -560,8 +568,10 @@ acceptance("Composer", function (needs) {
.exists("pops up a confirmation dialog"); .exists("pops up a confirmation dialog");
await click(".d-modal__footer button.discard-draft"); await click(".d-modal__footer button.discard-draft");
assert.true( assert
query(".d-editor-input").value.startsWith("This is the second post."), .dom(".d-editor-input")
.hasValue(
/^This is the second post\./,
"populates the input with the post text" "populates the input with the post text"
); );
}); });
@ -570,15 +580,19 @@ acceptance("Composer", function (needs) {
await visit("/t/this-is-a-test-topic/9"); await visit("/t/this-is-a-test-topic/9");
await click(".topic-post:nth-of-type(1) button.edit"); await click(".topic-post:nth-of-type(1) button.edit");
assert.true( assert
query(".d-editor-input").value.startsWith("This is the first post."), .dom(".d-editor-input")
.hasValue(
/^This is the first post\./,
"populates the input with the post text" "populates the input with the post text"
); );
await click(".topic-post:nth-of-type(1) button.reply"); await click(".topic-post:nth-of-type(1) button.reply");
assert.strictEqual(query(".d-editor-input").value, "", "clears the input"); assert.dom(".d-editor-input").hasNoValue("clears the input");
await click(".topic-post:nth-of-type(1) button.edit"); await click(".topic-post:nth-of-type(1) button.edit");
assert.true( assert
query(".d-editor-input").value.startsWith("This is the first post."), .dom(".d-editor-input")
.hasValue(
/^This is the first post\./,
"populates the input with the post text" "populates the input with the post text"
); );
}); });
@ -756,8 +770,10 @@ acceptance("Composer", function (needs) {
"has keep editing button" "has keep editing button"
); );
await click(".d-modal__footer button.discard-draft"); await click(".d-modal__footer button.discard-draft");
assert.true( assert
query(".d-editor-input").value.startsWith("This is the second post."), .dom(".d-editor-input")
.hasValue(
/^This is the second post\./,
"populates the input with the post text" "populates the input with the post text"
); );
}); });
@ -787,11 +803,7 @@ acceptance("Composer", function (needs) {
"has keep editing button" "has keep editing button"
); );
await click(".d-modal__footer button.save-draft"); await click(".d-modal__footer button.save-draft");
assert.strictEqual( assert.dom(".d-editor-input").hasNoValue("clears the composer input");
query(".d-editor-input").value,
"",
"clears the composer input"
);
}); });
test("Checks for existing draft", async function (assert) { test("Checks for existing draft", async function (assert) {
@ -1129,10 +1141,7 @@ acceptance("Composer - Focus Open and Closed", function (needs) {
await settled(); await settled();
assert.dom(".d-editor-input").isFocused("composer is open and focused"); assert.dom(".d-editor-input").isFocused("composer is open and focused");
assert.strictEqual( assert.dom("textarea.d-editor-input").hasValue("this is appended");
query("textarea.d-editor-input").value.trim(),
"this is appended"
);
}); });
test("Focusing a composer which is already open", async function (assert) { test("Focusing a composer which is already open", async function (assert) {
@ -1155,10 +1164,9 @@ acceptance("Composer - Focus Open and Closed", function (needs) {
await settled(); await settled();
assert.dom(".d-editor-input").isFocused("composer is open and focused"); assert.dom(".d-editor-input").isFocused("composer is open and focused");
assert.strictEqual( assert
query("textarea.d-editor-input").value.trim(), .dom("textarea.d-editor-input")
"this is some appended text" .hasValue("this is some appended text");
);
}); });
test("Focusing a composer which is not open that has a draft", async function (assert) { test("Focusing a composer which is not open that has a draft", async function (assert) {
@ -1173,10 +1181,9 @@ acceptance("Composer - Focus Open and Closed", function (needs) {
await settled(); await settled();
assert.dom(".d-editor-input").isFocused("composer is open and focused"); assert.dom(".d-editor-input").isFocused("composer is open and focused");
assert.strictEqual( assert
query("textarea.d-editor-input").value.trim(), .dom("textarea.d-editor-input")
"This is a dirty reply\n\nthis is some appended text" .hasValue("This is a dirty reply\n\nthis is some appended text");
);
}); });
}); });
@ -1350,7 +1357,9 @@ acceptance("composer buttons API", function (needs) {
Object.assign({ altKey: true }, metaModifier) Object.assign({ altKey: true }, metaModifier)
); );
assert.strictEqual(editor.value, "hello **the** world", "adds the bold"); assert
.dom(".d-editor-input")
.hasValue("hello **the** world", "adds the bold");
const dropdown = selectKit(".toolbar-popup-menu-options"); const dropdown = selectKit(".toolbar-popup-menu-options");
await dropdown.expand(); await dropdown.expand();

View File

@ -1,6 +1,6 @@
import { click, fillIn, visit } from "@ember/test-helpers"; import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Composer topic featured links", function (needs) { acceptance("Composer topic featured links", function (needs) {
needs.user(); needs.user();
@ -20,11 +20,9 @@ acceptance("Composer topic featured links", function (needs) {
assert assert
.dom(".d-editor-textarea-wrapper .popup-tip.good") .dom(".d-editor-textarea-wrapper .popup-tip.good")
.exists("the body is now good"); .exists("the body is now good");
assert.strictEqual( assert
query(".title-input input").value, .dom(".title-input input")
"An interesting article", .hasValue("An interesting article", "title is from the oneboxed article");
"title is from the oneboxed article"
);
}); });
test("onebox result doesn't include a title", async function (assert) { test("onebox result doesn't include a title", async function (assert) {
@ -37,19 +35,18 @@ acceptance("Composer topic featured links", function (needs) {
assert assert
.dom(".d-editor-textarea-wrapper .popup-tip.good") .dom(".d-editor-textarea-wrapper .popup-tip.good")
.exists("the body is now good"); .exists("the body is now good");
assert.strictEqual( assert
query(".title-input input").value, .dom(".title-input input")
"http://www.example.com/no-title.html", .hasValue("http://www.example.com/no-title.html", "title is unchanged");
"title is unchanged"
);
}); });
test("YouTube onebox with title", async function (assert) { test("YouTube onebox with title", async function (assert) {
await visit("/"); await visit("/");
await click("#create-topic"); await click("#create-topic");
await fillIn("#reply-title", "https://www.youtube.com/watch?v=dQw4w9WgXcQ"); await fillIn("#reply-title", "https://www.youtube.com/watch?v=dQw4w9WgXcQ");
assert.strictEqual( assert
query(".title-input input").value, .dom(".title-input input")
.hasValue(
"Rick Astley - Never Gonna Give You Up (Video)", "Rick Astley - Never Gonna Give You Up (Video)",
"title is from the oneboxed article" "title is from the oneboxed article"
); );
@ -65,8 +62,9 @@ acceptance("Composer topic featured links", function (needs) {
assert assert
.dom(".d-editor-textarea-wrapper .popup-tip.good") .dom(".d-editor-textarea-wrapper .popup-tip.good")
.exists("link is pasted into body"); .exists("link is pasted into body");
assert.strictEqual( assert
query(".title-input input").value, .dom(".title-input input")
.hasValue(
"http://www.example.com/nope-onebox.html", "http://www.example.com/nope-onebox.html",
"title is unchanged" "title is unchanged"
); );
@ -80,16 +78,8 @@ acceptance("Composer topic featured links", function (needs) {
assert assert
.dom(".d-editor-preview") .dom(".d-editor-preview")
.doesNotIncludeHtml("onebox", "onebox preview doesn't show"); .doesNotIncludeHtml("onebox", "onebox preview doesn't show");
assert.strictEqual( assert.dom(".d-editor-input").hasNoValue("link isn't put into the post");
query(".d-editor-input").value.length, assert.dom(".title-input input").hasValue(title, "title is unchanged");
0,
"link isn't put into the post"
);
assert.strictEqual(
query(".title-input input").value,
title,
"title is unchanged"
);
}); });
test("link is longer than max title length", async function (assert) { test("link is longer than max title length", async function (assert) {
@ -105,11 +95,9 @@ acceptance("Composer topic featured links", function (needs) {
assert assert
.dom(".d-editor-textarea-wrapper .popup-tip.good") .dom(".d-editor-textarea-wrapper .popup-tip.good")
.exists("the body is now good"); .exists("the body is now good");
assert.strictEqual( assert
query(".title-input input").value, .dom(".title-input input")
"An interesting article", .hasValue("An interesting article", "title is from the oneboxed article");
"title is from the oneboxed article"
);
}); });
test("onebox with title but extra words in title field", async function (assert) { test("onebox with title but extra words in title field", async function (assert) {
@ -119,13 +107,10 @@ acceptance("Composer topic featured links", function (needs) {
assert assert
.dom(".d-editor-preview") .dom(".d-editor-preview")
.doesNotIncludeHtml("onebox", "onebox preview doesn't show"); .doesNotIncludeHtml("onebox", "onebox preview doesn't show");
assert.strictEqual( assert.dom(".d-editor-input").hasNoValue("link isn't put into the post");
query(".d-editor-input").value.length, assert
0, .dom(".title-input input")
"link isn't put into the post" .hasValue(
);
assert.strictEqual(
query(".title-input input").value,
"http://www.example.com/has-title.html test", "http://www.example.com/has-title.html test",
"title is unchanged" "title is unchanged"
); );
@ -144,7 +129,7 @@ acceptance("Composer topic featured links", function (needs) {
assert assert
.dom(".d-editor-textarea-wrapper .popup-tip.good") .dom(".d-editor-textarea-wrapper .popup-tip.good")
.exists("the body is now good"); .exists("the body is now good");
assert.blank(query(".title-input input").value, "title is blank"); assert.dom(".title-input input").hasNoValue("title is blank");
}); });
}); });
@ -175,8 +160,9 @@ acceptance(
assert assert
.dom(".d-editor-textarea-wrapper .popup-tip.good") .dom(".d-editor-textarea-wrapper .popup-tip.good")
.exists("the body is now good"); .exists("the body is now good");
assert.strictEqual( assert
query(".title-input input").value, .dom(".title-input input")
.hasValue(
"An interesting article", "An interesting article",
"title is from the oneboxed article" "title is from the oneboxed article"
); );

View File

@ -97,18 +97,18 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) {
appEvents.on("composer:all-uploads-complete", async () => { appEvents.on("composer:all-uploads-complete", async () => {
await settled(); await settled();
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
"The image:\n![avatar.PNG|690x320](upload://yoj8pf9DdIeHRRULyw7i57GAYdz.jpeg)\n" "The image:\n![avatar.PNG|690x320](upload://yoj8pf9DdIeHRRULyw7i57GAYdz.jpeg)\n"
); );
done(); done();
}); });
appEvents.on("composer:upload-started", () => { appEvents.on("composer:upload-started", () => {
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
"The image:\n[Uploading: avatar.png…]()\n" .hasValue("The image:\n[Uploading: avatar.png…]()\n");
);
}); });
const image = createFile("avatar.png"); const image = createFile("avatar.png");
@ -128,8 +128,9 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) {
appEvents.on("composer:all-uploads-complete", async () => { appEvents.on("composer:all-uploads-complete", async () => {
await settled(); await settled();
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
"The image:\n![avatar.PNG|690x320](upload://yoj8pf9DdIeHRRULyw7i57GAYdz.jpeg)\n![avatar2.PNG|690x320](upload://sdfljsdfgjlkwg4328.jpeg)\n" "The image:\n![avatar.PNG|690x320](upload://yoj8pf9DdIeHRRULyw7i57GAYdz.jpeg)\n![avatar2.PNG|690x320](upload://sdfljsdfgjlkwg4328.jpeg)\n"
); );
done(); done();
@ -166,18 +167,18 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) {
appEvents.on("composer:all-uploads-complete", async () => { appEvents.on("composer:all-uploads-complete", async () => {
await settled(); await settled();
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
"The image:\n![avatar.PNG|690x320](upload://yoj8pf9DdIeHRRULyw7i57GAYdz.jpeg)\n" "The image:\n![avatar.PNG|690x320](upload://yoj8pf9DdIeHRRULyw7i57GAYdz.jpeg)\n"
); );
done(); done();
}); });
appEvents.on("composer:upload-started", () => { appEvents.on("composer:upload-started", () => {
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
"The image:\n[Uploading: avatar.png…]()\n" .hasValue("The image:\n[Uploading: avatar.png…]()\n");
);
}); });
const image = createFile("avatar.png"); const image = createFile("avatar.png");
@ -250,19 +251,18 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) {
uploadStarted++; uploadStarted++;
if (uploadStarted === 2) { if (uploadStarted === 2) {
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
"The image:\n[Uploading: avatar.png…]()\n[Uploading: avatar2.png…]()\n", "The image:\n[Uploading: avatar.png…]()\n[Uploading: avatar2.png…]()\n",
"it should show the upload placeholders when the upload starts" "it should show the upload placeholders when the upload starts"
); );
} }
}); });
appEvents.on("composer:uploads-cancelled", () => { appEvents.on("composer:uploads-cancelled", () => {
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
"The image:\n", .hasValue("The image:\n", "it should clear the cancelled placeholders");
"it should clear the cancelled placeholders"
);
}); });
await new Promise(function (resolve) { await new Promise(function (resolve) {
@ -282,16 +282,16 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) {
const done = assert.async(); const done = assert.async();
appEvents.on("composer:upload-started", () => { appEvents.on("composer:upload-started", () => {
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
"The image:\n[Uploading: avatar.png…]()\n" .hasValue("The image:\n[Uploading: avatar.png…]()\n");
);
}); });
appEvents.on("composer:all-uploads-complete", async () => { appEvents.on("composer:all-uploads-complete", async () => {
await settled(); await settled();
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
"The image:\n![avatar.PNG|690x320](upload://yoj8pf9DdIeHRRULyw7i57GAYdz.jpeg)\n" "The image:\n![avatar.PNG|690x320](upload://yoj8pf9DdIeHRRULyw7i57GAYdz.jpeg)\n"
); );
done(); done();
@ -313,16 +313,18 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) {
const done = assert.async(); const done = assert.async();
appEvents.on("composer:upload-started", () => { appEvents.on("composer:upload-started", () => {
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
"The image:\n[Uploading: avatar.png…]()\n Text after the image." "The image:\n[Uploading: avatar.png…]()\n Text after the image."
); );
}); });
appEvents.on("composer:all-uploads-complete", async () => { appEvents.on("composer:all-uploads-complete", async () => {
await settled(); await settled();
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
"The image:\n![avatar.PNG|690x320](upload://yoj8pf9DdIeHRRULyw7i57GAYdz.jpeg)\n Text after the image." "The image:\n![avatar.PNG|690x320](upload://yoj8pf9DdIeHRRULyw7i57GAYdz.jpeg)\n Text after the image."
); );
done(); done();
@ -347,16 +349,18 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) {
const done = assert.async(); const done = assert.async();
appEvents.on("composer:upload-started", () => { appEvents.on("composer:upload-started", () => {
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
"The image:\n[Uploading: avatar.png…]()\n Text after the image." "The image:\n[Uploading: avatar.png…]()\n Text after the image."
); );
}); });
appEvents.on("composer:all-uploads-complete", async () => { appEvents.on("composer:all-uploads-complete", async () => {
await settled(); await settled();
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
"The image:\n![avatar.PNG|690x320](upload://yoj8pf9DdIeHRRULyw7i57GAYdz.jpeg)\n Text after the image." "The image:\n![avatar.PNG|690x320](upload://yoj8pf9DdIeHRRULyw7i57GAYdz.jpeg)\n Text after the image."
); );
done(); done();
@ -373,16 +377,14 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) {
const done = assert.async(); const done = assert.async();
appEvents.on("composer:upload-started", () => { appEvents.on("composer:upload-started", () => {
assert.strictEqual( assert.dom(".d-editor-input").hasValue("[Uploading: avatar.png…]()\n");
query(".d-editor-input").value,
"[Uploading: avatar.png…]()\n"
);
}); });
appEvents.on("composer:all-uploads-complete", async () => { appEvents.on("composer:all-uploads-complete", async () => {
await settled(); await settled();
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
"![avatar.PNG|690x320](upload://yoj8pf9DdIeHRRULyw7i57GAYdz.jpeg)\n" "![avatar.PNG|690x320](upload://yoj8pf9DdIeHRRULyw7i57GAYdz.jpeg)\n"
); );
done(); done();
@ -400,16 +402,16 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) {
const done = assert.async(); const done = assert.async();
appEvents.on("composer:upload-started", () => { appEvents.on("composer:upload-started", () => {
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
"The image:\n[Uploading: avatar.png…]()\n" .hasValue("The image:\n[Uploading: avatar.png…]()\n");
);
}); });
appEvents.on("composer:all-uploads-complete", async () => { appEvents.on("composer:all-uploads-complete", async () => {
await settled(); await settled();
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
"The image:\n![avatar.PNG|690x320](upload://yoj8pf9DdIeHRRULyw7i57GAYdz.jpeg)\n" "The image:\n![avatar.PNG|690x320](upload://yoj8pf9DdIeHRRULyw7i57GAYdz.jpeg)\n"
); );
done(); done();
@ -464,8 +466,9 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) {
}); });
await settled(); await settled();
assert.strictEqual( assert
inputElement.value, .dom(inputElement)
.hasValue(
"||a|b|\n|---|---|---|\n|1|2|3|\n", "||a|b|\n|---|---|---|\n|1|2|3|\n",
"only the plain text table is pasted" "only the plain text table is pasted"
); );

View File

@ -1,6 +1,6 @@
import { click, fillIn, triggerKeyEvent, visit } from "@ember/test-helpers"; import { click, fillIn, triggerKeyEvent, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("EmojiPicker", function (needs) { acceptance("EmojiPicker", function (needs) {
needs.user(); needs.user();
@ -39,10 +39,11 @@ acceptance("EmojiPicker", function (needs) {
await click("button.emoji.btn"); await click("button.emoji.btn");
await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); await click(".emoji-picker-emoji-area img.emoji[title='grinning']");
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
":grinning:", ":grinning:",
"it adds the emoji code in the editor when selected" "adds the emoji code in the editor when selected"
); );
}); });
@ -54,20 +55,22 @@ acceptance("EmojiPicker", function (needs) {
await fillIn(".d-editor-input", "This is a test input"); await fillIn(".d-editor-input", "This is a test input");
await click("button.emoji.btn"); await click("button.emoji.btn");
await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); await click(".emoji-picker-emoji-area img.emoji[title='grinning']");
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
"This is a test input :grinning:", "This is a test input :grinning:",
"it adds the emoji code and a leading whitespace when there is text" "adds the emoji code and a leading whitespace when there is text"
); );
// Whitespace should not be added on whitespace // Whitespace should not be added on whitespace
await fillIn(".d-editor-input", "This is a test input "); await fillIn(".d-editor-input", "This is a test input ");
await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); await click(".emoji-picker-emoji-area img.emoji[title='grinning']");
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
"This is a test input :grinning:", "This is a test input :grinning:",
"it adds the emoji code and no leading whitespace when user already entered whitespace" "adds the emoji code and no leading whitespace when user already entered whitespace"
); );
}); });
@ -207,8 +210,9 @@ acceptance("EmojiPicker", function (needs) {
await triggerKeyEvent(document.activeElement, "keydown", "ArrowRight"); await triggerKeyEvent(document.activeElement, "keydown", "ArrowRight");
await triggerKeyEvent(document.activeElement, "keydown", "Enter"); await triggerKeyEvent(document.activeElement, "keydown", "Enter");
assert.strictEqual( assert
document.querySelector(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
":smiley:", ":smiley:",
"Pressing enter inserts the emoji markup in the composer" "Pressing enter inserts the emoji markup in the composer"
); );

View File

@ -2,7 +2,7 @@ import { click, currentRouteName, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { GROUP_SMTP_SSL_MODES } from "discourse/lib/constants"; import { GROUP_SMTP_SSL_MODES } from "discourse/lib/constants";
import formKit from "discourse/tests/helpers/form-kit-helper"; import formKit from "discourse/tests/helpers/form-kit-helper";
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 selectKit from "discourse/tests/helpers/select-kit-helper";
import { i18n } from "discourse-i18n"; import { i18n } from "discourse-i18n";
@ -151,16 +151,12 @@ acceptance(
); );
await click("#prefill_imap_gmail"); await click("#prefill_imap_gmail");
assert.strictEqual( assert
query("input[name='imap_server']").value, .dom("input[name='imap_server']")
"imap.gmail.com", .hasValue("imap.gmail.com", "prefills IMAP server settings for gmail");
"prefills IMAP server settings for gmail" assert
); .dom("input[name='imap_port']")
assert.strictEqual( .hasValue("993", "prefills IMAP port settings for gmail");
query("input[name='imap_port']").value,
"993",
"prefills IMAP port settings for gmail"
);
assert assert
.dom("#enable_ssl_imap") .dom("#enable_ssl_imap")
.isChecked("prefills IMAP ssl settings for gmail"); .isChecked("prefills IMAP ssl settings for gmail");
@ -292,16 +288,12 @@ acceptance(
"SMTP ssl mode is prefilled" "SMTP ssl mode is prefilled"
); );
assert.strictEqual( assert
query("[name='imap_server']").value, .dom("[name='imap_server']")
"imap.gmail.com", .hasValue("imap.gmail.com", "imap server is prefilled");
"imap server is prefilled" assert
); .dom("[name='imap_port']")
assert.strictEqual( .hasValue("993", "imap port is prefilled");
query("[name='imap_port']").value,
"993",
"imap port is prefilled"
);
assert.strictEqual( assert.strictEqual(
selectKit("#imap_mailbox").header().value(), selectKit("#imap_mailbox").header().value(),
"INBOX", "INBOX",

View File

@ -1,6 +1,6 @@
import { click, fillIn, visit } from "@ember/test-helpers"; import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
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 selectKit from "discourse/tests/helpers/select-kit-helper";
import { i18n } from "discourse-i18n"; import { i18n } from "discourse-i18n";
@ -186,10 +186,9 @@ acceptance("Group - Authenticated", function (needs) {
i18n("groups.membership_request.title", { group_name: "Macdonald" }) i18n("groups.membership_request.title", { group_name: "Macdonald" })
); );
assert.strictEqual( assert
query(".request-group-membership-form textarea").value, .dom(".request-group-membership-form textarea")
"Please add me" .hasValue("Please add me");
);
await click(".d-modal__footer .btn-primary"); await click(".d-modal__footer .btn-primary");

View File

@ -1,6 +1,6 @@
import { visit } from "@ember/test-helpers"; import { visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
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 selectKit from "discourse/tests/helpers/select-kit-helper";
acceptance("New Message - Anonymous", function () { acceptance("New Message - Anonymous", function () {
@ -22,16 +22,12 @@ acceptance("New Message - Authenticated", function (needs) {
); );
assert.dom(".composer-fields").exists("opens the composer"); assert.dom(".composer-fields").exists("opens the composer");
assert.strictEqual( assert
query("#reply-title").value.trim(), .dom("#reply-title")
"message title", .hasValue("message title", "pre-fills message title");
"it pre-fills message title" assert
); .dom(".d-editor-input")
assert.strictEqual( .hasValue("message body", "pre-fills message body");
query(".d-editor-input").value.trim(),
"message body",
"it pre-fills message body"
);
const privateMessageUsers = selectKit("#private-message-users"); const privateMessageUsers = selectKit("#private-message-users");
assert.strictEqual( assert.strictEqual(

View File

@ -1,6 +1,6 @@
import { click, fillIn, visit } from "@ember/test-helpers"; import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Search - Mobile", function (needs) { acceptance("Search - Mobile", function (needs) {
needs.mobileView(); needs.mobileView();
@ -35,10 +35,11 @@ acceptance("Search - Mobile", function (needs) {
await click("#search-button"); await click("#search-button");
assert.strictEqual( assert
query("input.full-page-search").value, .dom("input.full-page-search")
.hasValue(
"discourse", "discourse",
"it does not reset input when hitting search icon again" "does not reset input when hitting search icon again"
); );
}); });
}); });

View File

@ -83,8 +83,9 @@ acceptance("Search - Anonymous", function (needs) {
await click(document.activeElement); await click(document.activeElement);
await click(".show-advanced-search"); await click(".show-advanced-search");
assert.strictEqual( assert
query(".full-page-search").value, .dom(".full-page-search")
.hasValue(
"dev", "dev",
"goes to full search page and preserves the search term" "goes to full search page and preserves the search term"
); );
@ -247,8 +248,9 @@ acceptance("Search - Anonymous", function (needs) {
await click(document.activeElement); await click(document.activeElement);
await click(".show-advanced-search"); await click(".show-advanced-search");
assert.strictEqual( assert
query(".full-page-search").value, .dom(".full-page-search")
.hasValue(
"proper topic:280", "proper topic:280",
"goes to full search page and preserves search term + context" "goes to full search page and preserves search term + context"
); );
@ -621,10 +623,9 @@ acceptance("Search - Authenticated", function (needs) {
await triggerKeyEvent(document.activeElement, "keyup", "ArrowDown"); await triggerKeyEvent(document.activeElement, "keyup", "ArrowDown");
await triggerKeyEvent(document.activeElement, "keydown", 65); // maps to lowercase a await triggerKeyEvent(document.activeElement, "keydown", 65); // maps to lowercase a
assert.true( assert
query(".d-editor-input").value.includes("a link"), .dom(".d-editor-input")
"still has the original composer content" .hasValue(/a link/, "still has the original composer content");
);
assert.true( assert.true(
query(".d-editor-input").value.includes( query(".d-editor-input").value.includes(
@ -1196,10 +1197,7 @@ acceptance("Search - assistant", function (needs) {
await click(`${firstCategory} .badge-category__name`); await click(`${firstCategory} .badge-category__name`);
assert.strictEqual( assert.dom("#search-term").hasValue(`sam #${firstCategoryName}`);
query("#search-term").value,
`sam #${firstCategoryName}`
);
}); });
test("topic results - soft loads the topic results after closing the search menu", async function (assert) { test("topic results - soft loads the topic results after closing the search menu", async function (assert) {

View File

@ -2,7 +2,6 @@ import { click, currentURL, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { import {
acceptance, acceptance,
query,
queryAll, queryAll,
updateCurrentUser, updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
@ -474,13 +473,12 @@ acceptance("Tag info", function (needs) {
assert.dom(".tag-info .tag-name").exists("show tag"); assert.dom(".tag-info .tag-name").exists("show tag");
await click(".edit-tag"); await click(".edit-tag");
assert.strictEqual( assert
query("#edit-name").value, .dom("#edit-name")
"happy-monkey", .hasValue("happy-monkey", "displays original tag name");
"displays original tag name" assert
); .dom("#edit-description")
assert.strictEqual( .hasValue(
query("#edit-description").value,
"happy monkey description", "happy monkey description",
"displays original tag description" "displays original tag description"
); );

View File

@ -56,9 +56,10 @@ acceptance("Topic - Quote button - logged in", function (needs) {
await selectText("#post_3 aside.onebox p"); await selectText("#post_3 aside.onebox p");
await click(".insert-quote"); await click(".insert-quote");
assert.strictEqual( assert
query(".d-editor-input").value.trim(), .dom(".d-editor-input")
'[quote="group_moderator, post:3, topic:2480"]\nhttps://example.com/57350945\n[/quote]', .hasValue(
'[quote="group_moderator, post:3, topic:2480"]\nhttps://example.com/57350945\n[/quote]\n\n',
"quote only contains a link" "quote only contains a link"
); );
}); });
@ -145,9 +146,8 @@ acceptance("Topic - Quote button - keyboard shortcut", function (needs) {
await triggerKeyEvent(document, "keypress", "Q"); await triggerKeyEvent(document, "keypress", "Q");
assert.dom(".d-editor-input").exists("the editor is open"); assert.dom(".d-editor-input").exists("the editor is open");
assert.true( assert
query(".d-editor-input").value.includes("Any plans to support"), .dom(".d-editor-input")
"editor includes selected text" .hasValue(/Any plans to support/, "editor includes selected text");
);
}); });
}); });

View File

@ -48,9 +48,10 @@ acceptance("Topic", function (needs) {
assert.dom(".d-editor-input").exists("the composer input is visible"); assert.dom(".d-editor-input").exists("the composer input is visible");
assert.strictEqual( assert
query(".d-editor-input").value.trim(), .dom(".d-editor-input")
`Continuing the discussion from [Internationalization / localization](${window.location.origin}/t/internationalization-localization/280):`, .hasValue(
`Continuing the discussion from [Internationalization / localization](${window.location.origin}/t/internationalization-localization/280):\n\n`,
"fills composer with the ring string" "fills composer with the ring string"
); );
assert.strictEqual( assert.strictEqual(
@ -67,9 +68,10 @@ acceptance("Topic", function (needs) {
assert.dom(".d-editor-input").exists("the composer input is visible"); assert.dom(".d-editor-input").exists("the composer input is visible");
assert.strictEqual( assert
query(".d-editor-input").value.trim(), .dom(".d-editor-input")
`Continuing the discussion from [PM for testing](${window.location.origin}/t/pm-for-testing/12):`, .hasValue(
`Continuing the discussion from [PM for testing](${window.location.origin}/t/pm-for-testing/12):\n\n`,
"fills composer with the ring string" "fills composer with the ring string"
); );

View File

@ -1,7 +1,7 @@
import { click, visit } from "@ember/test-helpers"; import { click, visit } from "@ember/test-helpers";
import { IMAGE_VERSION } from "pretty-text/emoji/version"; import { IMAGE_VERSION } from "pretty-text/emoji/version";
import { test } from "qunit"; import { test } from "qunit";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("User Drafts", function (needs) { acceptance("User Drafts", function (needs) {
needs.user(); needs.user();
@ -30,10 +30,9 @@ acceptance("User Drafts", function (needs) {
assert.dom(".user-stream-item").exists("has drafts"); assert.dom(".user-stream-item").exists("has drafts");
await click(".user-stream-item .resume-draft"); await click(".user-stream-item .resume-draft");
assert.strictEqual( assert
query(".d-editor-input").value.trim(), .dom(".d-editor-input")
"A fun new topic for testing drafts." .hasValue(/A fun new topic for testing drafts./);
);
}); });
test("Stream - has excerpt", async function (assert) { test("Stream - has excerpt", async function (assert) {

View File

@ -34,9 +34,9 @@ module("Integration | Component | date-time-input-range", function (hooks) {
hbs`<DateTimeInputRange @from={{this.state.from}} @to={{this.state.to}} @onChange={{fn (mut this.state)}} />` hbs`<DateTimeInputRange @from={{this.state.from}} @to={{this.state.to}} @onChange={{fn (mut this.state)}} />`
); );
assert.strictEqual(fromDateInput().value, "2019-01-29"); assert.dom(fromDateInput()).hasValue("2019-01-29");
assert.strictEqual(fromTimeInput().dataset.name, "14:45"); assert.strictEqual(fromTimeInput().dataset.name, "14:45");
assert.strictEqual(toDateInput().value, ""); assert.dom(toDateInput()).hasNoValue();
assert.strictEqual(toTimeInput().dataset.name, "--:--"); assert.strictEqual(toTimeInput().dataset.name, "--:--");
await fillIn(toDateInput(), "2019-01-29"); await fillIn(toDateInput(), "2019-01-29");
@ -81,9 +81,9 @@ module("Integration | Component | date-time-input-range", function (hooks) {
hbs`<DateTimeInputRange @from={{this.state.from}} @to={{this.state.to}} @onChange={{fn (mut this.state)}} @timezone="Europe/Paris" />` hbs`<DateTimeInputRange @from={{this.state.from}} @to={{this.state.to}} @onChange={{fn (mut this.state)}} @timezone="Europe/Paris" />`
); );
assert.strictEqual(fromDateInput().value, "2019-01-29"); assert.dom(fromDateInput()).hasValue("2019-01-29");
assert.strictEqual(fromTimeInput().dataset.name, "14:45"); assert.strictEqual(fromTimeInput().dataset.name, "14:45");
assert.strictEqual(toDateInput().value, ""); assert.dom(toDateInput()).hasNoValue();
assert.strictEqual(toTimeInput().dataset.name, "--:--"); assert.strictEqual(toTimeInput().dataset.name, "--:--");
await fillIn(toDateInput(), "2019-01-29"); await fillIn(toDateInput(), "2019-01-29");

View File

@ -26,7 +26,7 @@ module("Integration | Component | date-time-input", function (hooks) {
await render(hbs`<DateTimeInput @date={{this.date}} />`); await render(hbs`<DateTimeInput @date={{this.date}} />`);
assert.strictEqual(dateInput().value, "2019-01-29"); assert.dom(dateInput()).hasValue("2019-01-29");
assert.strictEqual(timeInput().dataset.name, "14:45"); assert.strictEqual(timeInput().dataset.name, "14:45");
}); });

View File

@ -29,21 +29,15 @@ module(
".form-template-field__dropdown option:not(.form-template-field__dropdown-placeholder)" ".form-template-field__dropdown option:not(.form-template-field__dropdown-placeholder)"
); );
assert.strictEqual(dropdown.length, 3, "it has 3 choices"); assert.strictEqual(dropdown.length, 3, "it has 3 choices");
assert.strictEqual( assert
dropdown[0].value, .dom(dropdown[0])
"Choice 1", .hasValue("Choice 1", "has the correct name for choice 1");
"it has the correct name for choice 1" assert
); .dom(dropdown[1])
assert.strictEqual( .hasValue("Choice 2", "has the correct name for choice 2");
dropdown[1].value, assert
"Choice 2", .dom(dropdown[2])
"it has the correct name for choice 2" .hasValue("Choice 3", "has the correct name for choice 3");
);
assert.strictEqual(
dropdown[2].value,
"Choice 3",
"it has the correct name for choice 3"
);
}); });
test("renders a dropdown with choices and attributes", async function (assert) { test("renders a dropdown with choices and attributes", async function (assert) {

View File

@ -30,21 +30,15 @@ module(
".form-template-field__multi-select option:not(.form-template-field__multi-select-placeholder)" ".form-template-field__multi-select option:not(.form-template-field__multi-select-placeholder)"
); );
assert.strictEqual(dropdown.length, 3, "it has 3 choices"); assert.strictEqual(dropdown.length, 3, "it has 3 choices");
assert.strictEqual( assert
dropdown[0].value, .dom(dropdown[0])
"Choice 1", .hasValue("Choice 1", "has the correct name for choice 1");
"it has the correct name for choice 1" assert
); .dom(dropdown[1])
assert.strictEqual( .hasValue("Choice 2", "has the correct name for choice 2");
dropdown[1].value, assert
"Choice 2", .dom(dropdown[2])
"it has the correct name for choice 2" .hasValue("Choice 3", "has the correct name for choice 3");
);
assert.strictEqual(
dropdown[2].value,
"Choice 3",
"it has the correct name for choice 3"
);
}); });
test("renders a multi-select with choices and attributes", async function (assert) { test("renders a multi-select with choices and attributes", async function (assert) {

View File

@ -4,7 +4,6 @@ import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import pretender, { response } from "discourse/tests/helpers/create-pretender"; import pretender, { response } from "discourse/tests/helpers/create-pretender";
import { query } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper"; import selectKit from "discourse/tests/helpers/select-kit-helper";
module("Integration | Component | invite-panel", function (hooks) { module("Integration | Component | invite-panel", function (hooks) {
@ -34,9 +33,8 @@ module("Integration | Component | invite-panel", function (hooks) {
assert.dom(".send-invite").isEnabled(); assert.dom(".send-invite").isEnabled();
await click(".generate-invite-link"); await click(".generate-invite-link");
assert.strictEqual( assert
query(".invite-link-input").value, .dom(".invite-link-input")
"http://example.com/invites/92c297e886a0ca03089a109ccd6be155" .hasValue("http://example.com/invites/92c297e886a0ca03089a109ccd6be155");
);
}); });
}); });

View File

@ -2,7 +2,6 @@ import { blur, click, fillIn, render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { query } from "discourse/tests/helpers/qunit-helpers";
import { i18n } from "discourse-i18n"; import { i18n } from "discourse-i18n";
module("Integration | Component | secret-value-list", function (hooks) { module("Integration | Component | secret-value-list", function (hooks) {
@ -108,10 +107,9 @@ module("Integration | Component | secret-value-list", function (hooks) {
); );
await blur(".values .value[data-index='1'] .value-input:first-of-type"); await blur(".values .value[data-index='1'] .value-input:first-of-type");
assert.strictEqual( assert
query(".values .value[data-index='1'] .value-input:first-of-type").value, .dom(".values .value[data-index='1'] .value-input:first-of-type")
"changedKey" .hasValue("changedKey");
);
await fillIn( await fillIn(
".values .value[data-index='1'] .value-input:last-of-type", ".values .value[data-index='1'] .value-input:last-of-type",
@ -119,10 +117,9 @@ module("Integration | Component | secret-value-list", function (hooks) {
); );
await blur(".values .value[data-index='1'] .value-input:last-of-type"); await blur(".values .value[data-index='1'] .value-input:last-of-type");
assert.strictEqual( assert
query(".values .value[data-index='1'] .value-input:last-of-type").value, .dom(".values .value[data-index='1'] .value-input:last-of-type")
"changedValue" .hasValue("changedValue");
);
assert.deepEqual( assert.deepEqual(
this.values, this.values,
"firstKey|FirstValue\nchangedKey|changedValue", "firstKey|FirstValue\nchangedKey|changedValue",

View File

@ -8,7 +8,6 @@ import {
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { query } from "discourse/tests/helpers/qunit-helpers";
module("Integration | Component | simple-list", function (hooks) { module("Integration | Component | simple-list", function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
@ -29,11 +28,9 @@ module("Integration | Component | simple-list", function (hooks) {
.dom(".values .value") .dom(".values .value")
.exists({ count: 3 }, "adds the value to the list of values"); .exists({ count: 3 }, "adds the value to the list of values");
assert.strictEqual( assert
query(".values .value[data-index='2'] .value-input").value, .dom(".values .value[data-index='2'] .value-input")
"penar", .hasValue("penar", "sets the correct value for added item");
"it sets the correct value for added item"
);
await fillIn(".add-value-input", "eviltrout"); await fillIn(".add-value-input", "eviltrout");
await triggerKeyEvent(".add-value-input", "keydown", "Enter"); await triggerKeyEvent(".add-value-input", "keydown", "Enter");
@ -76,10 +73,7 @@ module("Integration | Component | simple-list", function (hooks) {
await fillIn(".values .value[data-index='1'] .value-input", "jarek"); await fillIn(".values .value[data-index='1'] .value-input", "jarek");
await blur(".values .value[data-index='1'] .value-input"); await blur(".values .value[data-index='1'] .value-input");
assert.strictEqual( assert.dom(".values .value[data-index='1'] .value-input").hasValue("jarek");
query(".values .value[data-index='1'] .value-input").value,
"jarek"
);
}); });
test("removing a value", async function (assert) { test("removing a value", async function (assert) {
@ -93,11 +87,9 @@ module("Integration | Component | simple-list", function (hooks) {
.dom(".values .value") .dom(".values .value")
.exists({ count: 1 }, "removes the value from the list of values"); .exists({ count: 1 }, "removes the value from the list of values");
assert.strictEqual( assert
query(".values .value[data-index='0'] .value-input").value, .dom(".values .value[data-index='0'] .value-input")
"osama", .hasValue("osama", "removes the correct value");
"it removes the correct value"
);
}); });
test("delimiter support", async function (assert) { test("delimiter support", async function (assert) {
@ -114,10 +106,8 @@ module("Integration | Component | simple-list", function (hooks) {
.dom(".values .value") .dom(".values .value")
.exists({ count: 3 }, "adds the value to the list of values"); .exists({ count: 3 }, "adds the value to the list of values");
assert.strictEqual( assert
query(".values .value[data-index='2'] .value-input").value, .dom(".values .value[data-index='2'] .value-input")
"eviltrout", .hasValue("eviltrout", "adds the correct value");
"it adds the correct value"
);
}); });
}); });

View File

@ -2,7 +2,6 @@ import { blur, click, fillIn, render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { query } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper"; import selectKit from "discourse/tests/helpers/select-kit-helper";
module("Integration | Component | value-list", function (hooks) { module("Integration | Component | value-list", function (hooks) {
@ -36,10 +35,7 @@ module("Integration | Component | value-list", function (hooks) {
await fillIn(".values .value[data-index='1'] .value-input", "jarek"); await fillIn(".values .value[data-index='1'] .value-input", "jarek");
await blur(".values .value[data-index='1'] .value-input"); await blur(".values .value[data-index='1'] .value-input");
assert.strictEqual( assert.dom(".values .value[data-index='1'] .value-input").hasValue("jarek");
query(".values .value[data-index='1'] .value-input").value,
"jarek"
);
assert.deepEqual(this.values, "vinkas\njarek", "updates the value list"); assert.deepEqual(this.values, "vinkas\njarek", "updates the value list");
}); });

View File

@ -53,7 +53,7 @@ module("Unit | Utility | autocomplete", function (hooks) {
await simulateKeys(element, "a :)\r"); await simulateKeys(element, "a :)\r");
assert.strictEqual(element.value, "a :sad: "); assert.dom(element).hasValue("a :sad: ");
assert.strictEqual(element.selectionStart, 8); assert.strictEqual(element.selectionStart, 8);
assert.strictEqual(element.selectionEnd, 8); assert.strictEqual(element.selectionEnd, 8);
}); });
@ -70,24 +70,24 @@ module("Unit | Utility | autocomplete", function (hooks) {
await simulateKeys(element, "@\r"); await simulateKeys(element, "@\r");
assert.strictEqual(element.value, "@test1 "); assert.dom(element).hasValue("@test1 ");
assert.strictEqual(element.selectionStart, 7); assert.strictEqual(element.selectionStart, 7);
assert.strictEqual(element.selectionEnd, 7); assert.strictEqual(element.selectionEnd, 7);
await simulateKeys(element, "@2\r"); await simulateKeys(element, "@2\r");
assert.strictEqual(element.value, "@test1 @test2 "); assert.dom(element).hasValue("@test1 @test2 ");
assert.strictEqual(element.selectionStart, 14); assert.strictEqual(element.selectionStart, 14);
assert.strictEqual(element.selectionEnd, 14); assert.strictEqual(element.selectionEnd, 14);
await setCaretPosition(element, 6); await setCaretPosition(element, 6);
await simulateKeys(element, "\b\b"); await simulateKeys(element, "\b\b");
assert.strictEqual(element.value, "@tes @test2 "); assert.dom(element).hasValue("@tes @test2 ");
await simulateKey(element, "\r"); await simulateKey(element, "\r");
assert.strictEqual(element.value, "@test1 @test2 "); assert.dom(element).hasValue("@test1 @test2 ");
assert.strictEqual(element.selectionStart, 7); assert.strictEqual(element.selectionStart, 7);
assert.strictEqual(element.selectionEnd, 7); assert.strictEqual(element.selectionEnd, 7);
@ -133,7 +133,7 @@ module("Unit | Utility | autocomplete", function (hooks) {
await simulateKeys(element, "@jane d\r"); await simulateKeys(element, "@jane d\r");
assert.strictEqual(element.value, "@jd "); assert.dom(element).hasValue("@jd ");
}); });
test("Autocomplete can render on @", async function (assert) { test("Autocomplete can render on @", async function (assert) {

View File

@ -3,7 +3,6 @@ import { skip } from "qunit";
import { import {
acceptance, acceptance,
publishToMessageBus, publishToMessageBus,
query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { import {
baseChatPretenders, baseChatPretenders,
@ -121,11 +120,7 @@ acceptance("Discourse Chat - Composer - unreliable network", function (needs) {
assert assert
.dom(".chat-message-container[data-id='175']") .dom(".chat-message-container[data-id='175']")
.exists("it sends the message"); .exists("it sends the message");
assert.strictEqual( assert.dom(".chat-composer__input").hasNoValue("clears the input");
query(".chat-composer__input").value,
"",
"it clears the input"
);
}); });
skip("Draft with unreliable network", async function (assert) { skip("Draft with unreliable network", async function (assert) {

View File

@ -2,7 +2,7 @@ import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper"; import selectKit from "discourse/tests/helpers/select-kit-helper";
import { i18n } from 'discourse-i18n'; import { i18n } from "discourse-i18n";
acceptance("Details Button", function (needs) { acceptance("Details Button", function (needs) {
needs.user(); needs.user();
@ -19,12 +19,13 @@ acceptance("Details Button", function (needs) {
await popupMenu.expand(); await popupMenu.expand();
await popupMenu.selectRowByName(i18n("details.title")); await popupMenu.selectRowByName(i18n("details.title"));
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
`\n[details="${i18n("composer.details_title")}"]\n${i18n( `\n[details="${i18n("composer.details_title")}"]\n${i18n(
"composer.details_text" "composer.details_text"
)}\n[/details]\n`, )}\n[/details]\n`,
"it should contain the right output" "contains the right output"
); );
await fillIn(".d-editor-input", "This is my title"); await fillIn(".d-editor-input", "This is my title");
@ -36,12 +37,13 @@ acceptance("Details Button", function (needs) {
await popupMenu.expand(); await popupMenu.expand();
await popupMenu.selectRowByName(i18n("details.title")); await popupMenu.selectRowByName(i18n("details.title"));
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
`\n[details="${i18n( `\n[details="${i18n(
"composer.details_title" "composer.details_title"
)}"]\nThis is my title\n[/details]\n`, )}"]\nThis is my title\n[/details]\n`,
"it should contain the right selected output" "contains the right selected output"
); );
assert.strictEqual( assert.strictEqual(
@ -63,12 +65,13 @@ acceptance("Details Button", function (needs) {
await popupMenu.expand(); await popupMenu.expand();
await popupMenu.selectRowByName(i18n("details.title")); await popupMenu.selectRowByName(i18n("details.title"));
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
`Before \n[details="${i18n( `Before \n[details="${i18n(
"composer.details_title" "composer.details_title"
)}"]\nsome text in between\n[/details]\n After`, )}"]\nsome text in between\n[/details]\n After`,
"it should contain the right output" "contains the right output"
); );
assert.strictEqual( assert.strictEqual(
@ -90,12 +93,13 @@ acceptance("Details Button", function (needs) {
await popupMenu.expand(); await popupMenu.expand();
await popupMenu.selectRowByName(i18n("details.title")); await popupMenu.selectRowByName(i18n("details.title"));
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
`Before \n\n[details="${i18n( `Before \n\n[details="${i18n(
"composer.details_title" "composer.details_title"
)}"]\nsome text in between\n[/details]\n\n After`, )}"]\nsome text in between\n[/details]\n\n After`,
"it should contain the right output" "contains the right output"
); );
assert.strictEqual( assert.strictEqual(
@ -128,12 +132,13 @@ acceptance("Details Button", function (needs) {
await popupMenu.expand(); await popupMenu.expand();
await popupMenu.selectRowByName(i18n("details.title")); await popupMenu.selectRowByName(i18n("details.title"));
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
`\n[details="${i18n( `\n[details="${i18n(
"composer.details_title" "composer.details_title"
)}"]\n${multilineInput}\n[/details]\n`, )}"]\n${multilineInput}\n[/details]\n`,
"it should contain the right output" "contains the right output"
); );
}); });
}); });

View File

@ -1,11 +1,7 @@
import { click, visit } from "@ember/test-helpers"; import { click, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import topicFixtures from "discourse/tests/fixtures/topic"; import topicFixtures from "discourse/tests/fixtures/topic";
import { import { acceptance, selectText } from "discourse/tests/helpers/qunit-helpers";
acceptance,
query,
selectText,
} from "discourse/tests/helpers/qunit-helpers";
import { cloneJSON } from "discourse-common/lib/object"; import { cloneJSON } from "discourse-common/lib/object";
acceptance("Local Dates - quoting", function (needs) { acceptance("Local Dates - quoting", function (needs) {
@ -47,11 +43,10 @@ acceptance("Local Dates - quoting", function (needs) {
await visit("/t/internationalization-localization/280"); await visit("/t/internationalization-localization/280");
await selectText("#post_1 .select-local-date-test"); await selectText("#post_1 .select-local-date-test");
await click(".insert-quote"); await click(".insert-quote");
assert.strictEqual( assert.dom(".d-editor-input").hasValue(
query(".d-editor-input").value.trim(),
`[quote=\"uwe_keim, post:1, topic:280\"] `[quote=\"uwe_keim, post:1, topic:280\"]
This is a test [date=2022-06-17 time=10:00:00 timezone="Australia/Brisbane" displayedTimezone="Australia/Perth"] This is a test [date=2022-06-17 time=10:00:00 timezone="Australia/Brisbane" displayedTimezone="Australia/Perth"]
[/quote]`, [/quote]\n\n`,
"converts the date to markdown with all options correctly" "converts the date to markdown with all options correctly"
); );
}); });
@ -86,11 +81,10 @@ acceptance("Local Dates - quoting range", function (needs) {
await visit("/t/internationalization-localization/280"); await visit("/t/internationalization-localization/280");
await selectText("#post_1 .select-local-date-test"); await selectText("#post_1 .select-local-date-test");
await click(".insert-quote"); await click(".insert-quote");
assert.strictEqual( assert.dom(".d-editor-input").hasValue(
query(".d-editor-input").value.trim(),
`[quote=\"uwe_keim, post:1, topic:280\"] `[quote=\"uwe_keim, post:1, topic:280\"]
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"] 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]`, [/quote]\n\n`,
"converts the date range to markdown with all options correctly" "converts the date range to markdown with all options correctly"
); );
}); });
@ -128,13 +122,12 @@ acceptance(
await visit("/t/internationalization-localization/280"); await visit("/t/internationalization-localization/280");
await selectText("#post_1 .select-local-date-test"); await selectText("#post_1 .select-local-date-test");
await click(".insert-quote"); await click(".insert-quote");
assert.strictEqual( assert.dom(".d-editor-input").hasValue(
query(".d-editor-input").value.trim(),
`[quote=\"uwe_keim, post:1, topic:280\"] `[quote=\"uwe_keim, post:1, topic:280\"]
Testing countdown [date=2022-06-21 time=09:30:00 format="LL" timezone="Australia/Brisbane" countdown="true"] Testing countdown [date=2022-06-21 time=09:30:00 format="LL" timezone="Australia/Brisbane" countdown="true"]
Testing recurring [date=2022-06-22 timezone="Australia/Brisbane" recurring="2.weeks"] Testing recurring [date=2022-06-22 timezone="Australia/Brisbane" recurring="2.weeks"]
[/quote]`, [/quote]\n\n`,
"converts the dates to markdown with all options correctly" "converts the dates to markdown with all options correctly"
); );
}); });

View File

@ -2,7 +2,7 @@ import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper"; import selectKit from "discourse/tests/helpers/select-kit-helper";
import { i18n } from 'discourse-i18n'; import { i18n } from "discourse-i18n";
acceptance("Spoiler Button", function (needs) { acceptance("Spoiler Button", function (needs) {
needs.user(); needs.user();
@ -22,10 +22,11 @@ acceptance("Spoiler Button", function (needs) {
await popUpMenu.expand(); await popUpMenu.expand();
await popUpMenu.selectRowByName(i18n("spoiler.title")); await popUpMenu.selectRowByName(i18n("spoiler.title"));
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
`[spoiler]${i18n("composer.spoiler_text")}[/spoiler]`, `[spoiler]${i18n("composer.spoiler_text")}[/spoiler]`,
"it should contain the right output" "contains the right output"
); );
let textarea = query(".d-editor-input"); let textarea = query(".d-editor-input");
@ -48,10 +49,11 @@ acceptance("Spoiler Button", function (needs) {
await popUpMenu.expand(); await popUpMenu.expand();
await popUpMenu.selectRowByName(i18n("spoiler.title")); await popUpMenu.selectRowByName(i18n("spoiler.title"));
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
`[spoiler]This is hidden[/spoiler]`, `[spoiler]This is hidden[/spoiler]`,
"it should contain the right output" "contains the right output"
); );
assert.strictEqual( assert.strictEqual(
@ -73,10 +75,11 @@ acceptance("Spoiler Button", function (needs) {
await popUpMenu.expand(); await popUpMenu.expand();
await popUpMenu.selectRowByName(i18n("spoiler.title")); await popUpMenu.selectRowByName(i18n("spoiler.title"));
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
`Before [spoiler]this is hidden[/spoiler] After`, `Before [spoiler]this is hidden[/spoiler] After`,
"it should contain the right output" "contains the right output"
); );
assert.strictEqual( assert.strictEqual(
@ -98,10 +101,11 @@ acceptance("Spoiler Button", function (needs) {
await popUpMenu.expand(); await popUpMenu.expand();
await popUpMenu.selectRowByName(i18n("spoiler.title")); await popUpMenu.selectRowByName(i18n("spoiler.title"));
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
`Before\n[spoiler]this is hidden[/spoiler]\nAfter`, `Before\n[spoiler]this is hidden[/spoiler]\nAfter`,
"it should contain the right output" "contains the right output"
); );
assert.strictEqual( assert.strictEqual(
@ -124,10 +128,11 @@ acceptance("Spoiler Button", function (needs) {
await popUpMenu.expand(); await popUpMenu.expand();
await popUpMenu.selectRowByName(i18n("spoiler.title")); await popUpMenu.selectRowByName(i18n("spoiler.title"));
assert.strictEqual( assert
query(".d-editor-input").value, .dom(".d-editor-input")
.hasValue(
`Before\n[spoiler]\nthis is\n\nhidden\n[/spoiler]\nAfter`, `Before\n[spoiler]\nthis is\n\nhidden\n[/spoiler]\nAfter`,
"it should contain the right output" "contains the right output"
); );
assert.strictEqual( assert.strictEqual(