🐛 Fixed bookmark filtering in Welcome Emails editor#26742
Conversation
WalkthroughThe changes refactor filtering logic in a filterable API hook by extracting a reusable 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This comment was marked as outdated.
This comment was marked as outdated.
be5a7c3 to
9b585d8
Compare
closes https://linear.app/ghost/issue/NY-1143 `useFilterableApi` filtered the response if data was already loaded, but not if it wasn't. This fixes that bug, which fixes the end-user bug.
9b585d8 to
d05d7b9
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/admin-x-framework/test/unit/hooks/use-filterable-api.test.ts (1)
554-576: Test for whitespace-only filters could use non-empty mock data.The
mockDatais an empty array, so this test doesn't actually validate the filtering behavior for whitespace inputs—it just confirms empty data returns empty results. Consider using non-empty mock data to meaningfully verify how whitespace-only filters (' ','\t\n') affect filtering.💡 Suggested improvement for meaningful whitespace test coverage
it('handles empty and whitespace-only filters', async () => { - const mockData: TestData[] = []; + const mockData: TestData[] = [ + {id: '1', name: 'John Doe', email: 'john@example.com'}, + {id: '2', name: 'Jane Smith', email: 'jane@example.com'} + ]; mockFetchApi.mockResolvedValue({ users: mockData, meta: {pagination: {next: null}} });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/admin-x-framework/test/unit/hooks/use-filterable-api.test.ts` around lines 554 - 576, The test "handles empty and whitespace-only filters" uses an empty mockData which cannot verify filtering behavior; update the test to use a non-empty mockData (e.g., an array with at least one TestData item), ensure mockFetchApi.mockResolvedValue returns that data, then call result.current.loadData with '', ' ', and '\t\n' and assert each call returns the non-empty mockData so useFilterableApi and its loadData behavior for whitespace-only filters is actually validated.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@apps/admin-x-framework/test/unit/hooks/use-filterable-api.test.ts`:
- Around line 554-576: The test "handles empty and whitespace-only filters" uses
an empty mockData which cannot verify filtering behavior; update the test to use
a non-empty mockData (e.g., an array with at least one TestData item), ensure
mockFetchApi.mockResolvedValue returns that data, then call
result.current.loadData with '', ' ', and '\t\n' and assert each call returns
the non-empty mockData so useFilterableApi and its loadData behavior for
whitespace-only filters is actually validated.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 96088369-9c4b-4a63-b64d-375413b0d452
📒 Files selected for processing (2)
apps/admin-x-framework/src/hooks/use-filterable-api.tsapps/admin-x-framework/test/unit/hooks/use-filterable-api.test.ts
9larsons
left a comment
There was a problem hiding this comment.
Looks great! Fixes a few other parts of Admin, too, as an added bonus.
closes https://linear.app/ghost/issue/NY-1143
useFilterableApifiltered the response if data was already loaded, but not if it wasn't. This fixes that bug, which fixes the end-user bug.Before.mp4
After.mp4