Skip to content

A platform for community discussion. Free, open, simple.

DEV: remove toggles for switching between jquery & floatkit autocomplete (#34867)

Kelv547d99e3b4a1
diff --git a/app/assets/javascripts/discourse/app/lib/search.js b/app/assets/javascripts/discourse/app/lib/search.js
index 1a3db25ceae..239b8f2cd85 100644
--- a/app/assets/javascripts/discourse/app/lib/search.js
+++ b/app/assets/javascripts/discourse/app/lib/search.js
@@ -1,11 +1,9 @@
import EmberObject from "@ember/object";
import { isEmpty } from "@ember/utils";
-import $ from "jquery";
import { Promise } from "rsvp";
import { ajax } from "discourse/lib/ajax";
import { search as searchCategoryTag } from "discourse/lib/category-tag-search";
import getURL from "discourse/lib/get-url";
-import { deepMerge } from "discourse/lib/object";
import { emojiUnescape } from "discourse/lib/text";
import { TextareaAutocompleteHandler } from "discourse/lib/textarea-text-manipulation";
import { userPath } from "discourse/lib/url";
@@ -228,40 +226,6 @@ export function isValidSearchTerm(searchTerm, siteSettings) {
}
export function applySearchAutocomplete(inputElement, siteSettings, owner) {
- if (!siteSettings.floatkit_autocomplete_input_fields) {
- const $input = $(inputElement);
-
- $input.autocomplete(
- deepMerge({
- template: categoryTagAutocomplete,
- key: "#",
- width: "100%",
- treatAsTextarea: true,
- autoSelectFirstSuggestion: false,
- transformComplete: (obj) => obj.text,
- dataSource: (term) => searchCategoryTag(term, siteSettings),
- })
- );
-
- if (siteSettings.enable_mentions) {
- $input.autocomplete(
- deepMerge({
- template: userAutocomplete,
- key: "@",
- width: "100%",
- treatAsTextarea: true,
- autoSelectFirstSuggestion: false,
- transformComplete: (v) => {
- validateSearchResult(v);
- return v.username || v.name;
- },
- dataSource: (term) => userSearch({ term, includeGroups: true }),
- })
- );
- }
- return;
- }
-
const autocompleteHandler = new TextareaAutocompleteHandler(inputElement);
DAutocompleteModifier.setupAutocomplete(
owner,
diff --git a/app/assets/javascripts/discourse/app/lib/textarea-text-manipulation.js b/app/assets/javascripts/discourse/app/lib/textarea-text-manipulation.js
index 6833e00d091..8ad4c569789 100644
--- a/app/assets/javascripts/discourse/app/lib/textarea-text-manipulation.js
+++ b/app/assets/javascripts/discourse/app/lib/textarea-text-manipulation.js
@@ -905,21 +905,12 @@ export default class TextareaTextManipulation {
}
autocomplete(options) {
- if (this.siteSettings.floatkit_autocomplete_composer) {
- return DAutocompleteModifier.setupAutocomplete(
- getOwner(this),
- this.textarea,
- this.autocompleteHandler,
- options
- );
- } else {
- // @ts-ignore
- this.$textarea.autocomplete(
- options instanceof Object
- ? { textHandler: this.autocompleteHandler, ...options }
- : options
- );
- }
+ return DAutocompleteModifier.setupAutocomplete(
+ getOwner(this),
+ this.textarea,
+ this.autocompleteHandler,
+ options
+ );
}
}
diff --git a/app/assets/javascripts/discourse/app/static/prosemirror/lib/text-manipulation.js b/app/assets/javascripts/discourse/app/static/prosemirror/lib/text-manipulation.js
index 28411c79fd7..7d10506726d 100644
--- a/app/assets/javascripts/discourse/app/static/prosemirror/lib/text-manipulation.js
+++ b/app/assets/javascripts/discourse/app/static/prosemirror/lib/text-manipulation.js
@@ -3,7 +3,6 @@ import { getOwner, setOwner } from "@ember/owner";
import { next } from "@ember/runloop";
import { service } from "@ember/service";
import { TrackedObject } from "@ember-compat/tracked-built-ins";
-import $ from "jquery";
import { lift, setBlockType, toggleMark, wrapIn } from "prosemirror-commands";
import { Slice } from "prosemirror-model";
import { liftListItem, sinkListItem } from "prosemirror-schema-list";
@@ -105,21 +104,12 @@ export default class ProsemirrorTextManipulation {
}
autocomplete(options) {
- if (this.siteSettings.floatkit_autocomplete_composer) {
- return DAutocompleteModifier.setupAutocomplete(
- getOwner(this),
- this.view.dom,
- this.autocompleteHandler,
- options
- );
- } else {
- // @ts-ignore
- $(this.view.dom).autocomplete(
- options instanceof Object
- ? { textHandler: this.autocompleteHandler, ...options }
- : options
- );
- }
+ return DAutocompleteModifier.setupAutocomplete(
+ getOwner(this),
+ this.view.dom,
+ this.autocompleteHandler,
+ options
+ );
}
applySurroundSelection(head, tail, exampleKey) {
diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-editor-mentions-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-editor-mentions-test.js
index e8cc636efd6..01dfd34c73a 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/composer-editor-mentions-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-editor-mentions-test.js
@@ -71,173 +71,6 @@ acceptance("Composer - editor mentions", function (needs) {
});
});
- test("selecting user mentions", async function (assert) {
- this.siteSettings.floatkit_autocomplete_composer = false;
- await visit("/");
- await click("#create-topic");
-
- await simulateKeys(".d-editor-input", "abc @u\r");
-
- assert
- .dom(".d-editor-input")
- .hasValue("abc @user ", "replaces mention correctly");
- });
-
- test("selecting user mentions after deleting characters", async function (assert) {
- this.siteSettings.floatkit_autocomplete_composer = false;
- await visit("/");
- await click("#create-topic");
-
- await simulateKeys(".d-editor-input", "abc @user a\b\b\r");
-
- assert
- .dom(".d-editor-input")
- .hasValue("abc @user ", "replaces mention correctly");
- });
-
- test("selecting user mentions after deleting characters mid sentence", async function (assert) {
- this.siteSettings.floatkit_autocomplete_composer = false;
- await visit("/");
- await click("#create-topic");
-
- await simulateKeys(".d-editor-input", "abc @user 123");
- await setCaretPosition(".d-editor-input", 9);
- await simulateKeys(".d-editor-input", "\b\b\r");
-
- assert
- .dom(".d-editor-input")
- .hasValue("abc @user 123", "replaces mention correctly");
- });
-
- test("shows status on search results when mentioning a user", async function (assert) {
- this.siteSettings.floatkit_autocomplete_composer = false;
- const timezone = loggedInUser().user_option.timezone;
- const now = moment(status.ends_at).add(-1, "hour").format();
- clock = fakeTime(now, timezone, true);
-
- await visit("/");
- await click("#create-topic");
-
- await simulateKeys(".d-editor-input", "@u");
-
- assert
- .dom(`.autocomplete .emoji[alt='${status.emoji}']`)
- .exists("status emoji is shown");
-
- assert
- .dom(".autocomplete .user-status-message-description")
- .hasText(status.description, "status description is shown");
- });
-
- test("metadata matches are moved to the end", async function (assert) {
- this.siteSettings.floatkit_autocomplete_composer = false;
- await visit("/");
- await click("#create-topic");
-
- await simulateKeys(".d-editor-input", "abc @u");
-
- assert.deepEqual(
- [...queryAll(".ac-user .username")].map((e) => e.innerText),
- ["user", "user2", "user_group", "johndoe", "foo"]
- );
-
- await simulateKeys(".d-editor-input", "\bf");
-
- assert.deepEqual(
- [...queryAll(".ac-user .username")].map((e) => e.innerText),
- ["foo", "user", "user2", "johndoe"]
- );
- });
-
- test("shows users immediately when @ is typed in a reply", async function (assert) {
- this.siteSettings.floatkit_autocomplete_composer = false;
- await visit("/");
- await click(".topic-list-item .title");
- await click(".btn-primary.create");
-
- await simulateKeys(".d-editor-input", "abc @");
-
- assert.deepEqual(
- [...document.querySelectorAll(".ac-user .username")].map(
- (e) => e.innerText
- ),
- ["user_group", "user", "user2", "johndoe", "foo"]
- );
- });
-
- test("selecting user mentions by partial full name", async function (assert) {
- this.siteSettings.floatkit_autocomplete_composer = false;
- await visit("/");
- await click("#create-topic");
-
- await simulateKeys(".d-editor-input", "abc @John Doe J\r");
-
- assert
- .dom(".d-editor-input")
- .hasValue("abc @johndoe ", "replaces full name mention correctly");
- });
-});
-
-acceptance("Composer - editor mentions with floatkit", function (needs) {
- let clock = null;
-
- const status = {
- emoji: "tooth",
- description: "off to dentist",
- ends_at: "2100-02-01T09:00:00.000Z",
- };
-
- needs.user();
- needs.settings({
- enable_mentions: true,
- allow_uncategorized_topics: true,
- });
- needs.hooks.afterEach(() => clock?.restore());
-
- needs.pretender((server, helper) => {
- server.get("/t/11557.json", () => {
- const topicFixture = cloneJSON(topicFixtures["/t/130.json"]);
- topicFixture.id = 11557;
- return helper.response(topicFixture);
- });
- server.get("/u/search/users", () => {
- return helper.response({
- users: [
- {
- username: "user",
- name: "Some User",
- avatar_template:
- "https://avatars.discourse.org/v3/letter/t/41988e/{size}.png",
- status,
- },
- {
- username: "user2",
- name: "Some User",
- avatar_template:
- "https://avatars.discourse.org/v3/letter/t/41988e/{size}.png",
- },
- {
- username: "johndoe",
- name: "John Doe Jr",
- avatar_template:
- "https://avatars.discourse.org/v3/letter/j/41988e/{size}.png",
- },
- {
- username: "foo",
- avatar_template:
- "https://avatars.discourse.org/v3/letter/t/41988e/{size}.png",
- },
- ],
- groups: [
- {
- name: "user_group",
- full_name: "Group",
- },
- ],
- });
- });
- });
-
test("selecting user mentions", async function (assert) {
await visit("/");
await click("#create-topic");
diff --git a/app/assets/javascripts/discourse/tests/acceptance/emoji-test.js b/app/assets/javascripts/discourse/tests/acceptance/emoji-test.js
index 208d49eb806..186be534e84 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/emoji-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/emoji-test.js
@@ -20,78 +20,6 @@ acceptance("Emoji", function (needs) {
});
});
- test("emoji is cooked properly", async function (assert) {
- this.siteSettings.floatkit_autocomplete_composer = false;
- await visit("/t/internationalization-localization/280");
- await click("#topic-footer-buttons .btn.create");
-
- await simulateKeys(".d-editor-input", "a :blonde_woman\t");
- assert
- .dom(".d-editor-preview")
- .hasHtml(
- `<p>a <img src="/images/emoji/twitter/blonde_woman.png?v=${v}" title=":blonde_woman:" class="emoji" alt=":blonde_woman:" loading="lazy" width="20" height="20" style="aspect-ratio: 20 / 20;"></p>`
- );
- });
-
- test("emoji can be picked from the emoji-picker using the mouse", async function (assert) {
- this.siteSettings.floatkit_autocomplete_composer = false;
- await visit("/t/internationalization-localization/280");
- await click("#topic-footer-buttons .btn.create");
-
- await simulateKeys(".d-editor-input", "a :man_b");
-
- // the 6th item in the list is the "more..."
- await click(".autocomplete.ac-emoji ul li:nth-of-type(6) a");
- await emojiPicker().select("man_biking");
-
- assert
- .dom(".d-editor-preview")
- .hasHtml(
- `<p>a <img src="/images/emoji/twitter/man_biking.png?v=${v}" title=":man_biking:" class="emoji" alt=":man_biking:" loading="lazy" width="20" height="20" style="aspect-ratio: 20 / 20;"></p>`
- );
- });
-
- test("skin toned emoji is cooked properly", async function (assert) {
- this.siteSettings.floatkit_autocomplete_composer = false;
- await visit("/t/internationalization-localization/280");
- await click("#topic-footer-buttons .btn.create");
-
- await fillIn(".d-editor-input", "a :blonde_woman:t5:");
-
- assert
- .dom(".d-editor-preview")
- .hasHtml(
- `<p>a <img src="/images/emoji/twitter/blonde_woman/5.png?v=${v}" title=":blonde_woman:t5:" class="emoji" alt=":blonde_woman:t5:" loading="lazy" width="20" height="20" style="aspect-ratio: 20 / 20;"></p>`
- );
- });
-
- needs.settings({ emoji_autocomplete_min_chars: 2 });
-
- test("siteSetting:emoji_autocomplete_min_chars", async function (assert) {
- this.siteSettings.floatkit_autocomplete_composer = false;
- await visit("/t/internationalization-localization/280");
- await click("#topic-footer-buttons .btn.create");
-
- await simulateKeys(".d-editor-input", ":s");
- assert.dom(".autocomplete.ac-emoji").doesNotExist();
-
- await simulateKey(".d-editor-input", "w");
- assert.dom(".autocomplete.ac-emoji").exists();
- });
-});
-
-acceptance("Emoji with floatkit", function (needs) {
- needs.user();
-
- needs.pretender((server, helper) => {
- server.get("/emojis/search-aliases.json", () => {
- return helper.response([]);
- });
- server.get("/drafts/topic_280.json", function () {
- return helper.response(200, { draft: null });
- });
- });
-
test("emoji is cooked properly", async function (assert) {
await visit("/t/internationalization-localization/280");
await click("#topic-footer-buttons .btn.create");
diff --git a/config/site_settings.yml b/config/site_settings.yml
index c1b41f54e1e..b7f6c72832f 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -564,18 +564,6 @@ basic:
enum: "InterfaceColorSelectorSetting"
default: "disabled"
area: "interface"
- floatkit_autocomplete_composer:
- client: true
- default: true
- area: "interface"
- floatkit_autocomplete_input_fields:
- client: true
- default: true
- area: "interface"
- floatkit_autocomplete_chat_composer:
- client: true
- default: true
- area: "interface"
login:
invite_only:
diff --git a/db/migrate/20250919061654_remove_floatkit_autocomplete_site_settings.rb b/db/migrate/20250919061654_remove_floatkit_autocomplete_site_settings.rb
new file mode 100644
index 00000000000..efaf68b2cee
--- /dev/null
+++ b/db/migrate/20250919061654_remove_floatkit_autocomplete_site_settings.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+#
+class RemoveFloatkitAutocompleteSiteSettings < ActiveRecord::Migration[8.0]
+ def up
+ execute "DELETE FROM site_settings WHERE name IN ('floatkit_autocomplete_composer', 'floatkit_autocomplete_input_fields', 'floatkit_autocomplete_chat_composer')"
+ end
+
+ def down
+ raise ActiveRecord::IrreversibleMigration
+ end
+end
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-composer.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-composer.gjs
index a86c4cd89e7..dd8c433bca7 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-composer.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-composer.gjs
@@ -10,7 +10,6 @@ import willDestroy from "@ember/render-modifiers/modifiers/will-destroy";
import { cancel, next } from "@ember/runloop";
import { service } from "@ember/service";
import { isPresent } from "@ember/utils";
-import $ from "jquery";
import {
emojiSearch,
isSkinTonableEmoji,
@@ -121,11 +120,6 @@ export default class ChatComposer extends Component {
}
applyAutocomplete(textarea, options) {
- if (!this.siteSettings.floatkit_autocomplete_composer) {
- const $textarea = $(textarea);
- return $textarea.autocomplete(options);
- }
-
const autocompleteHandler = new TextareaAutocompleteHandler(textarea);
return DAutocompleteModifier.setupAutocomplete(
getOwner(this),
@@ -561,11 +555,6 @@ export default class ChatComposer extends Component {
if (v.code) {
return `${v.code}:`;
} else {
- if (!this.siteSettings.floatkit_autocomplete_chat_composer) {
- const $textarea = $(textarea);
- $textarea.autocomplete({ cancel: true });
- }
-
const menuOptions = {
identifier: "emoji-picker",
groupIdentifier: "emoji-picker",
diff --git a/plugins/chat/spec/system/chat_composer_spec.rb b/plugins/chat/spec/system/chat_composer_spec.rb
index fa733e943f2..2ea432a3cf0 100644
--- a/plugins/chat/spec/system/chat_composer_spec.rb
+++ b/plugins/chat/spec/system/chat_composer_spec.rb
@@ -12,7 +12,6 @@ RSpec.describe "Chat composer", type: :system do
let(:open_thread) { PageObjects::Pages::ChatThread.new }
before do
- SiteSetting.floatkit_autocomplete_composer = true
chat_system_bootstrap
channel_1.add(current_user)
sign_in(current_user)
@@ -345,29 +344,4 @@ RSpec.describe "Chat composer", type: :system do
expect(channel_page.composer).to have_value("@#{autocomplete_user.username} ")
end
end
-
- context "with floatkit autocomplete disabled" do
- before { SiteSetting.floatkit_autocomplete_composer = false }
-
- context "when adding an emoji through the autocomplete" do
- it "adds the emoji to the composer" do
- chat_page.visit_channel(channel_1)
- find(".chat-composer__input").send_keys(":gri")
- find(".emoji-shortname", text: "grimacing").click
-
- expect(channel_page.composer).to have_value(":grimacing: ")
- end
-
- it "doesn't suggest denied emojis and aliases" do
- SiteSetting.emoji_deny_list = "peach|poop"
- chat_page.visit_channel(channel_1)
-
- find(".chat-composer__input").fill_in(with: ":peac")
- expect(page).to have_no_selector(".emoji-shortname", text: "peach")
-
- find(".chat-composer__input").fill_in(with: ":hank") # alias
- expect(page).to have_no_selector(".emoji-shortname", text: "poop")
- end
- end
- end
end
diff --git a/plugins/chat/spec/system/hashtag_autocomplete_spec.rb b/plugins/chat/spec/system/hashtag_autocomplete_spec.rb
index b11b04f1cbb..76da492b69c 100644
--- a/plugins/chat/spec/system/hashtag_autocomplete_spec.rb
+++ b/plugins/chat/spec/system/hashtag_autocomplete_spec.rb
@@ -15,7 +15,6 @@ describe "Using #hashtag autocompletion to search for and lookup channels", type
let(:topic_page) { PageObjects::Pages::Topic.new }
before do
- SiteSetting.floatkit_autocomplete_composer = true
chat_system_bootstrap(user, [channel1, channel2])
sign_in(user)
end
@@ -170,36 +169,5 @@ describe "Using #hashtag autocompletion to search for and lookup channels", type
css_class = ".hashtag-color--channel-#{management_channel.id}"
expect(find("#hashtag-css-generator", visible: false).text(:all)).not_to include(css_class)
end
-
- context "with floatkit autocomplete disabled" do
- before { SiteSetting.floatkit_autocomplete_composer = false }
-
- it "searches for channels, categories, and tags with # and prioritises channels in the results" do
- chat_page.visit_channel(channel1)
- chat_channel_page.composer.send_keys("this is #ra")
- expect(page).to have_css(
- ".hashtag-autocomplete .hashtag-autocomplete__option .hashtag-autocomplete__link",
- count: 3,
- )
- hashtag_results = page.all(".hashtag-autocomplete__link", count: 3)
- expect(hashtag_results.map(&:text).map { |r| r.gsub("\n", " ") }).to eq(
- ["Random", "Raspberry", "razed (x0)"],
- )
- end
-
- it "searches for channels as well with # in a topic composer and deprioritises them" do
- topic_page.visit_topic_and_open_composer(topic)
- expect(topic_page).to have_expanded_composer
- topic_page.type_in_composer("something #ra")
- expect(page).to have_css(
- ".hashtag-autocomplete .hashtag-autocomplete__option .hashtag-autocomplete__link",
- count: 3,
- )
- hashtag_results = page.all(".hashtag-autocomplete__link", count: 3)
- expect(hashtag_results.map(&:text).map { |r| r.gsub("\n", " ") }).to eq(
- ["Raspberry", "razed (x0)", "Random"],
- )
- end
- end
end
end
diff --git a/plugins/discourse-ai/assets/javascripts/discourse/components/ai-bot-conversations.gjs b/plugins/discourse-ai/assets/javascripts/discourse/components/ai-bot-conversations.gjs
index 5d0858d1254..ee7c713fdcf 100644
--- a/plugins/discourse-ai/assets/javascripts/discourse/components/ai-bot-conversations.gjs
+++ b/plugins/discourse-ai/assets/javascripts/discourse/components/ai-bot-conversations.gjs
@@ -9,17 +9,13 @@ import didInsert from "@ember/render-modifiers/modifiers/did-insert";
import { scheduleOnce } from "@ember/runloop";
import { service } from "@ember/service";
import { TrackedArray } from "@ember-compat/tracked-built-ins";
-import $ from "jquery";
import DButton from "discourse/components/d-button";
import PluginOutlet from "discourse/components/plugin-outlet";
import bodyClass from "discourse/helpers/body-class";
import lazyHash from "discourse/helpers/lazy-hash";
import { popupAjaxError } from "discourse/lib/ajax-error";
import userAutocomplete from "discourse/lib/autocomplete/user";
-import {
- hashtagAutocompleteOptions,
- setupHashtagAutocomplete,
-} from "discourse/lib/hashtag-autocomplete";
+import { hashtagAutocompleteOptions } from "discourse/lib/hashtag-autocomplete";
import { TextareaAutocompleteHandler } from "discourse/lib/textarea-text-manipulation";
import UppyUpload from "discourse/lib/uppy/uppy-upload";
import UppyMediaOptimization from "discourse/lib/uppy-media-optimization-plugin";
@@ -192,37 +188,6 @@ export default class AiBotConversations extends Component {
return;
}
- if (!this.siteSettings.floatkit_autocomplete_chat_composer) {
- $(textarea).autocomplete({
- template: userAutocomplete,
- dataSource: (term) => {
- destroyUserStatuses();
- return userSearch({
- term,
- includeGroups: true,
- }).then((result) => {
- initUserStatusHtml(getOwner(this), result.users);
- return result;
- });
- },
- onRender: (options) => renderUserStatusHtml(options),
- key: "@",
- width: "100%",
- treatAsTextarea: true,
- autoSelectFirstSuggestion: true,
- transformComplete: (obj) => {
- validateSearchResult(obj);
- return obj.username || obj.name;
- },
- afterComplete: (text) => {
- this.textarea.value = text;
- this.focusTextarea();
- this.updateInputValue({ target: { value: text } });
- },
- onClose: destroyUserStatuses,
- });
- }
-
const autocompleteHandler = new TextareaAutocompleteHandler(textarea);
DAutocompleteModifier.setupAutocomplete(
getOwner(this),
@@ -265,16 +230,6 @@ export default class AiBotConversations extends Component {
// You can change this to "chat-composer" if that's more appropriate
const hashtagConfig = this.site.hashtag_configurations["topic-composer"];
- if (!this.siteSettings.floatkit_autocomplete_chat_composer) {
- setupHashtagAutocomplete(hashtagConfig, $(textarea), {
- treatAsTextarea: true,
- afterComplete: (text) => {
- this.textarea.value = text;
- this.focusTextarea();
- this.updateInputValue({ target: { value: text } });
- },
- });
- }
const autocompleteHandler = new TextareaAutocompleteHandler(textarea);
DAutocompleteModifier.setupAutocomplete(
getOwner(this),
diff --git a/spec/system/composer_spec.rb b/spec/system/composer_spec.rb
index 80db6b87b4d..fd58b26267f 100644
--- a/spec/system/composer_spec.rb
+++ b/spec/system/composer_spec.rb
@@ -5,7 +5,6 @@ describe "Composer", type: :system do
let(:composer) { PageObjects::Components::Composer.new }
before { sign_in(user) }
- before { SiteSetting.floatkit_autocomplete_composer = false }
it "displays user cards in preview" do
page.visit "/new-topic"
@@ -75,78 +74,6 @@ describe "Composer", type: :system do
end
end
- context "with floatkit autocomplete enabled" do
- before { SiteSetting.floatkit_autocomplete_composer = true }
-
- it "displays user cards in preview" do
- page.visit "/new-topic"
-
- expect(composer).to be_opened
-
- composer.fill_content("@#{user.username}")
- composer.preview.find("a.mention").click
-
- page.has_css?("#user-card")
- end
-
- context "in a topic, the autocomplete prioritizes" do
- fab!(:topic_user, :user)
- fab!(:second_reply_user, :user)
-
- fab!(:topic) { Fabricate(:topic, user: topic_user) }
- fab!(:op) { Fabricate(:post, topic: topic, user: topic_user) }
- let!(:op_post) { PageObjects::Components::Post.new(op.post_number) }
-
- fab!(:second_reply) { Fabricate(:post, topic: topic, user: second_reply_user) }
- let!(:second_reply_post) { PageObjects::Components::Post.new(second_reply.post_number) }
-
- before { SiteSetting.enable_names = false }
-
- it "the topic owner if replying to topic" do
- page.visit "/t/#{topic.id}"
-
- op_post.reply
- expect(composer).to be_opened
- composer.type_content("@")
-
- expect(composer.mention_menu_autocomplete_username_list).to eq(
- [op.username, second_reply_user.username], # must be first the topic owner
- )
- end
-
- it "the recipient of the reply when replying" do
- page.visit "/t/#{topic.id}"
-
- second_reply_post.reply
- expect(composer).to be_opened
- composer.type_content("@")
-
- expect(composer.mention_menu_autocomplete_username_list).to eq(
- [second_reply_user.username, topic_user.username], # must be first the reply user
- )
- end
-
- it "the recipient of the reply when editing a reply" do
- admin = Fabricate(:admin, refresh_auto_groups: true)
- reply_to_second_post =
- Fabricate(:post, topic: topic, user: user, reply_to_post_number: second_reply.post_number)
- reply_post = PageObjects::Components::Post.new(reply_to_second_post.post_number)
-
- sign_in(admin)
- page.visit "/t/#{topic.id}"
- reply_post.edit
-
- expect(composer).to be_opened
-
- composer.type_content(" @")
-
- expect(composer.mention_menu_autocomplete_username_list).to eq(
- [second_reply_user.username, user.username, topic_user.username],
- )
- end
- end
- end
-
it "focuses the reply button when tabbing out of both editor modes" do
page.visit "/new-topic"
expect(composer).to be_opened
diff --git a/spec/system/hashtag_autocomplete_spec.rb b/spec/system/hashtag_autocomplete_spec.rb
index 13a500d2b89..fe4cd8aec15 100644
--- a/spec/system/hashtag_autocomplete_spec.rb
+++ b/spec/system/hashtag_autocomplete_spec.rb
@@ -17,7 +17,6 @@ describe "Using #hashtag autocompletion to search for and lookup categories and
let(:topic_page) { PageObjects::Pages::Topic.new }
before { sign_in(current_user) }
- before { SiteSetting.floatkit_autocomplete_composer = false }
def visit_topic_and_initiate_autocomplete(initiation_text: "something #co", expected_count: 2)
topic_page.visit_topic_and_open_composer(topic)
@@ -262,129 +261,4 @@ describe "Using #hashtag autocompletion to search for and lookup categories and
expect(generated_css).not_to include(".hashtag-color--category--#{private_category.id}")
end
end
-
- context "with floatkit autocomplete enabled" do
- before { SiteSetting.floatkit_autocomplete_composer = true }
-
- it "searches for categories and tags with # and prioritises categories in the results" do
- visit_topic_and_initiate_autocomplete
- hashtag_results = page.all(".hashtag-autocomplete__link", count: 2)
- expect(hashtag_results.map(&:text).map { |r| r.gsub("\n", " ") }).to eq(
- ["Cool Category", "cooltag (x325)"],
- )
- end
-
- it "begins showing results as soon as # is pressed based on categories and tags topic_count" do
- visit_topic_and_initiate_autocomplete(initiation_text: "#", expected_count: 5)
- hashtag_results = page.all(".hashtag-autocomplete__link")
- expect(hashtag_results.map(&:text).map { |r| r.gsub("\n", " ") }).to eq(
- [
- "Cool Category",
- "Other Category",
- uncategorized_category.name,
- "cooltag (x325)",
- "othertag (x66)",
- ],
- )
- end
-
- it "cooks the selected hashtag clientside in the composer preview with the correct url and icon" do
- visit_topic_and_initiate_autocomplete
- hashtag_results = page.all(".hashtag-autocomplete__link", count: 2)
- hashtag_results[0].click
- expect(page).to have_css(".hashtag-cooked")
- cooked_hashtag = page.find(".hashtag-cooked")
-
- expect(cooked_hashtag["outerHTML"]).to have_tag(
- "a",
- with: {
- class: "hashtag-cooked",
- href: category.url,
- "data-type": "category",
- "data-slug": category.slug,
- "data-id": category.id,
- },
- ) do
- with_tag(
- "span",
- with: {
- class: "hashtag-category-square hashtag-color--category-#{category.id}",
- },
- )
- end
-
- visit_topic_and_initiate_autocomplete
- hashtag_results = page.all(".hashtag-autocomplete__link", count: 2)
- hashtag_results[1].click
- expect(page).to have_css(".hashtag-cooked")
- cooked_hashtag = page.find(".hashtag-cooked")
- expect(cooked_hashtag["outerHTML"]).to have_tag(
- "a",
- with: {
- class: "hashtag-cooked",
- href: tag.url,
- "data-type": "tag",
- "data-slug": tag.name,
- "data-id": tag.id,
- },
- ) do
- with_tag(
- "svg",
- with: {
- class: "fa d-icon d-icon-tag svg-icon hashtag-color--tag-#{tag.id} svg-string",
- },
- ) { with_tag("use", with: { href: "#tag" }) }
- end
- end
-
- it "cooks the hashtags for tag and category correctly serverside when the post is saved to the database" do
- topic_page.visit_topic_and_open_composer(topic)
-
- expect(topic_page).to have_expanded_composer
-
- topic_page.send_reply("this is a #cool-cat category and a #cooltag tag")
-
- expect(topic_page).to have_post_number(2)
-
- cooked_hashtags = page.all(".hashtag-cooked", count: 2)
-
- expect(cooked_hashtags[0]["outerHTML"]).to have_tag(
- "a",
- with: {
- class: "hashtag-cooked",
- href: category.url,
- "data-type": "category",
- "data-slug": category.slug,
- "data-id": category.id,
- "aria-label": category.name,
- },
- ) do
- with_tag(
- "span",
- with: {
- class: "hashtag-category-square hashtag-color--category-#{category.id}",
- },
- )
- end
-
- expect(cooked_hashtags[1]["outerHTML"]).to have_tag(
- "a",
- with: {
- class: "hashtag-cooked",
- href: tag.url,
- "data-type": "tag",
- "data-slug": tag.name,
- "data-id": tag.id,
- "aria-label": tag.name,
- },
- ) do
- with_tag(
- "svg",
- with: {
- class: "fa d-icon d-icon-tag svg-icon hashtag-color--tag-#{tag.id} svg-string",
- },
- ) { with_tag("use", with: { href: "#tag" }) }
- end
- end
- end
end