Skip to content

Conversation

@ajayi-joseph
Copy link
Contributor

@ajayi-joseph ajayi-joseph commented Jan 2, 2026

Overview

Refactored the large use_state_js_test.dart file (1914 lines) by breaking each test group into separate, focused test files following the project's "no groups" philosophy. Also removed duplicate test files and consolidated their content.

Changes Made

Files Removed

  • test/use_state_js_test.dart - Massive 1914-line file with all test groups
  • test/semantic_elements_test.dart - Duplicate file was deleted as it was a duplicate of test/use_state_js_test.dart

New Test Files Created

Hook Tests (test/hooks/)

  • use_state_test.dart - useState hook functionality tests
  • use_state_js_array_test.dart - useStateJSArray hook tests
  • use_state_lazy_test.dart - useStateLazy hook tests
  • use_effect_test.dart - useEffect hook tests
  • use_layout_effect_test.dart - useLayoutEffect hook tests
  • use_reducer_test.dart - useReducer hook tests
  • use_reducer_lazy_test.dart - useReducerLazy hook tests
  • use_context_test.dart - useContext hook tests
  • use_ref_test.dart - useRef hook tests
  • create_ref_test.dart - createRef function tests
  • use_memo_test.dart - useMemo hook tests
  • use_callback_test.dart - useCallback hook tests

Component Tests (test/components/)

  • component_utilities_test.dart - forwardRef, memo, Children utilities
  • special_components_test.dart - Fragment, StrictMode, cloneElement, isValidElement
  • rendering_test.dart - conditional and list rendering
  • composition_test.dart - component composition patterns

Feature Tests

  • test/events/event_handling_test.dart - Event handling functionality
  • test/elements/html_elements_test.dart - HTML element rendering
  • test/jsx/jsx_dsl_test.dart - JSX DSL syntax tests

Benefits

  • Maintainable: Each test file focuses on a single feature/hook
  • Organized: Logical directory structure by functionality
  • No Groups: Eliminates test groups as requested in TODO comment
  • No Duplicates: Removed duplicate files and consolidated content
  • Complete Coverage: All 271 tests maintained and passing
  • Focused: Individual files are easier to understand and modify

Test Results

  • Before: 271 tests passing in 1 massive file
  • After: 271 tests passing across 17 focused files
  • Zero test loss: Complete preservation of test coverage

File Organization

test/
├── hooks/           # React hook tests (13 files)
├── components/      # Component utilities (4 files) 
├── events/          # Event handling (1 file)
├── elements/        # HTML elements (1 file)
└── jsx/             # JSX DSL (1 file)

This refactoring addresses the explicit TODO comment: // TODO: Break each group into separate files. No groups! and significantly improves test maintainability.

@MelbourneDeveloper
Copy link
Owner

Overview

Refactored the large use_state_js_test.dart file (1914 lines) by breaking each test group into separate, focused test files following the project's "no groups" philosophy. Also removed duplicate test files and consolidated their content.

Changes Made

Files Removed

  • test/use_state_js_test.dart - Massive 1914-line file with all test groups

  • test/semantic_elements_test.dart - Duplicate file was deleted as it was a duplicate of test/use_state_js_test.dart

New Test Files Created

Hook Tests (test/hooks/)

  • use_state_test.dart - useState hook functionality tests

  • use_state_js_array_test.dart - useStateJSArray hook tests

  • use_state_lazy_test.dart - useStateLazy hook tests

  • use_effect_test.dart - useEffect hook tests

  • use_layout_effect_test.dart - useLayoutEffect hook tests

  • use_reducer_test.dart - useReducer hook tests

  • use_reducer_lazy_test.dart - useReducerLazy hook tests

  • use_context_test.dart - useContext hook tests

  • use_ref_test.dart - useRef hook tests

  • create_ref_test.dart - createRef function tests

  • use_memo_test.dart - useMemo hook tests

  • use_callback_test.dart - useCallback hook tests

Component Tests (test/components/)

  • component_utilities_test.dart - forwardRef, memo, Children utilities

  • special_components_test.dart - Fragment, StrictMode, cloneElement, isValidElement

  • rendering_test.dart - conditional and list rendering

  • composition_test.dart - component composition patterns

Feature Tests

  • test/events/event_handling_test.dart - Event handling functionality

  • test/elements/html_elements_test.dart - HTML element rendering

  • test/jsx/jsx_dsl_test.dart - JSX DSL syntax tests

Benefits

  • Maintainable: Each test file focuses on a single feature/hook

  • Organized: Logical directory structure by functionality

  • No Groups: Eliminates test groups as requested in TODO comment

  • No Duplicates: Removed duplicate files and consolidated content

  • Complete Coverage: All 271 tests maintained and passing

  • Focused: Individual files are easier to understand and modify

Test Results

  • Before: 271 tests passing in 1 massive file

  • After: 271 tests passing across 17 focused files

  • Zero test loss: Complete preservation of test coverage

File Organization


test/

├── hooks/           # React hook tests (13 files)

├── components/      # Component utilities (4 files) 

├── events/          # Event handling (1 file)

├── elements/        # HTML elements (1 file)

└── jsx/             # JSX DSL (1 file)

This refactoring addresses the explicit TODO comment: // TODO: Break each group into separate files. No groups! and significantly improves test maintainability.

First PR! Thanks. Will have a look soon

@ajayi-joseph
Copy link
Contributor Author

More to come 😀

@ajayi-joseph
Copy link
Contributor Author

@MelbourneDeveloper . Had a look yet?

@MelbourneDeveloper
Copy link
Owner

MelbourneDeveloper commented Jan 17, 2026

Hi @ajayi-joseph . Thanks for the PR. Unfortunately, this kind of PR is really difficult to check because I can't eyeball anything and I have to use other means to review. It's good to break up huge files like this, but I'd recommend doing it in small steps instead of doing everything all at once.

The worrying thing is that it removes almost 4k LOC but only puts back 2k:
image

According to AI, there are 68 tests missing:

Branch Test Count
main 339
ja 271
Missing 68

Will do a bit more investigation, but I still have no real way of knowing if the tests haven't changed.


Edit: it's all good! There was a duplicate test file there, which explains the 68 extra tests.

Thanks!

@MelbourneDeveloper MelbourneDeveloper merged commit 625eda7 into MelbourneDeveloper:main Jan 17, 2026
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.

2 participants