diff --git a/apps/web/src/app/(authenticated)/settings/workspaces/page.tsx b/apps/web/src/app/(authenticated)/settings/workspaces/page.tsx index 5958a99..e4bf5f5 100644 --- a/apps/web/src/app/(authenticated)/settings/workspaces/page.tsx +++ b/apps/web/src/app/(authenticated)/settings/workspaces/page.tsx @@ -61,7 +61,6 @@ function WorkspacesPageContent(): ReactElement { setIsCreating(true); try { // TODO: Replace with real API call - console.log("Creating workspace:", newWorkspaceName); await new Promise((resolve) => setTimeout(resolve, 1000)); // Simulate API call alert(`Workspace "${newWorkspaceName}" created successfully!`); setNewWorkspaceName(""); diff --git a/apps/web/src/app/settings/workspaces/[id]/teams/page.tsx b/apps/web/src/app/settings/workspaces/[id]/teams/page.tsx index 9c8d525..71968b0 100644 --- a/apps/web/src/app/settings/workspaces/[id]/teams/page.tsx +++ b/apps/web/src/app/settings/workspaces/[id]/teams/page.tsx @@ -45,8 +45,6 @@ function TeamsPageContent(): ReactElement { // description: newTeamDescription || undefined, // }); - console.log("Creating team:", { name: newTeamName, description: newTeamDescription }); - // Reset form setNewTeamName(""); setNewTeamDescription(""); diff --git a/apps/web/src/components/chat/MessageList.test.tsx b/apps/web/src/components/chat/MessageList.test.tsx new file mode 100644 index 0000000..83df03f --- /dev/null +++ b/apps/web/src/components/chat/MessageList.test.tsx @@ -0,0 +1,43 @@ +/** + * @file MessageList.test.tsx + * @description Tests for formatTime utility in MessageList + */ + +import { describe, it, expect } from "vitest"; +import { formatTime } from "./MessageList"; + +describe("formatTime", () => { + it("should format a valid ISO date string", () => { + const result = formatTime("2024-06-15T14:30:00Z"); + // The exact output depends on locale, but it should not be empty or "Invalid date" + expect(result).toBeTruthy(); + expect(result).not.toBe("Invalid date"); + }); + + it('should return "Invalid date" for an invalid date string', () => { + const result = formatTime("not-a-date"); + expect(result).toBe("Invalid date"); + }); + + it('should return "Invalid date" for an empty string', () => { + const result = formatTime(""); + expect(result).toBe("Invalid date"); + }); + + it('should return "Invalid date" for garbage input', () => { + const result = formatTime("abc123xyz"); + expect(result).toBe("Invalid date"); + }); + + it("should handle a valid date without time component", () => { + const result = formatTime("2024-01-01"); + expect(result).toBeTruthy(); + expect(result).not.toBe("Invalid date"); + }); + + it("should handle Unix epoch", () => { + const result = formatTime("1970-01-01T00:00:00Z"); + expect(result).toBeTruthy(); + expect(result).not.toBe("Invalid date"); + }); +}); diff --git a/apps/web/src/components/chat/MessageList.tsx b/apps/web/src/components/chat/MessageList.tsx index 7789b30..f8f631d 100644 --- a/apps/web/src/components/chat/MessageList.tsx +++ b/apps/web/src/components/chat/MessageList.tsx @@ -313,12 +313,15 @@ function LoadingIndicator({ quip }: { quip?: string | null }): React.JSX.Element ); } -function formatTime(isoString: string): string { +export function formatTime(isoString: string): string { try { const date = new Date(isoString); + if (isNaN(date.getTime())) { + return "Invalid date"; + } return date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }); } catch { - return ""; + return "Invalid date"; } }