Skip to content

refactor: bring 18 more files under 300 lines via partial class and spec splits#110

Merged
antosubash merged 2 commits intomainfrom
feature/frosty-mirzakhani
Apr 15, 2026
Merged

refactor: bring 18 more files under 300 lines via partial class and spec splits#110
antosubash merged 2 commits intomainfrom
feature/frosty-mirzakhani

Conversation

@antosubash
Copy link
Copy Markdown
Owner

Summary

Continues df56c1b's effort to keep every source file under 300 lines. Splits the 14 test files, DevCommand.cs, and 3 E2E/k6 scenario files documented as "remaining" in tasks/todo.md. Generator internals and NewProjectCommand.cs are intentionally out of scope for this batch (left for a follow-up that needs more care).

  • C# tests (14 files) — split by feature area using partial class so xUnit discovery, [Collection] attributes, and fixture construction are unchanged. Covers Chat, PageBuilder, Email, FileStorage, BackgroundJobs, DevTools, Database, Core events, LoadTest/Shared factories, and CLI scaffold tests.
  • cli/SimpleModule.Cli/Commands/Dev/DevCommand.cs (777 → 230) — split Unix process signal helpers, graceful shutdown, and misc helpers into DevCommand.Signals.cs, DevCommand.Shutdown.cs, DevCommand.Helpers.cs. Mirrors the precedent set by ViteDevWatchService.{Logging,Helpers,Process}.cs.
  • tests/e2e/tests/flows/pagebuilder-crud.spec.ts (414) and menu-manager-crud.spec.ts (368) — split into topic-scoped .spec.ts files under subfolders, with non-.spec helper modules for shared setup so Playwright doesn't try to run them as tests.
  • tests/k6/scenarios/hotspots.ts (365) — now a thin entry point that re-exports scenario functions from sibling files (metrics.ts, summary.ts, requests-core/admin/tenants.ts). k6 entry exports (default, setup, options, handleSummary) preserved.

Why

The under-300-line rule was introduced in df56c1b; this PR finishes the work it left open (minus the generator/CLI-new bucket, which is gnarlier). No behavior changes — all file splits are pure code movement.

Reviewer notes

  • ViteDevWatchServiceTests.*.cs renamed. The original test file held 5 independent top-level classes, not a partial. The initial split mirrored its name with dot-suffixes, which would mislead future readers into thinking it was a partial. Renamed to FileWatcherIntegrationTests.cs, ServiceLifecycleTests.cs, DiscoverModuleDirectoriesTests.cs, FindRepoRootTests.cs, PathMatchingTests.cs.
  • EntityInterceptorTests test entities are nested back inside the partial class. The initial split moved 7 entity types and 2 DbContexts to a sibling file at namespace scope (forcing them public). Restored as private sealed class nested in the partial to match the original visibility.
  • packages/SimpleModule.Client/src/routes.ts is intentionally NOT committeddotnet build regenerates it and the repo convention (captured in tasks/todo.md:99) is to revert it before committing.

Test plan

  • npm run check — 0 errors, 0 warnings, typecheck 19/19
  • npm run build — all workspaces built
  • dotnet build — 0 warnings, 0 errors
  • dotnet test (excl. LoadTests) — ~1,226 passed, 0 failed, 1 skipped
  • npm run test:smoke -w tests/e2e — 68/68 passed (3 Map smoke tests were flaky on first run, passed on both subsequent runs; Map code was not touched in this PR)

…ass extraction

Split 13 React pages by extracting sub-components, tab panels, filter
toolbars, and chart helpers into sibling components/ folders. Split 7
C# services using the partial class pattern (by responsibility: query
vs command, logging, export). Split 2 UI library components (chart.tsx
and public-layout.tsx) into focused per-concern files.

Build 0W/0E, npm typecheck 19/19, npm lint clean. Remaining 32 files
(generator internals, tests, CLI commands, E2E specs) documented in
tasks/todo.md for future batches.
…pec splits

Continues the effort started in df56c1b to keep every source file under 300
lines. Splits 14 C# test files, the DevCommand CLI orchestrator, and 3 E2E/k6
scenario files using the same partial-class pattern established for services
in the previous batch.

- Tests (14 files) — split by feature area using partial class so xUnit
  discovery, [Collection] attributes, and fixture construction are preserved.
  Covers Chat, PageBuilder, Email, FileStorage, BackgroundJobs, DevTools,
  Database, Core (events), LoadTest/Shared factories, and Cli scaffold tests.
- DevCommand.cs (777 -> 230) — split process signal helpers (Unix SIGTERM
  descendants), graceful shutdown, and misc helpers into sibling partials.
- pagebuilder-crud.spec.ts (414) and menu-manager-crud.spec.ts (368) — split
  into topic-scoped .spec.ts files under subfolders, with a non-.spec helper
  module for shared setup so Playwright does not try to run it.
- hotspots.ts (365) — converted to a thin k6 entry point re-exporting the
  scenario request functions and options from sibling modules (metrics,
  summary, requests-core/admin/tenants).
- Renamed the ViteDevWatchServiceTests.* split files to match their actual
  sibling class names (they are not partials — each file is a distinct
  xUnit class) to avoid misleading naming.
- Nested test entities in EntityInterceptorTests back inside the partial
  class as private sealed nested types to restore their original visibility
  after the split exposed them at namespace scope.

Generator internals (framework/SimpleModule.Generator/**, the corresponding
*.Tests, and NewProjectCommand.cs) are intentionally left in tasks/todo.md
for a follow-up batch; they need more care than a mechanical split.

Verification:
- dotnet build: 0W/0E
- dotnet test (all except LoadTests): ~1,226 passed, 0 failed, 1 skipped
- npm run check: 0 errors, 0 warnings, typecheck 19/19
- npm run build: all workspaces built
- e2e smoke (68 tests): all passed
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying simplemodule-website with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6722c41
Status: ✅  Deploy successful!
Preview URL: https://6905add4.simplemodule-website.pages.dev
Branch Preview URL: https://feature-frosty-mirzakhani.simplemodule-website.pages.dev

View logs

@antosubash antosubash merged commit a5aaaaf into main Apr 15, 2026
5 checks passed
@antosubash antosubash deleted the feature/frosty-mirzakhani branch April 15, 2026 18:01
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