Assign correct value to messageText when toggling resolved state

Google-bug-id: b/208768967
Change-Id: I674765123be82eae991277d3a5eb7d507c23b6ee
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
index bd05edb..1b3ab79 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
@@ -1121,7 +1121,14 @@
 
   private handleToggleResolved() {
     this.unresolved = !this.unresolved;
-    if (!this.editing) this.save();
+    if (!this.editing) {
+      // messageText is only assigned a value if the comment reaches editing
+      // state, however it is possible that the user toggles the resolved state
+      // without editing the comment in which case we assign the correct value
+      // to messageText here
+      this.messageText = this.comment?.message ?? '';
+      this.save();
+    }
   }
 
   private async openDeleteCommentOverlay() {
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.ts b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.ts
index 28a52dc..964ab1f 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.ts
@@ -521,7 +521,7 @@
     });
 
     test('resolved comment state indicated by checkbox', async () => {
-      const saveStub = sinon.stub(element, 'save');
+      const saveStub = stubComments('saveDraft');
       element.comment = {
         ...createComment(),
         __draft: true,