From 5fdece6d2dc2e88ab0caadcecbe643ac4c8e6ad5 Mon Sep 17 00:00:00 2001 From: lucaronin Date: Fri, 6 Mar 2026 21:00:35 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=85=20Pulse:=20add=20right=20border,?= =?UTF-8?q?=20collapse=20commit=20files=20by=20default?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add border-r border-[var(--sidebar-border)] to PulseView container - CommitCard files default to collapsed (expanded: false) for cleaner initial state - Update tests to reflect new collapsed-by-default behavior --- src/components/PulseView.test.tsx | 38 ++++++++++++++++++++++++++----- src/components/PulseView.tsx | 4 ++-- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/components/PulseView.test.tsx b/src/components/PulseView.test.tsx index 021ff331..fcd3b7b5 100644 --- a/src/components/PulseView.test.tsx +++ b/src/components/PulseView.test.tsx @@ -104,11 +104,17 @@ describe('PulseView', () => { expect(nonLink.tagName).toBe('SPAN') }) - it('renders file list with correct titles', async () => { + it('renders file list with correct titles when expanded', async () => { mockInvokeFn.mockResolvedValue(mockCommits) render() + // Files are collapsed by default — expand all commit cards first + await waitFor(() => { + expect(screen.getAllByLabelText('Expand files').length).toBeGreaterThan(0) + }) + screen.getAllByLabelText('Expand files').forEach((btn) => fireEvent.click(btn)) + await waitFor(() => { expect(screen.getByText('my project')).toBeInTheDocument() }) @@ -122,6 +128,12 @@ describe('PulseView', () => { render() + // Expand first commit card + await waitFor(() => { + expect(screen.getAllByLabelText('Expand files').length).toBeGreaterThan(0) + }) + fireEvent.click(screen.getAllByLabelText('Expand files')[0]) + await waitFor(() => { expect(screen.getByText('my project')).toBeInTheDocument() }) @@ -136,6 +148,12 @@ describe('PulseView', () => { render() + // Expand all commit cards to find the deleted file + await waitFor(() => { + expect(screen.getAllByLabelText('Expand files').length).toBeGreaterThan(0) + }) + screen.getAllByLabelText('Expand files').forEach((btn) => fireEvent.click(btn)) + await waitFor(() => { expect(screen.getByText('old')).toBeInTheDocument() }) @@ -191,20 +209,28 @@ describe('PulseView', () => { }) }) - it('toggles file list visibility when clicking collapse button', async () => { + it('toggles file list visibility when clicking expand/collapse button', async () => { mockInvokeFn.mockResolvedValue(mockCommits) render() + // Files are collapsed by default + await waitFor(() => { + expect(screen.getAllByLabelText('Expand files').length).toBeGreaterThan(0) + }) + expect(screen.queryByText('my project')).not.toBeInTheDocument() + + // Click expand on first commit card + fireEvent.click(screen.getAllByLabelText('Expand files')[0]) + + // Files should now be visible await waitFor(() => { expect(screen.getByText('my project')).toBeInTheDocument() }) - // Click the collapse button on the first commit card - const collapseBtn = screen.getAllByLabelText('Collapse files')[0] - fireEvent.click(collapseBtn) + // Click collapse to hide again + fireEvent.click(screen.getAllByLabelText('Collapse files')[0]) - // Files should be hidden expect(screen.queryByText('my project')).not.toBeInTheDocument() }) diff --git a/src/components/PulseView.tsx b/src/components/PulseView.tsx index ea6ad7c1..75e198d6 100644 --- a/src/components/PulseView.tsx +++ b/src/components/PulseView.tsx @@ -96,7 +96,7 @@ function FileItem({ file, onOpenNote }: { file: PulseFile; onOpenNote?: (path: s } function CommitCard({ commit, onOpenNote }: { commit: PulseCommit; onOpenNote?: (path: string) => void }) { - const [expanded, setExpanded] = useState(true) + const [expanded, setExpanded] = useState(false) const Chevron = expanded ? CaretDown : CaretRight return ( @@ -239,7 +239,7 @@ export const PulseView = memo(function PulseView({ vaultPath, onOpenNote, sideba const dayGroups = groupCommitsByDay(commits) return ( -
+
{/* Header */}