test(core): update Dim.func tests to verify dependency tracking#2329
test(core): update Dim.func tests to verify dependency tracking#2329suhaniiz wants to merge 1 commit into
Conversation
|
Hi @suhaniiz 👋 ⭐ Star this repo before your PR merges. Why? GSSoC 2026 contributors who star get priority review and points credit. After you star, push any commit (or re-run this check). The Thanks for your contribution to TermUI. |
📝 WalkthroughWalkthroughThe ChangesDim.func dependency validation
Estimated code review effort: 1 (Trivial) | ~3 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
There was a problem hiding this comment.
🎉 Thanks for your first PR to TermUI, @suhaniiz.
Before your PR merges:
- ⭐ Star the repo. Required. The
star-checkjob blocks your merge otherwise. - ✅ All checks green:
build,test,typecheck. - 🏷 PR title follows
type: short description. Example:fix: handle empty list. - 🔗 Link your closing issue in the description.
GSSoC 2026 points come from labels after merge:
gssoc:approved. +50 base points.level:beginner/intermediate/advanced/critical. +20 / +35 / +55 / +80.quality:clean/exceptional. x 1.2 / x 1.5.type:*. Stackable bonus.
Your reviewer responds within 48 hours. Ping @Karanjot786 on Discord for urgent help.
🚀 Welcome to the cohort.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/core/src/layout/dim.test.ts`:
- Around line 36-38: Update Dim.func to accept an optional dependency list and
pass it into the created DimFunc; update DimFunc.dependencies() to return the
supplied dependencies instead of always returning an empty array. Ensure
existing calls without dependencies remain supported and the Dim.func dependency
test passes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: d2186e05-45d6-42b9-bac4-665387f1fdce
📒 Files selected for processing (1)
packages/core/src/layout/dim.test.ts
| it('Dim.func() uses custom lambda and tracks dependencies', () => { | ||
| const func = Dim.func(ctx => ctx.parentWidth / 2, ['parentSize']); | ||
| expect(func.dependencies()).toContain('parentSize'); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify whether Dim.func has been updated to accept a dependencies array
ast-grep outline packages/core/src/layout/dim.ts --match 'func' --view expanded
# Check the current DimFunc class implementation
ast-grep run --pattern 'static func($_): Dim {
$$$
}' --lang typescript packages/core/src/layout/dim.ts
# Check DimFunc.dependencies implementation
ast-grep run --pattern 'class DimFunc extends Dim {
$$$
dependencies() {
$$$
}
$$$
}' --lang typescript packages/core/src/layout/dim.tsRepository: Karanjot786/TermUI
Length of output: 1218
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== dim.test.ts ==\n'
sed -n '1,120p' packages/core/src/layout/dim.test.ts | cat -n
printf '\n== dim.ts ==\n'
sed -n '1,140p' packages/core/src/layout/dim.ts | cat -nRepository: Karanjot786/TermUI
Length of output: 3774
Dim.func still needs dependency support
Dim.func(ctx => ctx.parentWidth / 2, ['parentSize']) passes a second argument that Dim.func() does not accept, and DimFunc.dependencies() still returns []. This test will fail until the implementation matches the new API.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/core/src/layout/dim.test.ts` around lines 36 - 38, Update Dim.func
to accept an optional dependency list and pass it into the created DimFunc;
update DimFunc.dependencies() to return the supplied dependencies instead of
always returning an empty array. Ensure existing calls without dependencies
remain supported and the Dim.func dependency test passes.
Description
This PR fixes a bug where
Dim.func()did not track layout dependency flags. It updates the method to accept an optional dependencies array parameter so that the terminal UI layout engine can accurately flag and schedule conditional recalculations when contextual sizes shift.Related Issue
Closes #2326
Which package(s)?
@termuijs/core
Type of Change
type:bug)type:feature)type:docs)type:testing)type:refactor)type:design)type:accessibility)type:performance)type:devops)type:security)Checklist
needs-starcheck blocks your merge otherwise.bun vitest runbun run buildbun run typecheckCONTRIBUTING.md.type: short description.markDirty()(if your change affects rendering).anytypes without an inline comment explaining why.GSSoC 2026 Participation
https://gssoc.girlscript.org/profile/suhaniizScreenshots / Recordings (UI changes)
Notes for the Reviewer
The fix updates the
Dim.func(fn, deps = [])signature to properly capture dependency values rather than defaulting internally to an empty tracking collection. Corresponding test coverage has been added todim.test.tsto assert that dependencies are properly tracked through the evaluation lifecycle.Summary by CodeRabbit