Copy links dialog - add sha for merged changes

Google-Bug-Id: b/237746936
Release-Notes: skip
Change-Id: I458184686f533c7deaa299074d2cf78372ab36a8
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
index 7e8e6dd..5ea35ec 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
@@ -1335,6 +1335,16 @@
         value: `${this.change?.id.split('~').pop()}`,
       },
     ];
+    if (
+      this.change?.status === ChangeStatus.MERGED &&
+      this.change?.current_revision
+    ) {
+      links.push({
+        label: 'SHA',
+        shortcut: 's',
+        value: this.change.current_revision,
+      });
+    }
     return html`<gr-copy-links .copyLinks=${links}> </gr-copy-links>`;
   }
 
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts
index f45d023..cd4b1e1 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts
@@ -26,6 +26,7 @@
   mockPromise,
   pressKey,
   queryAndAssert,
+  stubFlags,
   stubRestApi,
   stubUsers,
   waitQueryAndAssert,
@@ -96,6 +97,7 @@
 import {deepClone} from '../../../utils/deep-util';
 import {Modifier} from '../../../utils/dom-util';
 import {GrButton} from '../../shared/gr-button/gr-button';
+import {GrCopyLinks} from '../gr-copy-links/gr-copy-links';
 
 suite('gr-change-view tests', () => {
   let element: GrChangeView;
@@ -2559,4 +2561,24 @@
     });
     assert.equal(element.calculateHasParent(changeId, relatedChanges), true);
   });
+
+  test('renders sha in copy links', async () => {
+    stubFlags('isEnabled').returns(true);
+    sinon.stub(GerritNav, 'getUrlForChange').returns('/change/123');
+    const sha = '123' as CommitId;
+    element.change = {
+      ...createChangeViewChange(),
+      status: ChangeStatus.MERGED,
+      current_revision: sha,
+    };
+    await element.updateComplete;
+
+    const copyLinksDialog = queryAndAssert<GrCopyLinks>(
+      element,
+      'gr-copy-links'
+    );
+    assert.isTrue(
+      copyLinksDialog.copyLinks.some(copyLink => copyLink.value === sha)
+    );
+  });
 });