Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

test(frontend): say which instant a comment row shows

zchpeter460c81d9ad11
diff --git a/frontend/src/components/issue-activity/IssueCommentActivity.test.tsx b/frontend/src/components/issue-activity/IssueCommentActivity.test.tsx
index 7f0af30527..592491bcc7 100644
--- a/frontend/src/components/issue-activity/IssueCommentActivity.test.tsx
+++ b/frontend/src/components/issue-activity/IssueCommentActivity.test.tsx
@@ -1,4 +1,5 @@
import { create } from "@bufbuild/protobuf";
+import { timestampFromMs } from "@bufbuild/protobuf/wkt";
import { render, screen } from "@testing-library/react";
import type { AnchorHTMLAttributes, ReactNode } from "react";
import { describe, expect, test, vi } from "vitest";
@@ -153,6 +154,31 @@ describe("canEditIssueComment", () => {
});
describe("IssueCommentRow", () => {
+ test("times a comment by when it was written, not when it was edited", () => {
+ // The two instants sit beside each other and feed the same "edited"
+ // marker, so the row has to say which one the timestamp is.
+ const writtenMs = Date.UTC(2026, 2, 2, 12);
+ render(
+ <IssueCommentRow
+ comment={create(IssueCommentSchema, {
+ creator: "users/[email protected]",
+ comment: "a remark",
+ createTime: timestampFromMs(writtenMs),
+ updateTime: timestampFromMs(writtenMs + 60_000),
+ })}
+ isLast
+ issue={create(IssueSchema, { type: Issue_Type.DATABASE_CHANGE })}
+ linkless
+ plan={create(PlanSchema, {})}
+ />
+ );
+
+ expect(screen.getByTestId("humanize-ts").textContent).toBe(
+ String(writtenMs)
+ );
+ expect(screen.getByText("(common.edited)")).toBeInTheDocument();
+ });
+
test("shows who bypassed review and created the rollout", () => {
const issue = create(IssueSchema, {
type: Issue_Type.DATABASE_CHANGE,
diff --git a/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.test.tsx b/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.test.tsx
index d87c98556b..5661367c06 100644
--- a/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.test.tsx
+++ b/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.test.tsx
@@ -225,6 +225,29 @@ describe("CommentThreadCard", () => {
);
});
+ test("times a reply by when it was written, not when it was edited", () => {
+ // The two instants sit beside each other in ThreadComment and feed the
+ // same "edited" marker, so the row has to say which one it shows.
+ const reply = create(IssueCommentSchema, {
+ name: `${ISSUE}/issueComments/edited`,
+ comment: "Reply",
+ creator: "users/[email protected]",
+ root: `${ISSUE}/issueComments/root`,
+ createTime: create(TimestampSchema, { seconds: BigInt(1_000) }),
+ updateTime: create(TimestampSchema, { seconds: BigInt(2_000) }),
+ });
+ const [thread] = groupThreads([comment("root", "Root question"), reply]);
+ render(
+ <CommentThreadCard issueName={ISSUE} project={project} thread={thread} />
+ );
+
+ const shown = Array.from(
+ container.querySelectorAll("[data-testid='humanize-ts']")
+ ).map((node) => node.textContent);
+ expect(shown).toContain("1000000");
+ expect(shown).not.toContain("2000000");
+ });
+
test("renders the root and replies oldest first with the thread footer", () => {
const [thread] = groupThreads([
comment("root", "Root question"),
diff --git a/frontend/src/test-utils/humanizeTs.tsx b/frontend/src/test-utils/humanizeTs.tsx
index 9cc7b6e3b3..3aa6846166 100644
--- a/frontend/src/test-utils/humanizeTs.tsx
+++ b/frontend/src/test-utils/humanizeTs.tsx
@@ -11,9 +11,12 @@ export const humanizeTsStub = () => ({
}: {
tsMs: number | undefined;
mode?: string;
- }) => (
- <span data-testid="humanize-ts" data-mode={mode}>
- {tsMs ?? ""}
- </span>
- ),
+ }) =>
+ // Nothing at all without an instant, as the component does: a stub that
+ // left an empty box behind would hide a row that kept its separator.
+ tsMs === undefined ? null : (
+ <span data-testid="humanize-ts" data-mode={mode}>
+ {tsMs}
+ </span>
+ ),
});