PolyGerrit: Reduce the threshold in gr-watched-projects-editor
Reducing the threshold to 1 allows for more aggressive autocomplete
results, and also supports project names with less than three
characters.
Bug: Issue 7520
Change-Id: I7a97be7312806e5ba12bbc6e022ffa05741a2fe7
(cherry picked from commit cd63eb511af53374425ae55672a2155fadb50d65)
diff --git a/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor.html b/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor.html
index 68b2c23..cf5e0b1 100644
--- a/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor.html
+++ b/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor.html
@@ -96,7 +96,7 @@
<gr-autocomplete
id="newProject"
query="[[_query]]"
- threshold="3"
+ threshold="1"
placeholder="Project"></gr-autocomplete>
</th>
<th colspan$="[[_getTypeCount()]]">
diff --git a/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor_test.html b/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor_test.html
index a93beb1..fbc6217 100644
--- a/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor_test.html
+++ b/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor_test.html
@@ -58,7 +58,7 @@
stub('gr-rest-api-interface', {
getSuggestedProjects(input) {
- if (input.startsWith('the')) {
+ if (input.startsWith('th')) {
return Promise.resolve({'the project': {
id: 'the project',
state: 'ACTIVE',
@@ -122,6 +122,14 @@
});
});
+ test('_getProjectSuggestions non-empty with two letter project', done => {
+ element._getProjectSuggestions('th').then(projects => {
+ assert.equal(projects.length, 1);
+ assert.equal(projects[0].name, 'the project');
+ done();
+ });
+ });
+
test('_canAddProject', () => {
assert.isFalse(element._canAddProject(null, null));
assert.isFalse(element._canAddProject({}, null));