Why
The home and blog page tests verify that getPosts was called with a specific sort direction by having the PostList mock call getPosts internally as a side-effect — which tests a hidden call chain through an artificial seam rather than anything a user can observe, and produces assertions that pass or fail based on mock implementation details rather than real behavior.
Current state
app/(home)/page.test.tsx lines 21–26 define a PostList mock whose body calls void getPosts({ sortDirection: 'descending' }). This call is not used to render anything — it exists solely so that expect(getPosts).toHaveBeenCalledWith({ sortDirection: 'descending' }) at line 74 passes. The same pattern appears in app/blog/page.test.tsx lines 22–23.
The assertion passes because the mock fires the call, not because the real page or PostList component does anything observable with the sort direction. If PostList were rewritten to receive sort direction as a prop instead of calling getPosts internally, these tests would break — even if the rendered output were identical.
Ideal state
- The home page test asserts that the page renders a
PostList component with an observable prop (e.g., via a data-testid or rendered attribute) rather than tracking an internal call count.
- The sort-direction contract (
sortDirection: 'descending') is verified in blog-post-list.test.tsx where getPosts is the actual module under test.
- The
PostList mock in app/(home)/page.test.tsx and app/blog/page.test.tsx does not call getPosts.
Out of scope
- Restructuring
blog-post-list.test.tsx.
- Adding new snapshot tests or changing the component's public API.
Starting points
app/(home)/page.test.tsx lines 21–26 — the PostList mock definition that calls getPosts as a side-effect
app/blog/page.test.tsx lines 22–23 — same pattern
ui/sections/blog-post-list.tsx — the real PostList component whose observable contract the home and blog page tests should verify
QA plan
- Open
app/(home)/page.test.tsx — expect the PostList mock body to contain no call to getPosts.
- Open
app/blog/page.test.tsx — expect the same.
- Run
pnpm test app/\(home\)/page.test.tsx app/blog/page.test.tsx — expect all tests to pass.
- Confirm that the
expect(getPosts).toHaveBeenCalledWith(...) assertions in these two files are either removed or replaced with assertions on the rendered output of the page.
Done when
Neither app/(home)/page.test.tsx nor app/blog/page.test.tsx contains a PostList mock that calls getPosts internally; the tests still verify the pages render a post list, and the sort-direction contract lives in blog-post-list.test.tsx.
Why
The home and blog page tests verify that
getPostswas called with a specific sort direction by having thePostListmock callgetPostsinternally as a side-effect — which tests a hidden call chain through an artificial seam rather than anything a user can observe, and produces assertions that pass or fail based on mock implementation details rather than real behavior.Current state
app/(home)/page.test.tsxlines 21–26 define aPostListmock whose body callsvoid getPosts({ sortDirection: 'descending' }). This call is not used to render anything — it exists solely so thatexpect(getPosts).toHaveBeenCalledWith({ sortDirection: 'descending' })at line 74 passes. The same pattern appears inapp/blog/page.test.tsxlines 22–23.The assertion passes because the mock fires the call, not because the real page or
PostListcomponent does anything observable with the sort direction. IfPostListwere rewritten to receive sort direction as a prop instead of callinggetPostsinternally, these tests would break — even if the rendered output were identical.Ideal state
PostListcomponent with an observable prop (e.g., via adata-testidor rendered attribute) rather than tracking an internal call count.sortDirection: 'descending') is verified inblog-post-list.test.tsxwheregetPostsis the actual module under test.PostListmock inapp/(home)/page.test.tsxandapp/blog/page.test.tsxdoes not callgetPosts.Out of scope
blog-post-list.test.tsx.Starting points
app/(home)/page.test.tsxlines 21–26 — thePostListmock definition that callsgetPostsas a side-effectapp/blog/page.test.tsxlines 22–23 — same patternui/sections/blog-post-list.tsx— the realPostListcomponent whose observable contract the home and blog page tests should verifyQA plan
app/(home)/page.test.tsx— expect thePostListmock body to contain no call togetPosts.app/blog/page.test.tsx— expect the same.pnpm test app/\(home\)/page.test.tsx app/blog/page.test.tsx— expect all tests to pass.expect(getPosts).toHaveBeenCalledWith(...)assertions in these two files are either removed or replaced with assertions on the rendered output of the page.Done when
Neither
app/(home)/page.test.tsxnorapp/blog/page.test.tsxcontains aPostListmock that callsgetPostsinternally; the tests still verify the pages render a post list, and the sort-direction contract lives inblog-post-list.test.tsx.