Skip to content

Commit

Permalink
BUG: Only bail out if input text is actually empty
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fedarko committed Jul 10, 2019
1 parent 30f04d9 commit 3aa1513
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion qurro/support_files/js/feature_computation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
}

Expand Down
13 changes: 12 additions & 1 deletion qurro/tests/web_tests/tests/test_filter_features.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3aa1513

Please sign in to comment.