Focus input on cherrypick dialog open

Bug: Issue 7407
Change-Id: Ic87053e63a3a3004cebae8fb5d1a4e76d0f07295
(cherry picked from commit f927042808)
This commit is contained in:
Kasper Nilsson
2017-10-16 16:39:35 -07:00
committed by David Pursehouse
parent be12867423
commit 19f695e6df
2 changed files with 14 additions and 0 deletions

View File

@@ -69,6 +69,10 @@
this.fire('cancel', null, {bubbles: false});
},
resetFocus() {
this.$.branchInput.focus();
},
_getProjectBranchesSuggestions(input) {
if (input.startsWith('refs/heads/')) {
input = input.substring('refs/heads/'.length);

View File

@@ -34,8 +34,10 @@ limitations under the License.
<script>
suite('gr-confirm-cherrypick-dialog tests', () => {
let element;
let sandbox;
setup(() => {
sandbox = sinon.sandbox.create();
stub('gr-rest-api-interface', {
getProjectBranches(input) {
if (input.startsWith('test')) {
@@ -55,6 +57,8 @@ limitations under the License.
element.project = 'test-project';
});
teardown(() => { sandbox.restore(); });
test('with merged change', () => {
element.changeStatus = 'MERGED';
element.commitMessage = 'message\n';
@@ -93,6 +97,12 @@ limitations under the License.
});
});
test('resetFocus', () => {
const focusStub = sandbox.stub(element.$.branchInput, 'focus');
element.resetFocus();
assert.isTrue(focusStub.called);
});
test('_getProjectBranchesSuggestions non-empty', done => {
element._getProjectBranchesSuggestions('test-branch').then(branches => {
assert.equal(branches.length, 1);