From 071a82efe30e8f5fda274dfb1de4e0382ba132bf Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 28 Oct 2019 18:32:13 +0000 Subject: [PATCH] FIX: Correct error when sending PM to email address --- .../javascripts/discourse/lib/user-search.js.es6 | 6 +++--- test/javascripts/lib/user-search-test.js.es6 | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/user-search.js.es6 b/app/assets/javascripts/discourse/lib/user-search.js.es6 index 90b3a3d28e1..5288fae5896 100644 --- a/app/assets/javascripts/discourse/lib/user-search.js.es6 +++ b/app/assets/javascripts/discourse/lib/user-search.js.es6 @@ -54,9 +54,9 @@ function performSearch( oldSearch .then(function(r) { const hasResults = !!( - r.users.length || - r.groups.length || - r.emails.length + (r.users && r.users.length) || + (r.groups && r.groups.length) || + (r.emails && r.emails.length) ); if (eagerComplete && !hasResults) { diff --git a/test/javascripts/lib/user-search-test.js.es6 b/test/javascripts/lib/user-search-test.js.es6 index 5d11b479037..28a298c0fb7 100644 --- a/test/javascripts/lib/user-search-test.js.es6 +++ b/test/javascripts/lib/user-search-test.js.es6 @@ -27,6 +27,10 @@ QUnit.module("lib:user-search", { ]}); } + if(request.url.match(/no-results/)){ + return response({users: []}); + } + return response({ users: [ { @@ -167,4 +171,10 @@ QUnit.test("it skips a search depending on punctuations", async assert => { results = await userSearch({ term: "sam@sam.com" }); assert.equal(results.length, 0); + + results = await userSearch({ + term: "no-results@example.com", + allowEmails: true + }); + assert.equal(results.length, 1); });