Skip to content

testing: rewrite widget coverage around expected behavior#366

Merged
RtlZeroMemory merged 3 commits intomainfrom
epic-323-rewrite-wave-1
Apr 14, 2026
Merged

testing: rewrite widget coverage around expected behavior#366
RtlZeroMemory merged 3 commits intomainfrom
epic-323-rewrite-wave-1

Conversation

@RtlZeroMemory
Copy link
Copy Markdown
Owner

@RtlZeroMemory RtlZeroMemory commented Apr 14, 2026

Scope

Areas Touched

  • input and textarea
  • modal, overlay, and focus
  • select and dropdown
  • table, tree, and virtual list

Old Tests Removed Or Merged

  • removed packages/core/src/app/__tests__/table.renderCache.test.ts because it only asserted cache identity/reuse and did not protect visible table behavior
  • retained lower-level helper/route tests in inputEditor.*, focus.layers.test.ts, overlayUnification.test.ts, dropdown.position.test.ts, table.*, virtualList.*, and tree.* where they still protect deterministic lower-level contracts not replaced by the new behavior oracles

New Behavior Oracles Introduced

  • app-level modal oracle for Escape close plus returnFocusTo focus restore
  • app-level modal backdrop oracle for close-on-backdrop vs blocked background activation
  • app-level disabled input/textarea and disabled select focus behavior
  • dropdown item-click select-and-close oracle
  • controlled table visible-order oracle tied to sort state and row activation
  • virtual-list selection and scroll callback oracle
  • tree lazy-load visible-child-before-activation oracle
  • shared semantic scenario for textarea multiline editing
  • shared semantic scenario for keyboard-only select cycling with disabled-option skip

Test Commands Run

  • npm install
  • ./node_modules/.bin/biome check packages/core/src/app/__tests__/widgetBehavior.contracts.test.ts packages/core/src/testing/__tests__/referenceScenario.semantic.test.ts
  • ./node_modules/.bin/tsc -b packages/core/tsconfig.json packages/node/tsconfig.json --pretty false
  • npm -w @rezi-ui/native run build:native
  • node --test packages/core/dist/app/__tests__/widgetBehavior.contracts.test.js packages/core/dist/testing/__tests__/referenceScenario.semantic.test.js packages/core/dist/testing/__tests__/scenarioHarness.test.js packages/node/dist/__tests__/testingHarness.test.js packages/node/dist/__tests__/ptyScenario.test.js

Known Unresolved Areas Left For Later

  • dropdown outside-click close is still deferred because EPIC EPIC: Widget contracts and scenario schema #321 called the integrated evidence thinner than item-click and escape paths
  • select pointer behavior beyond focus remains intentionally conservative
  • tree failure/loading error presentation remains under-specified
  • shared cursor assertions are still omitted until semantic/PTY cursor normalization is resolved

Summary by CodeRabbit

  • Tests

    • Added comprehensive widget behavior contract tests covering disabled inputs, modals, focus management, overlays, and table sorting interactions.
    • Added new reference testing scenarios for select keyboard navigation and textarea multiline editing.
    • Expanded testing utilities with additional scenario fixtures for enhanced test coverage.
    • Removed deprecated table render cache test suite.
  • Chores

    • Updated CI environment detection in test utilities for improved type safety.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 14, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4dd2b678-7184-4098-af4b-29a0e511ed85

📥 Commits

Reviewing files that changed from the base of the PR and between a388a1c and 5d7cf9e.

📒 Files selected for processing (2)
  • packages/core/src/app/__tests__/widgetBehavior.contracts.test.ts
  • packages/core/src/testing/__tests__/referenceScenario.semantic.test.ts

📝 Walkthrough

Walkthrough

The PR removes a legacy table render-cache test suite and introduces a comprehensive testing framework with new reference scenarios for select keyboard navigation and textarea multiline editing, alongside extensive contract tests covering widget interactions including focus management, modals, overlays, sorting, and tree expansion. Minor CI environment variable typing improvements are also applied.

Changes

Cohort / File(s) Summary
Test Cleanup
packages/core/src/app/__tests__/table.renderCache.test.ts
Deleted entire test suite verifying table render cache behavior for row key derivation reuse and selection set caching across rebuild cycles.
Reference Scenarios
packages/core/src/testing/referenceScenarios/selectKeyboardCycler.ts, packages/core/src/testing/referenceScenarios/textareaMultilineEditing.ts
Added two new reference scenario modules: select keyboard cycler verifies disabled option skipping with Enter/Space navigation; textarea multiline editing verifies newline insertion and cursor position updates during editing.
Testing Exports
packages/core/src/testing/index.ts
Added re-exports for new reference scenarios and fixture factories: referenceTextareaMultilineScenario, createReferenceTextareaMultilineFixture, referenceSelectKeyboardCyclerScenario, createReferenceSelectKeyboardCyclerFixture.
Contract Tests
packages/core/src/app/__tests__/widgetBehavior.contracts.test.ts
Added comprehensive contract test suite covering disabled widget exclusion from focus, modal lifecycle (open/close/focus restoration/backdrop click behavior), dropdown overlay interactions, table sorting and keyboard navigation, virtual list selection/scroll behavior, and tree asynchronous child loading with ordered event sequencing.
Semantic Scenario Tests
packages/core/src/testing/__tests__/referenceScenario.semantic.test.ts
Added three semantic tests validating reference scenarios for input modal pause/resume, textarea multiline editing, and select keyboard cycling with pass/mismatch assertions.
CI Environment Detection
packages/node/src/__tests__/ptyScenario.test.ts, packages/node/src/__tests__/testingHarness.test.ts
Introduced typed env alias for process.env to improve CI environment variable access with proper type safety in macOS CI detection logic.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related issues

  • EPIC: Rewrite wave 1 for critical widgets #323: Changes directly implement the EPIC goal of rewriting/removing wave-1 widget tests by replacing table render-cache tests with behavior-focused contract tests and new reference scenarios covering the same widget areas (input, textarea, select, modal, table, tree, virtual list).
  • Task: Rewrite table, tree, and virtual list tests around expected behavior #347: Changes remove the old table render-cache tests and add new contract tests explicitly covering table sorting, virtual list selection/scroll behavior, and tree expansion, directly matching the task to rewrite table, tree, and virtual list tests.

Possibly related PRs

Poem

🐰 Old tests gave way to contracts new,
Select and textarea dance on cue,
Modals close, trees expand with grace,
Widget behavior finds its place! ✨🎭

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: rewriting wave-1 widget test coverage to focus on expected behavioral contracts rather than implementation details like render caching.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch epic-323-rewrite-wave-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.

❤️ Share

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

@RtlZeroMemory RtlZeroMemory marked this pull request as ready for review April 14, 2026 11:54
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
packages/node/src/__tests__/testingHarness.test.ts (1)

14-15: Type safety improvement for CI environment variable access.

The explicit typing matches the pattern in ptyScenario.test.ts and improves type safety for the CI environment check. The duplication across two test files is acceptable, though if this pattern appears in additional files, consider extracting it to a shared test utility.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/node/src/__tests__/testingHarness.test.ts` around lines 14 - 15,
Replace the plain process.env access with a typed environment object to improve
type safety: cast process.env to NodeJS.ProcessEnv & Readonly<{ CI?: string }>
and use that typed variable when computing isMacOsCi (the symbols to change are
env and isMacOsCi); follow the same pattern used in ptyScenario.test.ts so the
CI check becomes process.platform === "darwin" && env.CI === "true".
packages/core/src/app/__tests__/wave1.behavior.test.ts (1)

344-346: Hardcoded coordinates may be fragile.

The click coordinates (2, 3) assume a specific layout for the dropdown items. If the dropdown positioning or item rendering changes, this test could break silently or click the wrong item.

Consider using centerOf(renderer, "dd-item-two") or a similar approach if dropdown items expose IDs, or add a comment explaining the expected layout.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/core/src/app/__tests__/wave1.behavior.test.ts` around lines 344 -
346, The test uses hardcoded coordinates in
renderer.routeEngineEvent(mouseEvent(...)) which is fragile; replace the literal
(2,3) coords with a computed target (e.g., const target = centerOf(renderer,
"dd-item-two") or another helper that resolves the dropdown item's center) and
pass target.x/target.y into mouseEvent, then call
renderer.routeEngineEvent(mouseEvent(...)) and submit(renderer, view) as before
so the click targets the correct dropdown item regardless of layout changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/core/src/app/__tests__/wave1.behavior.test.ts`:
- Around line 344-346: The test uses hardcoded coordinates in
renderer.routeEngineEvent(mouseEvent(...)) which is fragile; replace the literal
(2,3) coords with a computed target (e.g., const target = centerOf(renderer,
"dd-item-two") or another helper that resolves the dropdown item's center) and
pass target.x/target.y into mouseEvent, then call
renderer.routeEngineEvent(mouseEvent(...)) and submit(renderer, view) as before
so the click targets the correct dropdown item regardless of layout changes.

In `@packages/node/src/__tests__/testingHarness.test.ts`:
- Around line 14-15: Replace the plain process.env access with a typed
environment object to improve type safety: cast process.env to NodeJS.ProcessEnv
& Readonly<{ CI?: string }> and use that typed variable when computing isMacOsCi
(the symbols to change are env and isMacOsCi); follow the same pattern used in
ptyScenario.test.ts so the CI check becomes process.platform === "darwin" &&
env.CI === "true".

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a99a1873-0846-4289-ab65-24a1e01869e6

📥 Commits

Reviewing files that changed from the base of the PR and between 12ef46b and a388a1c.

📒 Files selected for processing (8)
  • packages/core/src/app/__tests__/table.renderCache.test.ts
  • packages/core/src/app/__tests__/wave1.behavior.test.ts
  • packages/core/src/testing/__tests__/wave1ScenarioHarness.test.ts
  • packages/core/src/testing/index.ts
  • packages/core/src/testing/referenceScenarios/selectKeyboardCycler.ts
  • packages/core/src/testing/referenceScenarios/textareaMultilineEditing.ts
  • packages/node/src/__tests__/ptyScenario.test.ts
  • packages/node/src/__tests__/testingHarness.test.ts
💤 Files with no reviewable changes (1)
  • packages/core/src/app/tests/table.renderCache.test.ts

@RtlZeroMemory RtlZeroMemory changed the title testing: rewrite wave-1 widget coverage around expected behavior testing: rewrite widget coverage around expected behavior Apr 14, 2026
@RtlZeroMemory RtlZeroMemory merged commit c819b99 into main Apr 14, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant