From 3aa15135b2a339b6ff137c7a5d70da2c6e682793 Mon Sep 17 00:00:00 2001 From: Marcus Fedarko Date: Tue, 9 Jul 2019 21:03:52 -0700 Subject: [PATCH] BUG: Only bail out if input text is actually empty what was happening was that you could enter in something like " " as the input text, and it'd just get rejected (because the previous code immediately bailed out of searching if inputText.trim().length was 0). However, text searching uses the *exact* text you enter in, whitespace and all. This behavior is ok, but it means that we shouldn't necessarily filter out inputs containing only whitespace (since the user could conceivably want to find all features containing a space for a given metadata field, and exact text searching should provide that functionality). We still check to make sure that the input text isn't empty, so #3 is still resolved. And the rank searching trims the input text anyway, so all this change affects is the text searching controls. --- CHANGELOG.md | 2 ++ qurro/support_files/js/feature_computation.js | 2 +- qurro/tests/web_tests/tests/test_filter_features.js | 13 ++++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d03ac08..fd579ab2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ### Features added ### Backward-incompatible changes ### Bug fixes +- Allowed "exact text" searching (the first search option) using just + whitespace. ### Performance enhancements - Removed some unused data from `qurro/tests/`. ### Miscellaneous diff --git a/qurro/support_files/js/feature_computation.js b/qurro/support_files/js/feature_computation.js index 2a89bdbf..a66211a2 100644 --- a/qurro/support_files/js/feature_computation.js +++ b/qurro/support_files/js/feature_computation.js @@ -161,7 +161,7 @@ define(function() { throw new Error("featureMetadataField not found in data"); } else if (searchType !== "text" && searchType !== "rank") { throw new Error('searchType must be either "text" or "rank"'); - } else if (inputText.trim().length === 0) { + } else if (inputText.length === 0) { return []; } diff --git a/qurro/tests/web_tests/tests/test_filter_features.js b/qurro/tests/web_tests/tests/test_filter_features.js index 6e2e3cb6..82d40237 100644 --- a/qurro/tests/web_tests/tests/test_filter_features.js +++ b/qurro/tests/web_tests/tests/test_filter_features.js @@ -154,7 +154,7 @@ define(["feature_computation", "mocha", "chai", "testing_utilities"], function( ); }); - it("Doesn't find anything if inputText is empty or contains only whitespace", function() { + it("Doesn't find anything if inputText is empty, but can do just-text-searching using whitespace", function() { chai.assert.isEmpty( feature_computation.filterFeatures( rpJSON1, @@ -187,6 +187,17 @@ define(["feature_computation", "mocha", "chai", "testing_utilities"], function( "text" ) ); + chai.assert.sameMembers( + testing_utilities.getFeatureIDsFromObjectArray( + feature_computation.filterFeatures( + rpJSON1, + " ", + "Feature ID", + "text" + ) + ), + inputFeatures + ); }); it("Ignores actual null values", function() { // Feature 6's Taxonomy value is "null", while Feature 7's