Skip to content

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

test(frontend): assert which reading, not that there is one

zchpeter3fd11e0b3fc5
diff --git a/frontend/src/components/task-run-log/TaskRunLogViewer.test.tsx b/frontend/src/components/task-run-log/TaskRunLogViewer.test.tsx
index 024dd8787f..83de4f69c9 100644
--- a/frontend/src/components/task-run-log/TaskRunLogViewer.test.tsx
+++ b/frontend/src/components/task-run-log/TaskRunLogViewer.test.tsx
@@ -323,7 +323,8 @@ describe("TaskRunLogViewer", () => {
Array.from(container.querySelectorAll("span")).find(
(span) => span.textContent === text
);
- expect(cell("12:00:00.000")?.firstElementChild).not.toBeNull();
+ const timed = cell("12:00:00.000");
+ expect(timed).toBeDefined();
expect(cell("--:--:--.---")?.firstElementChild).toBeNull();
// Finite, and past the last instant there is: no reading, so no tooltip.
expect(cell("12:00:02.000")?.firstElementChild).toBeNull();
@@ -331,6 +332,55 @@ describe("TaskRunLogViewer", () => {
unmount();
});
+ test("the offered date is the line's own instant", () => {
+ // Which instant, not merely that there is one: a tooltip built from the
+ // wrong time reads as plausibly as the right one. The zone is pinned to
+ // Asia/Shanghai in vitest.config.ts, so noon UTC reads as 8pm.
+ vi.useFakeTimers();
+ const section: Section = {
+ id: "section-0",
+ type: TaskRunLogEntry_Type.COMMAND_EXECUTE,
+ label: "Command Execute",
+ status: "success",
+ statusIcon: CheckCircle2,
+ statusClass: "text-green-600",
+ duration: "2s",
+ entryCount: 1,
+ items: [
+ {
+ key: "timed",
+ time: "20:00:00.000",
+ timeMs: Date.UTC(2026, 2, 2, 12),
+ relativeTime: "",
+ levelIndicator: "\u2713",
+ levelClass: "text-green-600",
+ detail: "ROW",
+ detailClass: "text-gray-600",
+ },
+ ],
+ };
+
+ const { container, unmount } = renderIntoContainer(
+ createElement(SectionContent, { section, datasetKey: "runs/1" })
+ );
+
+ act(() => {
+ Array.from(container.querySelectorAll("span"))
+ .find((span) => span.textContent === "20:00:00.000")
+ ?.firstElementChild?.dispatchEvent(
+ new FocusEvent("focusin", { bubbles: true })
+ );
+ vi.advanceTimersByTime(200);
+ });
+
+ const overlay = document.getElementById("bb-react-layer-overlay");
+ expect(overlay?.textContent).toContain("Mar 2, 2026");
+ expect(overlay?.textContent).toContain("8:00:00");
+
+ unmount();
+ vi.useRealTimers();
+ });
+
test("renders a load more action for large sections", () => {
const largeSection: Section = {
id: "section-0",
diff --git a/frontend/src/components/task-run-log/model.test.ts b/frontend/src/components/task-run-log/model.test.ts
index 694ce5250b..90fbf61a99 100644
--- a/frontend/src/components/task-run-log/model.test.ts
+++ b/frontend/src/components/task-run-log/model.test.ts
@@ -238,6 +238,32 @@ describe("task-run-log model", () => {
expect(sections[1]?.status).toBe("error");
});
+ test("gives a line with no log time no instant to show", () => {
+ // The line still reads as a row -- its time column says so -- but there is
+ // no instant behind it, and a zero would have been an instant.
+ const sections = buildSectionsFromEntries(
+ [
+ create(TaskRunLogEntrySchema, {
+ type: TaskRunLogEntry_Type.COMMAND_EXECUTE,
+ logTime: ts(10),
+ commandExecute: {},
+ }),
+ create(TaskRunLogEntrySchema, {
+ type: TaskRunLogEntry_Type.COMMAND_EXECUTE,
+ commandExecute: {},
+ }),
+ ],
+ { getSectionLabel: (type) => String(type) }
+ );
+
+ const timestamps = sections
+ .flatMap((section) => section.items)
+ .map((item) => item.timeMs);
+ expect(timestamps).toHaveLength(2);
+ expect(timestamps.filter((ms) => ms === undefined)).toHaveLength(1);
+ expect(timestamps.filter((ms) => typeof ms === "number")).toHaveLength(1);
+ });
+
test("renders gh-ost migration as a timed section", () => {
const detailText = {
completed: "Completed",
diff --git a/frontend/src/lib/taskRun.test.ts b/frontend/src/lib/taskRun.test.ts
index 2f6b08afc7..4daf87aae7 100644
--- a/frontend/src/lib/taskRun.test.ts
+++ b/frontend/src/lib/taskRun.test.ts
@@ -161,6 +161,27 @@ describe("getTaskRunComment", () => {
expect(comment).toContain("task-run.status.waiting-max-tasks-per-rollout");
});
+ test("keeps a waiting cause with no report time out of the comment", () => {
+ // The message names the last report, so without one there is nothing to
+ // name; the row falls through to whatever detail it carries.
+ const comment = getTaskRunComment(
+ makeTaskRun({
+ detail: "still waiting",
+ schedulerInfo: {
+ waitingCause: {
+ cause: { case: "parallelTasksLimit", value: true },
+ },
+ },
+ status: TaskRun_Status.RUNNING,
+ }),
+ t
+ );
+ expect(comment).not.toContain(
+ "task-run.status.waiting-max-tasks-per-rollout"
+ );
+ expect(comment).toBe("still waiting");
+ });
+
test("falls back to detail, then a dash", () => {
expect(
getTaskRunComment(
diff --git a/frontend/src/routes/project/plan-detail/components/deploy/DeployTaskHeader.test.tsx b/frontend/src/routes/project/plan-detail/components/deploy/DeployTaskHeader.test.tsx
index 424ba65bee..179bf6eb0f 100644
--- a/frontend/src/routes/project/plan-detail/components/deploy/DeployTaskHeader.test.tsx
+++ b/frontend/src/routes/project/plan-detail/components/deploy/DeployTaskHeader.test.tsx
@@ -71,10 +71,12 @@ describe("DeployTaskHeader", () => {
"names when a scheduled task runs, expanded: %s",
(isExpanded) => {
const container = render({ scheduledTimeMs: SCHEDULED_AT_MS, isExpanded });
- // The operational form: the zone is part of the string, since a rollout
- // time read in the wrong zone is the mistake this display exists to stop.
- expect(container.textContent).toContain("Sep 15, 2026");
- expect(container.textContent).toContain("GMT+8");
+ // The operational form exactly: the zone is part of the string, since a
+ // rollout time read in the wrong zone is the mistake this display exists
+ // to stop, and the seconds are not, since nothing is scheduled to one.
+ // Both halves matter -- the full form carries a zone too, so a test that
+ // only looks for one cannot tell the two apart.
+ expect(container.textContent).toContain("Sep 15, 2026, 9:00 AM GMT+8");
}
);
diff --git a/frontend/src/utils/v1/queryHistory.test.ts b/frontend/src/utils/v1/queryHistory.test.ts
index c3a2d29f79..9c63eb7bea 100644
--- a/frontend/src/utils/v1/queryHistory.test.ts
+++ b/frontend/src/utils/v1/queryHistory.test.ts
@@ -1,6 +1,12 @@
// @vitest-environment node
-import { describe, expect, test } from "vitest";
-import { extractQueryHistoryUID } from "./queryHistory";
+import { create } from "@bufbuild/protobuf";
+import { timestampFromMs } from "@bufbuild/protobuf/wkt";
+import { describe, expect, test, vi } from "vitest";
+import { QueryHistorySchema } from "@/types/proto-es/v1/query_history_service_pb";
+import { extractQueryHistoryUID, queryHistoryTabTitle } from "./queryHistory";
+
+// The title is built from Intl, which reads the active locale here.
+vi.mock("@/lib/i18n", () => ({ default: { language: "en-US" } }));
describe("extractQueryHistoryUID", () => {
test("extracts the uid from a full resource name", () => {
@@ -15,3 +21,21 @@ describe("extractQueryHistoryUID", () => {
expect(extractQueryHistoryUID("projects/proj1")).toBe("-1");
});
});
+
+describe("queryHistoryTabTitle", () => {
+ test("names the time in full, since a tab title hosts no tooltip", () => {
+ expect(
+ queryHistoryTabTitle(
+ create(QueryHistorySchema, {
+ createTime: timestampFromMs(Date.UTC(2026, 2, 2, 12)),
+ })
+ )
+ ).toBe("Query history at Mar 2, 2026, 8:00:00 PM GMT+8");
+ });
+
+ test("names no time when the history carries none", () => {
+ expect(queryHistoryTabTitle(create(QueryHistorySchema, {}))).toBe(
+ "Query history"
+ );
+ });
+});