Fix gr-account-list test failure in Firefox
Also fixes lint error in gr-rest-api-interface. Change-Id: I3211018091fba5f471e0b62653eb348306c670e1
This commit is contained in:
@@ -48,6 +48,7 @@ limitations under the License.
|
||||
|
||||
var existingReviewer1;
|
||||
var existingReviewer2;
|
||||
var sandbox;
|
||||
var element;
|
||||
|
||||
function getChips() {
|
||||
@@ -55,6 +56,7 @@ limitations under the License.
|
||||
}
|
||||
|
||||
setup(function() {
|
||||
sandbox = sinon.sandbox.create();
|
||||
existingReviewer1 = makeAccount();
|
||||
existingReviewer2 = makeAccount();
|
||||
|
||||
@@ -65,6 +67,10 @@ limitations under the License.
|
||||
element.accounts = [existingReviewer1, existingReviewer2];
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
test('account entry only appears when editable', function() {
|
||||
element.readonly = false;
|
||||
assert.isFalse(element.$.entry.hasAttribute('hidden'));
|
||||
@@ -230,52 +236,42 @@ limitations under the License.
|
||||
});
|
||||
|
||||
suite('keyboard interactions', function() {
|
||||
var sandbox;
|
||||
setup(function() {
|
||||
sandbox = sinon.sandbox.create();
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
test('backspace from input removes account iff cursor is in start pos',
|
||||
function(done) {
|
||||
test('backspace at text input start removes last account', function() {
|
||||
var input = element.$.entry.$.input;
|
||||
sandbox.stub(element.$.entry, '_getReviewerSuggestions');
|
||||
sandbox.stub(input, '_updateSuggestions');
|
||||
// Next line is a workaround for Firefix not moving cursor
|
||||
// on input field update
|
||||
assert.equal(input.$.input.selectionStart, 0);
|
||||
input.text = 'test';
|
||||
MockInteractions.focus(input.$.input);
|
||||
flush(function() {
|
||||
assert.equal(element.accounts.length, 2);
|
||||
MockInteractions.pressAndReleaseKeyOn(input.$.input, 8); // Backspace
|
||||
assert.equal(element.accounts.length, 2);
|
||||
input.text = '';
|
||||
MockInteractions.pressAndReleaseKeyOn(input.$.input, 8); // Backspace
|
||||
assert.equal(element.accounts.length, 1);
|
||||
done();
|
||||
});
|
||||
flushAsynchronousOperations();
|
||||
assert.equal(element.accounts.length, 2);
|
||||
MockInteractions.pressAndReleaseKeyOn(input.$.input, 8); // Backspace
|
||||
assert.equal(element.accounts.length, 2);
|
||||
input.text = '';
|
||||
MockInteractions.pressAndReleaseKeyOn(input.$.input, 8); // Backspace
|
||||
assert.equal(element.accounts.length, 1);
|
||||
});
|
||||
|
||||
test('arrow key navigation', function(done) {
|
||||
test('arrow key navigation', function() {
|
||||
var input = element.$.entry.$.input;
|
||||
input.text = '';
|
||||
element.accounts = [makeAccount(), makeAccount()];
|
||||
MockInteractions.focus(input.$.input);
|
||||
flush(function() {
|
||||
var chips = element.accountChips;
|
||||
var chipsOneSpy = sandbox.spy(chips[1], 'focus');
|
||||
MockInteractions.pressAndReleaseKeyOn(input.$.input, 37); // Left
|
||||
assert.isTrue(chipsOneSpy.called);
|
||||
var chipsZeroSpy = sandbox.spy(chips[0], 'focus');
|
||||
MockInteractions.pressAndReleaseKeyOn(chips[1], 37); // Left
|
||||
assert.isTrue(chipsZeroSpy.called);
|
||||
MockInteractions.pressAndReleaseKeyOn(chips[0], 37); // Left
|
||||
assert.isTrue(chipsZeroSpy.calledOnce);
|
||||
MockInteractions.pressAndReleaseKeyOn(chips[0], 39); // Right
|
||||
assert.isTrue(chipsOneSpy.calledTwice);
|
||||
done();
|
||||
});
|
||||
flushAsynchronousOperations();
|
||||
var chips = element.accountChips;
|
||||
var chipsOneSpy = sandbox.spy(chips[1], 'focus');
|
||||
MockInteractions.pressAndReleaseKeyOn(input.$.input, 37); // Left
|
||||
assert.isTrue(chipsOneSpy.called);
|
||||
var chipsZeroSpy = sandbox.spy(chips[0], 'focus');
|
||||
MockInteractions.pressAndReleaseKeyOn(chips[1], 37); // Left
|
||||
assert.isTrue(chipsZeroSpy.called);
|
||||
MockInteractions.pressAndReleaseKeyOn(chips[0], 37); // Left
|
||||
assert.isTrue(chipsZeroSpy.calledOnce);
|
||||
MockInteractions.pressAndReleaseKeyOn(chips[0], 39); // Right
|
||||
assert.isTrue(chipsOneSpy.calledTwice);
|
||||
});
|
||||
|
||||
test('delete', function(done) {
|
||||
|
@@ -373,7 +373,8 @@
|
||||
q: [
|
||||
'is:open owner:self',
|
||||
'is:open ((reviewer:self -owner:self -star:ignore) OR assignee:self)',
|
||||
'is:closed (owner:self OR reviewer:self OR assignee:self) -age:4w limit:10',
|
||||
'is:closed (owner:self OR reviewer:self OR assignee:self) -age:4w ' +
|
||||
'limit:10',
|
||||
],
|
||||
};
|
||||
return this.fetchJSON('/changes/', null, null, params);
|
||||
|
Reference in New Issue
Block a user