-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:paviliondev/discourse-mentionables …
…into main
- Loading branch information
Showing
4 changed files
with
83 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
assets/javascripts/discourse/tests/acceptance/mentionable-in-composer-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { click, fillIn, visit } from "@ember/test-helpers"; | ||
import { toggleCheckDraftPopup } from "discourse/controllers/composer"; | ||
import { cloneJSON } from "discourse-common/lib/object"; | ||
import { | ||
acceptance, | ||
exists, | ||
query, | ||
} from "discourse/tests/helpers/qunit-helpers"; | ||
import { test } from "qunit"; | ||
import mentionableFixtures from "../fixtures/mentionable-fixtures"; | ||
|
||
acceptance("Composer", function (needs) { | ||
needs.user({ | ||
id: 5, | ||
username: "kris", | ||
whisperer: true, | ||
}); | ||
needs.settings({ | ||
general_category_id: 1, | ||
default_composer_category: 1, | ||
}); | ||
needs.site({ | ||
categories: [ | ||
{ | ||
id: 1, | ||
name: "General", | ||
slug: "general", | ||
permission: 1, | ||
topic_template: null, | ||
}, | ||
], | ||
}); | ||
needs.site(cloneJSON(mentionableFixtures["mentionable_items.json"])); | ||
needs.hooks.afterEach(() => toggleCheckDraftPopup(false)); | ||
|
||
test("composer controls", async function (assert) { | ||
await visit("/"); | ||
assert.ok(exists("#create-topic"), "the create button is visible"); | ||
await click("#create-topic"); | ||
assert.ok(exists(".d-editor-input"), "the composer input is visible"); | ||
assert.ok(exists(".d-editor-preview:visible"), "shows the preview"); | ||
await fillIn("#reply-title", "this is my new topic title"); | ||
assert.ok( | ||
exists(".title-input .popup-tip.good.hide"), | ||
"the title is now good" | ||
); | ||
await fillIn( | ||
".d-editor-input", | ||
"this is the *content* of a post with a mentionable item +the-stuff-of-dreams" | ||
); | ||
assert.strictEqual( | ||
query(".d-editor-preview").innerHTML.trim(), | ||
'<p>this is the <em>content</em> of a post with a mentionable item <a href="https://amazing.com/stuff-of-dreams-book" class="mentionable-item" target="_blank" tabindex="-1"><span>The Stuff of Dreams</span></a></p>', | ||
"it previews content" | ||
); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
assets/javascripts/discourse/tests/fixtures/mentionable-fixtures.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export default { | ||
"mentionable_items.json": { | ||
mentionable_items: [ | ||
{ | ||
affiliate_snippet_1: "", | ||
affiliate_snippet_2: "", | ||
affiliate_snippet_3: "", | ||
created_at: "2021-11-03T17:35:14.474Z", | ||
description: "The Stuff of Dreams book", | ||
id: 1, | ||
image_url: null, | ||
name: "The Stuff of Dreams", | ||
slug: "the-stuff-of-dreams", | ||
updated_at: "2021-11-03T17:35:14.474Z", | ||
url: "https://amazing.com/stuff-of-dreams-book", | ||
}, | ||
], | ||
}, | ||
}; |