Skip to content

🧪 Add tests for cardTree in cardElements - #540

Closed
is0692vs wants to merge 1 commit into
mainfrom
test-card-tree-11123211576793738880
Closed

🧪 Add tests for cardTree in cardElements#540
is0692vs wants to merge 1 commit into
mainfrom
test-card-tree-11123211576793738880

Conversation

@is0692vs

@is0692vs is0692vs commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🎯 What: Added missing tests for the exported cardTree function.
📊 Coverage: Covered 1-column layout, 2-column layout, and empty block configurations.
Result: Improved test coverage for src/lib/cardElements.tsx.


PR created automatically by Jules for task 11123211576793738880 started by @is0692vs

Greptile Summary

cardTree に対して、1列、2列、ブロックなしの構成を React Testing Library で描画するテストを追加しています。

  • CardDataCardRenderOptions のテスト用フィクスチャを追加
  • 各構成でヘッダーおよび選択されたブロックの表示有無を検証
  • jsdom テスト環境を明示

Confidence Score: 4/5

マージを妨げる問題はありませんが、追加されたレイアウトテストは列配置のリグレッションを検出できるよう強化することを推奨します。

フィクスチャ、依存関係、描画対象の文字列は現在の実装と整合していますが、1列・2列テストはいずれもテキストの存在だけを確認するため、列配置が壊れても成功します。

Files Needing Attention: src/lib/tests/cardElements.test.tsx

Important Files Changed

Filename Overview
src/lib/tests/cardElements.test.tsx cardTree の主要構成を描画するテストは追加されていますが、1列・2列の実際の配置までは検証していません。
Prompt To Fix All With AI
### Issue 1
src/lib/__tests__/cardElements.test.tsx:158-161
**列配置を検証していないテスト**

1列・2列のテストはいずれも表示テキストだけを確認しているため、すべてのブロックが同じ列や `full` 領域に誤配置されても成功します。列コンテナ、スタイル、または各ブロックの親要素を検証しない限り、テスト名が示すレイアウト回帰を検出できません。

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "test: add tests for cardTree" | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

Context used:

Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
github-user-summary Ignored Ignored Aug 7, 2026 6:46am

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@is0692vs, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 55 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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: bceb7a9a-209d-4b09-9ff0-6bba817bf578

📥 Commits

Reviewing files that changed from the base of the PR and between eb95c48 and 92fbf0b.

📒 Files selected for processing (1)
  • src/lib/__tests__/cardElements.test.tsx

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Add jsdom tests for cardTree layouts in cardElements

🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Add missing jsdom-based rendering tests for the exported cardTree function.
• Cover 1-column, 2-column, and empty-block configurations to prevent regressions.
• Use Testing Library to render output and assert key content presence/absence.
Diagram

graph TD
  A["cardElements.test.tsx"] --> B["Vitest (jsdom)"] --> C["Testing Library render"] --> D["cardTree()"] --> E["React element tree"] --> F["Content assertions"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Assert structure via semantic queries (roles/testids)
  • ➕ Less brittle than textContent string matching
  • ➕ Can validate layout placement (left/right/full) more directly
  • ➕ Clearer failure messages tied to elements
  • ➖ May require adding stable selectors (e.g., aria-labels or data-testid) in production components
  • ➖ Slightly more verbose tests
2. Snapshot testing for cardTree output
  • ➕ Captures broad UI output quickly, good for regression detection
  • ➕ Minimal test logic per scenario
  • ➖ Snapshots can become noisy and hard to review
  • ➖ Changes may be accepted without understanding impact

Recommendation: The PR’s approach (render + content assertions across key layout modes) is a good baseline for coverage. If these tests become flaky or overly permissive, prefer semantic queries (roles/testids) to assert block presence and 2-column placement more robustly; consider snapshots only if the output structure is stable and review discipline is strong.

Files changed (1) +70 / -1

Tests (1) +70 / -1
cardElements.test.tsxAdd jsdom render coverage for cardTree layouts +70/-1

Add jsdom render coverage for cardTree layouts

• Configures the suite to run under jsdom, imports 'cardTree', and uses Testing Library to render it. Adds tests for 1-column, 2-column (with layout mapping), and empty-block configurations using a mocked 'CardData' + base render options.

src/lib/tests/cardElements.test.tsx

@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (1) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. ../cardElements uses relative import 📘 Rule violation ✧ Quality
Description
This test file imports modules under src/ via relative paths (e.g., ../cardElements) instead of
the required @/ alias. This reduces consistency and can break or complicate refactors/moves within
src/.
Code

src/lib/tests/cardElements.test.tsx[R3-6]

+import { estimateHeight, levelColor, cardTree } from "../cardElements";
+import { render } from "@testing-library/react";
+import type { CardData } from "../cardDataFetcher";
import type { CardRenderOptions } from "../cardOptions";
Evidence
PR Compliance ID 226103 requires using the @/ alias for imports that resolve inside src/. The
changed test file uses relative imports (../cardElements, ../cardDataFetcher, ../cardOptions)
that target src/lib/*, while tsconfig.json confirms the @/* alias is configured.

Rule 226103: Use @/ path alias for src imports in frontend code
src/lib/tests/cardElements.test.tsx[2-6]
tsconfig.json[21-23]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The file `src/lib/__tests__/cardElements.test.tsx` imports other `src/` modules via relative paths (`../...`) instead of using the configured `@/` alias.

## Issue Context
`tsconfig.json` defines `@/*` -> `./src/*`, and the compliance checklist requires `@/` for imports that resolve inside `src`.

## Fix Focus Areas
- src/lib/__tests__/cardElements.test.tsx[2-6]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Unfocused textContent assertions 🐞 Bug ⚙ Maintainability
Description
The new cardTree tests assert on container.textContent substrings, which confirms only that text
appears somewhere in the rendered output but not *where* or with what structure/semantics. This
makes failures less actionable and can allow regressions in element structure/layout to slip by
while still matching the same concatenated text.
Code

src/lib/tests/cardElements.test.tsx[R159-164]

+      const { container } = render(cardTree(mockData, options2Col, 500));
+      expect(container.textContent).toContain("testuser");
+      expect(container.textContent).toContain("Test bio");
+      expect(container.textContent).toContain("Stats");
+      expect(container.textContent).toContain("Top Repositories");
+    });
Evidence
The new tests use container.textContent assertions across multiple cases. In contrast, other repo
tests use Testing Library queries (screen.getByText) which are more intention-revealing and
produce clearer failures.

src/lib/tests/cardElements.test.tsx[142-177]
src/components/tests/ProfileCard.test.tsx[35-50]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
Current `cardTree` tests rely on `container.textContent` substring checks. These assertions are low-specificity and reduce the diagnostic quality of the tests.

### Issue Context
Other tests in the repo typically use Testing Library queries (e.g., `screen.getByText`, `screen.queryByText`) which better express intent and make failures clearer.

### Fix Focus Areas
- src/lib/__tests__/cardElements.test.tsx[142-177]
- src/components/__tests__/ProfileCard.test.tsx[35-50]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

3. Misleading style-check comment 🐞 Bug ⚙ Maintainability
Description
The 1-column cardTree test comment claims it verifies “correct styles”, but the test only checks
container.textContent, which misrepresents what is actually covered. This can mislead future
changes into thinking layout/styling is asserted when it is not.
Code

src/lib/tests/cardElements.test.tsx[R144-147]

+      // Check if root container has correct styles (using basic string matching on text content or generic checks)
+      expect(container.textContent).toContain("testuser");
+      expect(container.textContent).toContain("github-user-summary");
+      expect(container.textContent).toContain("Test bio");
Evidence
The test comment explicitly mentions verifying styles, but the assertions only check for specific
strings in container.textContent. The component styling is implemented via inline style props in
cardTree, which the test currently does not assert at all.

src/lib/tests/cardElements.test.tsx[142-149]
src/lib/cardElements.tsx[330-342]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The new `cardTree` test includes a comment stating it checks root container styles, but it only performs text-content assertions. This mismatch is misleading and reduces maintainability.

### Issue Context
`cardTree` uses inline styles heavily. If style coverage is intended, assertions should verify specific style properties; otherwise, the comment should be updated to reflect that the test only checks rendered text.

### Fix Focus Areas
- src/lib/__tests__/cardElements.test.tsx[142-149]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context used
✅ Compliance rules (platform): 30 rules

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

Comment on lines +3 to 6
import { estimateHeight, levelColor, cardTree } from "../cardElements";
import { render } from "@testing-library/react";
import type { CardData } from "../cardDataFetcher";
import type { CardRenderOptions } from "../cardOptions";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

1. ../cardelements uses relative import 📘 Rule violation ✧ Quality

This test file imports modules under src/ via relative paths (e.g., ../cardElements) instead of
the required @/ alias. This reduces consistency and can break or complicate refactors/moves within
src/.
Agent Prompt
## Issue description
The file `src/lib/__tests__/cardElements.test.tsx` imports other `src/` modules via relative paths (`../...`) instead of using the configured `@/` alias.

## Issue Context
`tsconfig.json` defines `@/*` -> `./src/*`, and the compliance checklist requires `@/` for imports that resolve inside `src`.

## Fix Focus Areas
- src/lib/__tests__/cardElements.test.tsx[2-6]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +144 to +147
// Check if root container has correct styles (using basic string matching on text content or generic checks)
expect(container.textContent).toContain("testuser");
expect(container.textContent).toContain("github-user-summary");
expect(container.textContent).toContain("Test bio");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Informational

2. Misleading style-check comment 🐞 Bug ⚙ Maintainability

The 1-column cardTree test comment claims it verifies “correct styles”, but the test only checks
container.textContent, which misrepresents what is actually covered. This can mislead future
changes into thinking layout/styling is asserted when it is not.
Agent Prompt
### Issue description
The new `cardTree` test includes a comment stating it checks root container styles, but it only performs text-content assertions. This mismatch is misleading and reduces maintainability.

### Issue Context
`cardTree` uses inline styles heavily. If style coverage is intended, assertions should verify specific style properties; otherwise, the comment should be updated to reflect that the test only checks rendered text.

### Fix Focus Areas
- src/lib/__tests__/cardElements.test.tsx[142-149]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +159 to +164
const { container } = render(cardTree(mockData, options2Col, 500));
expect(container.textContent).toContain("testuser");
expect(container.textContent).toContain("Test bio");
expect(container.textContent).toContain("Stats");
expect(container.textContent).toContain("Top Repositories");
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

3. Unfocused textcontent assertions 🐞 Bug ⚙ Maintainability

The new cardTree tests assert on container.textContent substrings, which confirms only that text
appears somewhere in the rendered output but not *where* or with what structure/semantics. This
makes failures less actionable and can allow regressions in element structure/layout to slip by
while still matching the same concatenated text.
Agent Prompt
### Issue description
Current `cardTree` tests rely on `container.textContent` substring checks. These assertions are low-specificity and reduce the diagnostic quality of the tests.

### Issue Context
Other tests in the repo typically use Testing Library queries (e.g., `screen.getByText`, `screen.queryByText`) which better express intent and make failures clearer.

### Fix Focus Areas
- src/lib/__tests__/cardElements.test.tsx[142-177]
- src/components/__tests__/ProfileCard.test.tsx[35-50]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +158 to +161

const { container } = render(cardTree(mockData, options2Col, 500));
expect(container.textContent).toContain("testuser");
expect(container.textContent).toContain("Test bio");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 列配置を検証していないテスト

1列・2列のテストはいずれも表示テキストだけを確認しているため、すべてのブロックが同じ列や full 領域に誤配置されても成功します。列コンテナ、スタイル、または各ブロックの親要素を検証しない限り、テスト名が示すレイアウト回帰を検出できません。

Knowledge Base Used: Card Data Pipeline

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/lib/__tests__/cardElements.test.tsx
Line: 158-161

Comment:
**列配置を検証していないテスト**

1列・2列のテストはいずれも表示テキストだけを確認しているため、すべてのブロックが同じ列や `full` 領域に誤配置されても成功します。列コンテナ、スタイル、または各ブロックの親要素を検証しない限り、テスト名が示すレイアウト回帰を検出できません。

**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.

@is0692vs

is0692vs commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #550, which includes cardTree together with errorTree coverage.

@is0692vs is0692vs closed this Aug 9, 2026
@is0692vs
is0692vs deleted the test-card-tree-11123211576793738880 branch August 9, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant