🧪 Add tests for cardRenderer - #554
Conversation
Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
Warning Review limit reached
Next review available in: 46 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
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 |
PR Summary by QodoAdd Vitest coverage for cardRenderer rendering and font-fetch/cache behavior
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
| }); | ||
|
|
||
| // Check that isTrustedFontUrl was called | ||
| expect(isTrustedFontUrl).toHaveBeenCalledWith(uniqueUrl, undefined); |
There was a problem hiding this comment.
このアサーションは isTrustedFontUrl の呼び出ししか確認していないため、未信頼URLをそのまま取得したり、誤ったURLへ切り替えたりする退行を検出できません。実際の fetch 引数などを使って、既定フォントURLが選択されたことも検証してください。
Knowledge Base Used: Card Data Pipeline
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/lib/__tests__/cardRenderer.test.tsx
Line: 180
Comment:
**フォールバック先が未検証**
このアサーションは `isTrustedFontUrl` の呼び出ししか確認していないため、未信頼URLをそのまま取得したり、誤ったURLへ切り替えたりする退行を検出できません。実際の `fetch` 引数などを使って、既定フォントURLが選択されたことも検証してください。
**Knowledge Base Used:** [Card Data Pipeline](https://app.greptile.com/hiroki-org/-/custom-context/knowledge-base/hiroki-org/github-user-summary/-/docs/card-data-pipeline.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
Code Review by Qodo
1. Non-camelCase test filename
|
| @@ -0,0 +1,252 @@ | |||
| import { describe, expect, it, vi, beforeEach, afterEach } from "vitest"; | |||
There was a problem hiding this comment.
1. Non-camelcase test filename 📘 Rule violation ✧ Quality
The newly added test file name cardRenderer.test.tsx includes a dot in its basename (cardRenderer.test), which violates the camelCase-only filename policy for files introduced under src/lib/. This can break filename lint rules and tooling conventions enforced by the repository.
Agent Prompt
## Issue description
A new file was added under `src/lib/` whose basename is not camelCase because it contains a dot: `cardRenderer.test`.
## Issue Context
Compliance requires introduced/renamed files under `src/lib/` to use camelCase basenames consisting only of letters and digits.
## Fix Focus Areas
- src/lib/__tests__/cardRenderer.test.tsx[1-1]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| import { describe, expect, it, vi, beforeEach, afterEach } from "vitest"; | ||
| import { renderCardResponse, renderErrorCardResponse } from "../cardRenderer"; | ||
| import type { CardData } from "../cardDataFetcher"; | ||
| import type { CardRenderOptions } from "../cardOptions"; |
There was a problem hiding this comment.
2. Relative src imports in test 📘 Rule violation ✧ Quality
The new test uses relative imports (e.g., ../cardRenderer) to import modules from within src/, despite @/* being configured. This violates the requirement to use the @/ alias for src imports and can lead to inconsistent import styles and brittle refactors.
Agent Prompt
## Issue description
Imports in the new test file reference `src/` modules using relative paths instead of the configured `@/` alias.
## Issue Context
`tsconfig.json` configures `@/*` → `./src/*`, and compliance requires `@/` for imports targeting `src`.
## Fix Focus Areas
- src/lib/__tests__/cardRenderer.test.tsx[1-5]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| const mockFetch = vi.fn(); | ||
| global.fetch = mockFetch; | ||
|
|
There was a problem hiding this comment.
3. Direct global fetch assignment 📘 Rule violation ▣ Testability
The test directly assigns global.fetch = mockFetch (and also overwrites global.AbortController) instead of using Vitest’s vi.stubGlobal, violating compliance requirements and risking global state leakage between tests. Because these module-scope mutations are not restored, they can create order-dependent, flaky behavior when the Vitest environment is reused across suites.
Agent Prompt
## Issue description
Update `src/lib/__tests__/cardRenderer.test.tsx` to stop directly mutating `global.fetch` (and `global.AbortController`) at module scope and instead use Vitest’s global stubbing APIs with proper cleanup, so mocks do not leak between tests and the code complies with PR Compliance ID 226126.
## Issue Context
Compliance mandates mocking `fetch` via `vi.stubGlobal('fetch', ...)` (or an approved helper that uses it) rather than `global.fetch = ...`. The current test overwrites `global.fetch` and `global.AbortController` and never restores them, which can leak into other test files when the Vitest environment is reused; this can also break other suites that capture `global.fetch` as an `originalFetch` at module initialization and restore it in `afterEach`, because they may accidentally snapshot the mocked value.
## Fix Focus Areas
- src/lib/__tests__/cardRenderer.test.tsx[28-43]
- src/lib/__tests__/cardRenderer.test.tsx[45-57]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
🎯 What: The
src/lib/cardRenderer.tsxfile was missing a dedicated test suite, which presented a testing gap given its reliance on external dependencies like@vercel/og(forImageResponse),satori, and dynamicfetchcalls for external font handling.📊 Coverage: A new test suite was introduced at
src/lib/__tests__/cardRenderer.test.tsxproviding complete coverage across several distinct scenarios:SVGandPNGresponses.fetchAPI for retrieving valid font URLs while handling potential timeout, rejection, and fetch/status failures using mockedAbortControllerandfetchmechanisms.isTrustedFontUrlvalidator mapping logic before fallback occurs.MAX_FONT_CACHE_SIZE), ensuring proper cache eviction logic prevents unbounded allocations when flooded with unique requests.✨ Result: Test coverage for
src/lib/cardRenderer.tsxis now comprehensively accounted for, elevating line, branch, logic, and functional paths toward full protection against future regressions.PR created automatically by Jules for task 15356029834693712644 started by @is0692vs
Greptile Summary
cardRenderer のSVG・PNG生成、エラーレスポンス、フォント取得、信頼性検査、キャッシュ退避を対象とする専用テストスイートを追加しています。大部分の主要分岐をモック環境で検証していますが、未信頼フォントのケースでは既定URLへのフォールバック自体が未検証です。
Confidence Score: 4/5
マージを妨げる問題はありませんが、未信頼フォントURLのフォールバックテストを具体化すると回帰検出力が向上します。
変更はテストのみで本番動作を変えませんが、未信頼URLのケースはバリデータ呼び出ししか確認しておらず、実際の取得先が既定フォントへ切り替わる契約を保護できていません。
Files Needing Attention: src/lib/tests/cardRenderer.test.tsx
Important Files Changed
Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "test: add test suite for cardRenderer.ts..." | Re-trigger Greptile
Context used: