[#140] Closed the data-provider gap in the largest test suites. - #141
Conversation
…skeleton into a helper.
…llscreen guard twins.
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 21 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. 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)
📝 WalkthroughWalkthroughThis test-only refactor consolidates repeated PHPUnit cases into data-provider-driven tests across form validation, panel rendering, input resolution, schema generation, agent help, and widget creation. ChangesForm validation
Panel controller flows
Resolver and schema coverage
Widget coverage
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
|
🚀 Deployed on https://6a69b4ee468e7fafe2d8bb00--tui-docs.netlify.app |
This comment has been minimized.
This comment has been minimized.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #141 +/- ##
=======================================
Coverage 99.09% 99.09%
=======================================
Files 119 119
Lines 4650 4650
=======================================
Hits 4608 4608
Misses 42 42 ☔ View full report in Codecov by Harness. |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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 `@tests/phpunit/Unit/Widget/WidgetFactoryTest.php`:
- Around line 118-127: Update the picker-path fixtures in the relevant
WidgetFactory tests to use vfsStream instead of the host-dependent /nonexistent
path. Initialize the virtual filesystem for both “single picker outside its
start” and “multiple picker keeps its paths” cases, and pass corresponding
vfs:// paths while preserving each test’s expected result.
- Around line 131-136: Update testDateWithNonStringCurrentOpensOnToday so the
expected date is captured both before and after WidgetFactory::create, then
assert that the widget value matches either captured boundary date, preserving
midnight-safe validation of today.
- Line 205: Update the Key::char call in the widget handling test to construct
the control byte with chr(5) instead of the double-quoted "\x05" literal,
preserving the existing behavior and required string-quoting convention.
🪄 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: b8c26c8e-ac11-4351-b648-067623d7ca9b
📒 Files selected for processing (6)
tests/phpunit/Unit/Builder/FormTest.phptests/phpunit/Unit/Render/PanelControllerTest.phptests/phpunit/Unit/Resolver/InputResolverTest.phptests/phpunit/Unit/Schema/AgentHelpTest.phptests/phpunit/Unit/Schema/SchemaGeneratorTest.phptests/phpunit/Unit/Widget/WidgetFactoryTest.php
…tem and bracketed the today assertion.
|
Closes #140
Summary
AGENTS.mdasks for data providers wherever they fit, and the suite already followed the naming half of that rule perfectly: all 147 providers weredataProvider-prefixed and placed after the test they feed. The gap was adoption, concentrated in the six largest files, where 232 test methods carried only 4 providers between them and repeated the same setup and assertion shapes by hand.This converts every genuinely tabular cluster in those six files into a provider, collapsing 232 test methods into 159 while growing the number of executed cases from 2215 to 2239. Line coverage on all nine classes under test is byte-identical to the baseline, and the assertion count rose from 4878 to 4886 because merged twins now assert the union of what each twin asserted rather than the intersection.
No production code changed.
Changes
Where a provider was the right shape
Three distinct shapes turned up, and they were treated differently rather than collapsed one way:
InputResolverTestcoercion and env-name resolution, andWidgetFactoryTestwidget-by-type, value seeding and editor handoff, became plain value providers.FormTest's rejections andAgentHelpTest's field shapes became providers of closures, following the patterndataProviderLayoutMismatchThrowsalready demonstrated inFormTest.PanelControllerTestis this, and a provider is the wrong tool for it: merging such tests produces one test that branches internally and stops naming the behaviour on failure. Only the twin clusters were converted; the fullscreen alignment tests look like a family but each asserts a structurally different thing (line count, indent width, line indices, a box-glyph row) and were left alone.Per file
Unit/Render/PanelControllerTest.phpUnit/Builder/FormTest.phpUnit/Widget/WidgetFactoryTest.phpUnit/Schema/AgentHelpTest.phpUnit/Resolver/InputResolverTest.phpUnit/Schema/SchemaGeneratorTest.phpFormTest- 17 one-off...Throwsmethods plustestLayoutMismatchThrowsbecame a singletestBuildThrowswith 21 named rows, each asserting the one contract they share: this declaration is refused at build time with this message.testRatingCollapsedScaleThrowsandtestToggleInvalidDefaultThrowswere left as they are, since they already use providers and their scalar parameterization carries meaning the closure form would flatten.InputResolverTest- the coercion cluster became 15 tabular rows and the env-name and alias cluster 7 rows. Tests that previously set three environment variables in one body now resolve each independently, so a failure names the one coercion that broke.WidgetFactoryTest- the five field helpers becamestaticso providers can call them;testCreatesByType, previously 17 sequentialassertInstanceOflines in a single body, is now 17 rows. The value-seeding cluster and the three external-editor tests each became one provider. The two file-picker cases stayed out of the seeding provider and got their own test seeded fromvfsStream, since a static provider is evaluated at collection time whereas the virtual filesystem has per-test lifetime.SchemaGeneratorTest- aprompt()helper now supplies the 26-key skeleton that three expectations each spelled out in full.testGeneratedeliberately keeps its fully-written arrays: it is the one place that documents the complete shape of a generated prompt, and that is worth its verbosity.AgentHelpTest- four providers covering field shape, environment advertisement, closure defaults and skipped non-answering types, sharing oneassertHelp()helper for the contains, absent and regex assertion lists.PanelControllerTest- modal dismissal (Cancel button and Escape), the textarea editor hint, the fullscreen too-small guard, and the fullscreen minimum-size family.Determinism
Two tests previously leaned on ambient state and no longer do:
vfsStreamdirectory, matching the conventionFilePickerWidgetTestalready follows.testDateWithNonStringCurrentOpensOnTodaycomputed its expectation after the widget had already resolved today, leaving a midnight window. It now reads the date either side of the call and accepts either boundary.Two adjacent cleanups
The issue's own analysis called out repetition that is not data-provider work, so it landed as separate commits that can be reverted independently:
BuildsThemesTrait::plainTheme()already existed andPanelControllerTestalready used the trait, yet wrote that exact theme literal out 15 times. Those now call the helper. The other 17DefaultThemeconstructions in the file differ genuinely and were left alone.Enter/Enteropener repeated in 16 test bodies is nowdrillAndEdit(), which names what those two keystrokes do.Verification
composer test- 2239 tests, 4886 assertions, green.composer test-coverage- line coverage identical to the pre-change baseline onForm,LayoutGuard,PanelBuilder,FieldBuilder,InputResolver,WidgetFactory,SchemaGenerator,AgentHelpandPanelController;FilePickerWidgetremains at 100%. This was the pass or fail gate rather than the assertion count, since a deleted assertion also passes a green suite.composer lint- PHPCS, PHPStan level 9 and Rector all clean. Two test methods gained docblocks because PHPStan neededlist<string>andclass-stringnarrowing that the project's iterable-value-type waiver does not cover.Before / After