Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix(plan): show "(edited)" marker in place after comment edit (BYT-9746) (#20649)
boojacke71bcc8350d5
diff --git a/frontend/src/react/stores/app/index.test.ts b/frontend/src/react/stores/app/index.test.tsindex 8347994b2a..fc5caeeba2 100644--- a/frontend/src/react/stores/app/index.test.ts+++ b/frontend/src/react/stores/app/index.test.ts@@ -26,6 +26,7 @@ import {import { IdentityProviderSchema } from "@/types/proto-es/v1/idp_service_pb";import { InstanceRoleSchema } from "@/types/proto-es/v1/instance_role_service_pb";import { InstanceSchema } from "@/types/proto-es/v1/instance_service_pb";+import { IssueCommentSchema } from "@/types/proto-es/v1/issue_service_pb";import {ProjectSchema,WebhookSchema,@@ -154,6 +155,9 @@ const mocks = vi.hoisted(() => ({listAccessGrants: vi.fn(),activateAccessGrant: vi.fn(),revokeAccessGrant: vi.fn(),+ listIssueComments: vi.fn(),+ createIssueComment: vi.fn(),+ updateIssueComment: vi.fn(),}));vi.mock("@/connect", () => ({@@ -276,6 +280,11 @@ vi.mock("@/connect", () => ({getIamPolicy: mocks.getIamPolicy,setIamPolicy: mocks.setIamPolicy,},+ issueServiceClientConnect: {+ listIssueComments: mocks.listIssueComments,+ createIssueComment: mocks.createIssueComment,+ updateIssueComment: mocks.updateIssueComment,+ },}));const user = createProto(UserSchema, {@@ -1356,6 +1365,40 @@ describe("useAppStore", () => {);});+ test("updateIssueComment writes the server response so the edited marker shows in place (BYT-9746)", async () => {+ const issueName = "projects/a/issues/1";+ const commentName = `${issueName}/issueComments/100`;+ const original = createProto(IssueCommentSchema, {+ name: commentName,+ comment: "before",+ createTime: timestampSeconds(1000),+ updateTime: timestampSeconds(1000),+ });+ // The server bumps updated_at on edit and returns the refreshed comment.+ const serverUpdated = createProto(IssueCommentSchema, {+ name: commentName,+ comment: "after",+ createTime: timestampSeconds(1000),+ updateTime: timestampSeconds(2000),+ });+ mocks.updateIssueComment.mockResolvedValue(serverUpdated);+ const store = createAppStore();+ store.setState({ issueCommentsByIssue: { [issueName]: [original] } });++ await store.getState().updateIssueComment({+ issueCommentName: commentName,+ comment: "after",+ });++ const cached = store.getState().getIssueComments(issueName)[0];+ expect(cached.comment).toBe("after");+ // Regression guard: the optimistic patch used to discard the RPC response+ // and keep the stale updateTime, so IssueCommentActivity's+ // `isEdited = createTime !== updateTime` stayed false until a full refetch.+ expect(cached.updateTime).toEqual(serverUpdated.updateTime);+ expect(cached.updateTime).not.toEqual(cached.createTime);+ });+test("deduplicates project fetches and caches the result", async () => {mocks.getProject.mockResolvedValue(projectA);const store = createAppStore();diff --git a/frontend/src/react/stores/app/issueComment.ts b/frontend/src/react/stores/app/issueComment.tsindex 782795d4ae..eaad49545f 100644--- a/frontend/src/react/stores/app/issueComment.ts+++ b/frontend/src/react/stores/app/issueComment.ts@@ -86,23 +86,24 @@ export const createIssueCommentSlice: AppSliceCreator<IssueCommentSlice> = (const { projectId, issueId } =getProjectIdIssueIdIssueCommentId(issueCommentName);const parent = `${projectNamePrefix}${projectId}/${issueNamePrefix}${issueId}`;- await issueServiceClientConnect.updateIssueComment(- createProto(UpdateIssueCommentRequestSchema, {- parent,- issueComment: createProto(IssueCommentSchema, {- name: issueCommentName,- comment,- }),- updateMask: { paths: ["comment"] },- })- );+ const updatedIssueComment =+ await issueServiceClientConnect.updateIssueComment(+ createProto(UpdateIssueCommentRequestSchema, {+ parent,+ issueComment: createProto(IssueCommentSchema, {+ name: issueCommentName,+ comment,+ }),+ updateMask: { paths: ["comment"] },+ })+ );set((state) => ({issueCommentsByIssue: {...state.issueCommentsByIssue,[parent]: (state.issueCommentsByIssue[parent] ?? []).map((issueComment) =>issueComment.name === issueCommentName- ? { ...issueComment, comment }+ ? updatedIssueComment: issueComment),},