Show "content restored" message more selectively
With this change, we only show the "content restored" message if the local content differs from the remote content. Bug: Issue 8928 Change-Id: Ic0a3ca33998c7c3e4235d4676c435ad5face8ad3
This commit is contained in:
@@ -155,7 +155,8 @@
|
||||
|
||||
return this.$.restAPI.getFileContent(changeNum, path, patchNum)
|
||||
.then(res => {
|
||||
if (storedContent && storedContent.message) {
|
||||
if (storedContent && storedContent.message &&
|
||||
storedContent.message !== res.content) {
|
||||
this.dispatchEvent(new CustomEvent('show-alert',
|
||||
{detail: {message: RESTORED_MESSAGE}, bubbles: true}));
|
||||
|
||||
|
||||
@@ -376,6 +376,29 @@ suite('gr-editor-view tests', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('local edit exists, is same as remote edit', () => {
|
||||
sandbox.stub(element.$.storage, 'getEditableContentItem')
|
||||
.returns({message: 'pending edit'});
|
||||
sandbox.stub(element.$.restAPI, 'getFileContent')
|
||||
.returns(Promise.resolve({
|
||||
ok: true,
|
||||
type: 'text/javascript',
|
||||
content: 'pending edit',
|
||||
}));
|
||||
|
||||
const alertStub = sandbox.stub();
|
||||
element.addEventListener('show-alert', alertStub);
|
||||
|
||||
return element._getFileData(1, 'test', 1).then(() => {
|
||||
flushAsynchronousOperations();
|
||||
|
||||
assert.isFalse(alertStub.called);
|
||||
assert.equal(element._newContent, 'pending edit');
|
||||
assert.equal(element._content, 'pending edit');
|
||||
assert.equal(element._type, 'text/javascript');
|
||||
});
|
||||
});
|
||||
|
||||
test('storage key computation', () => {
|
||||
element._changeNum = 1;
|
||||
element._patchNum = 1;
|
||||
|
||||
Reference in New Issue
Block a user