Merge "Enable message hyperlinking for hidden messages"
This commit is contained in:
commit
4a77478ddb
@ -70,7 +70,24 @@
|
|||||||
|
|
||||||
scrollToMessage: function(messageID) {
|
scrollToMessage: function(messageID) {
|
||||||
var el = this.$$('[data-message-id="' + messageID + '"]');
|
var el = this.$$('[data-message-id="' + messageID + '"]');
|
||||||
if (!el) { return; }
|
// If the message is hidden, expand the hidden messages back to that
|
||||||
|
// point.
|
||||||
|
if (!el) {
|
||||||
|
for (var index = 0; index < this._processedMessages.length; index++) {
|
||||||
|
if (this._processedMessages[index].id === messageID) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (index === this._processedMessages.length) { return; }
|
||||||
|
|
||||||
|
var newMessages = this._processedMessages.slice(index,
|
||||||
|
-this._visibleMessages.length);
|
||||||
|
// Add newMessages to the beginning of _visibleMessages.
|
||||||
|
this.splice.apply(this, ['_visibleMessages', 0, 0].concat(newMessages));
|
||||||
|
// Allow the dom-repeat to stamp.
|
||||||
|
Polymer.dom.flush();
|
||||||
|
el = this.$$('[data-message-id="' + messageID + '"]');
|
||||||
|
}
|
||||||
|
|
||||||
el.set('message.expanded', true);
|
el.set('message.expanded', true);
|
||||||
var top = el.offsetTop;
|
var top = el.offsetTop;
|
||||||
|
@ -56,6 +56,7 @@ limitations under the License.
|
|||||||
suite('gr-messages-list tests', function() {
|
suite('gr-messages-list tests', function() {
|
||||||
var element;
|
var element;
|
||||||
var messages;
|
var messages;
|
||||||
|
var sandbox;
|
||||||
|
|
||||||
var getMessages = function() {
|
var getMessages = function() {
|
||||||
return Polymer.dom(element.root).querySelectorAll('gr-message');
|
return Polymer.dom(element.root).querySelectorAll('gr-message');
|
||||||
@ -66,12 +67,17 @@ limitations under the License.
|
|||||||
getConfig: function() { return Promise.resolve({}); },
|
getConfig: function() { return Promise.resolve({}); },
|
||||||
getLoggedIn: function() { return Promise.resolve(false); },
|
getLoggedIn: function() { return Promise.resolve(false); },
|
||||||
});
|
});
|
||||||
|
sandbox = sinon.sandbox.create();
|
||||||
element = fixture('basic');
|
element = fixture('basic');
|
||||||
messages = _.times(3, randomMessage);
|
messages = _.times(3, randomMessage);
|
||||||
element.messages = messages;
|
element.messages = messages;
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
teardown(function() {
|
||||||
|
sandbox.restore();
|
||||||
|
});
|
||||||
|
|
||||||
test('show some old messages', function() {
|
test('show some old messages', function() {
|
||||||
assert.isTrue(element.$.messageControlsContainer.hasAttribute('hidden'));
|
assert.isTrue(element.$.messageControlsContainer.hasAttribute('hidden'));
|
||||||
element.messages = _.times(26, randomMessage);
|
element.messages = _.times(26, randomMessage);
|
||||||
@ -224,8 +230,8 @@ limitations under the License.
|
|||||||
allMessageEls[i].set('message.expanded', false);
|
allMessageEls[i].set('message.expanded', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
var scrollToStub = sinon.stub(window, 'scrollTo');
|
var scrollToStub = sandbox.stub(window, 'scrollTo');
|
||||||
var highlightStub = sinon.stub(element, '_highlightEl');
|
var highlightStub = sandbox.stub(element, '_highlightEl');
|
||||||
|
|
||||||
element.scrollToMessage('invalid');
|
element.scrollToMessage('invalid');
|
||||||
|
|
||||||
@ -241,9 +247,23 @@ limitations under the License.
|
|||||||
|
|
||||||
assert.isTrue(scrollToStub.calledOnce);
|
assert.isTrue(scrollToStub.calledOnce);
|
||||||
assert.isTrue(highlightStub.calledOnce);
|
assert.isTrue(highlightStub.calledOnce);
|
||||||
|
});
|
||||||
|
|
||||||
scrollToStub.restore();
|
test('scroll to message offscreen', function() {
|
||||||
highlightStub.restore();
|
var scrollToStub = sandbox.stub(window, 'scrollTo');
|
||||||
|
var highlightStub = sandbox.stub(element, '_highlightEl');
|
||||||
|
element.messages = _.times(25, randomMessage);
|
||||||
|
flushAsynchronousOperations();
|
||||||
|
assert.isFalse(scrollToStub.called);
|
||||||
|
assert.isFalse(highlightStub.called);
|
||||||
|
|
||||||
|
var messageID = element.messages[1].id;
|
||||||
|
element.scrollToMessage(messageID);
|
||||||
|
assert.isTrue(scrollToStub.calledOnce);
|
||||||
|
assert.isTrue(highlightStub.calledOnce);
|
||||||
|
assert.equal(element._visibleMessages.length, 24);
|
||||||
|
assert.isTrue(
|
||||||
|
element.$$('[data-message-id="' + messageID + '"]')._expanded);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('messages', function() {
|
test('messages', function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user