mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 03:06:53 +08:00
FEATURE: autocomplete usernames early in topic based on participation
Following this change when a user hits `@` and is replying to a topic they will see usernames of people who were last seen and participated in the topic This is somewhat experimental, we may tweak this, or make it optional. Also, a regression in a423a938 where hitting TAB would eat a post you were writing: Eg this would eat a post: ``` text @hello, testing 123 <tab> ```
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
import userSearch from "discourse/lib/user-search";
|
||||
import { CANCELLED_STATUS } from "discourse/lib/autocomplete";
|
||||
|
||||
QUnit.module("lib:user-search", {
|
||||
beforeEach() {
|
||||
@ -73,7 +72,29 @@ QUnit.test("it strips @ from the beginning", async assert => {
|
||||
assert.equal(results[results.length - 1]["name"], "team");
|
||||
});
|
||||
|
||||
QUnit.test("it does not search for invalid usernames", async assert => {
|
||||
let results = await userSearch({ term: "foo, " });
|
||||
assert.equal(results, CANCELLED_STATUS);
|
||||
QUnit.test("it skips a search depending on punctuations", async assert => {
|
||||
let skippedTerms = [
|
||||
"@sam s", // double space is not allowed
|
||||
"@sam;",
|
||||
"@sam,",
|
||||
"@sam:"
|
||||
];
|
||||
|
||||
skippedTerms.forEach(async term => {
|
||||
let results = await userSearch({ term });
|
||||
assert.equal(results.length, 0);
|
||||
});
|
||||
|
||||
let allowedTerms = [
|
||||
"@sam sam", // double space is not allowed
|
||||
"@sam.sam",
|
||||
"@"
|
||||
];
|
||||
|
||||
let topicId = 100;
|
||||
|
||||
allowedTerms.forEach(async term => {
|
||||
let results = await userSearch({ term, topicId });
|
||||
assert.equal(results.length, 6);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user