Skip to content

Conversation

douglasduteil
Copy link
Contributor

  • Extract set_user middleware logic to loadUserPageVariables function
  • Implement type-safe context variables using factory pattern
  • Refactor GetUserById to support dynamic column selection with generics
  • Add comprehensive tests for GetUserById with real database testing
  • Follow clean architecture patterns for data loading
  • Establish naming convention: loadPageVariables for context data loading

- Extract set_user middleware logic to loadUserPageVariables function
- Implement type-safe context variables using factory pattern
- Refactor GetUserById to support dynamic column selection with generics
- Add comprehensive tests for GetUserById with real database testing
- Follow clean architecture patterns for data loading
- Establish naming convention: loadPageVariables for context data loading
- Add loadModerationPageVariables function for consolidated data loading
- Add loadOrganizationPageVariables function following same pattern
- Update context types to use Awaited<ReturnType<...>> for automatic type inference
- Document Page Variables Pattern convention in CONTRIBUTING.md
- Establish consistent naming: loadDomainPageVariables (e.g., loadUserPageVariables)
- Consolidate complex data loading logic into single source functions
- Enable better maintainability and type safety across domains
…ment

- Create reusable set_variables utility function in app/middleware/context/
- Replace middleware pattern with simple helper for bulk context variable setting
- Update users and organizations routes to use set_variables with loadPageVariables
- Fix TypeScript errors: remove missing GetOrganizationById export, add z_email_domain import
- Fix test syntax: use rejects.toThrow() for async promise rejection testing
- Maintain full type safety in route handlers while reducing code duplication
- Remove deprecated set_context_variables function and tests
- Refactor moderations/:id route to use set_variables with loadModerationPageVariables
- Refactor organizations/domaines route to use set_variables with loadDomainesPageVariables
- Update set_variables tests with Hono compatibility test
- Achieve complete unification: all complex routes now use consistent pattern
- Simplify codebase by removing 85 lines of complex middleware code

Benefits:
- Single responsibility: set_variables only handles bulk variable assignment
- Better maintainability: consistent pattern across all routes
- Improved testability: simple helper function vs complex middleware
- Type safety preserved: each route maintains proper TypeScript types
…y migration

- Unified all remaining API routes to use consistent set_variables pattern
- Migrated get_users_list to users repository following factory pattern
- Added comprehensive test suite for GetUsersList with snapshots
- Updated CONTRIBUTING.md with snapshot testing convention
- Request processing stays in middleware, page_title in render functions
- Clean architecture: data loading consolidated in loadPageVariables functions
- Updated repository testing conventions with real-world examples
- Added time control, multiple seed functions, and comprehensive coverage guidelines
- Enhanced example with GetUsersList showing snapshot testing best practices
- Documented mixed approach: snapshots for comprehensive validation + targeted assertions
- Included specific testing requirements for CRUD, edge cases, filtering, pagination
- Replace GetFicheOrganizationById usecase with GetOrganizationById repository in API contexts
- Eliminate duplicate organization fetching in organizations/:id route
- Consolidate organization and organization_fiche into single repository call
- Add missing columns for complete organization data (cached_categorie_juridique, etc.)
- Maintain backward compatibility while improving performance and consistency
@douglasduteil douglasduteil force-pushed the douglasduteil/refactor-get-user-by-id-dynamic-columns branch from 4077f05 to 7f38d45 Compare September 11, 2025 01:47
Add better test structure with explicit row navigation and context resets
to ensure stable domain status verification in moderation workflow.
Replace manual useRequestContext<IdentiteProconnect_Pg_Context>() calls
with usePageRequestContext from local context in duplicate warning component.
This follows the established pattern of using typed page contexts instead
of manual context access.
@github-actions github-actions bot added the 🚥 e2e End-to-end testing (flow check) label Sep 11, 2025
@douglasduteil douglasduteil marked this pull request as ready for review September 11, 2025 09:43
@douglasduteil douglasduteil merged commit 3f2b654 into master Sep 11, 2025
23 of 31 checks passed
@douglasduteil douglasduteil deleted the douglasduteil/refactor-get-user-by-id-dynamic-columns branch September 11, 2025 09:43
Copy link

🚀 This pull request is included in v2025.9.0. See Release 2025.9.0 for release notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant