Show any edit weblinks in place of EDIT button
https://imgur.com/a/R9YPanV
Change-Id: Ib0b1f5cd59998f290694ca4437da2cfdef755a5e
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host_test.js b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host_test.js
index 5e1b5ff..6c96e34 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host_test.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host_test.js
@@ -211,7 +211,7 @@
assert.isTrue(cancelStub.called);
});
- test('reload() loads files weblinks', () => {
+ test('reload() loads files weblinks', async () => {
element.change = createChange();
const weblinksStub = sinon.stub(GerritNav, '_generateWeblinks')
.returns({name: 'stubb', url: '#s'});
@@ -222,28 +222,40 @@
element.path = 'test-path';
element.commitRange = {baseCommit: 'test-base', commit: 'test-commit'};
element.patchRange = {};
- return element.reload().then(() => {
- assert.isTrue(weblinksStub.calledTwice);
- assert.isTrue(weblinksStub.firstCall.calledWith({
- commit: 'test-base',
- file: 'test-path',
- options: {
- weblinks: undefined,
- },
- repo: 'test-project',
- type: GerritNav.WeblinkType.FILE}));
- assert.isTrue(weblinksStub.secondCall.calledWith({
- commit: 'test-commit',
- file: 'test-path',
- options: {
- weblinks: undefined,
- },
- repo: 'test-project',
- type: GerritNav.WeblinkType.FILE}));
- assert.deepEqual(element.filesWeblinks, {
- meta_a: [{name: 'stubb', url: '#s'}],
- meta_b: [{name: 'stubb', url: '#s'}],
- });
+
+ await element.reload();
+
+ assert.equal(weblinksStub.callCount, 3);
+ assert.deepEqual(weblinksStub.firstCall.args[0], {
+ commit: 'test-base',
+ file: 'test-path',
+ options: {
+ weblinks: undefined,
+ },
+ repo: 'test-project',
+ type: GerritNav.WeblinkType.EDIT});
+ assert.deepEqual(element.editWeblinks, [{
+ name: 'stubb', url: '#s',
+ }]);
+ assert.deepEqual(weblinksStub.secondCall.args[0], {
+ commit: 'test-base',
+ file: 'test-path',
+ options: {
+ weblinks: undefined,
+ },
+ repo: 'test-project',
+ type: GerritNav.WeblinkType.FILE});
+ assert.deepEqual(weblinksStub.thirdCall.args[0], {
+ commit: 'test-commit',
+ file: 'test-path',
+ options: {
+ weblinks: undefined,
+ },
+ repo: 'test-project',
+ type: GerritNav.WeblinkType.FILE});
+ assert.deepEqual(element.filesWeblinks, {
+ meta_a: [{name: 'stubb', url: '#s'}],
+ meta_b: [{name: 'stubb', url: '#s'}],
});
});