311 Commits

Author SHA1 Message Date
Felipe Cardoso
6d1b730ae7 Add _hasHydrated flag to authStore and update AuthGuard to wait for store hydration, ensuring stability during loading phases in tests and app. 2025-11-02 14:16:56 +01:00
Felipe Cardoso
29f98f059b **Add comprehensive backend documentation for FastAPI setup, configuration, and architecture** 2025-11-02 14:11:34 +01:00
Felipe Cardoso
b181182c3b **Authentication Refactor:** Remove authStore and its associated tests, transitioning to the new authentication model. Add dynamic loading for PasswordResetConfirmForm to optimize performance. Include a theme initialization script in layout.tsx to prevent FOUC. 2025-11-02 14:00:05 +01:00
Felipe Cardoso
92b7de352c **Docs and Code Enhancements:** Add CodeBlock component with copy functionality and syntax highlighting. Introduce /docs page as the central hub for design system documentation. Update MarkdownContent to support improved heading styles, enhanced links, optimized images with Next.js Image, and upgraded table, blockquote, and list styling for better readability and usability. 2025-11-02 13:47:26 +01:00
Felipe Cardoso
aff76e3a69 Update implementation plan to reflect Phase 2.5 completion, documenting design system integration, UI consistency, and enhanced test coverage (97.57%). 2025-11-02 13:34:50 +01:00
Felipe Cardoso
13771c5354 **Design System Enhancements:** Replace .md links with clean paths in /dev documentation. Migrate anchor tags (<a>) to Next.js <Link> components for internal navigation. Add dynamic [...slug] markdown route for rendering docs. Introduce MarkdownContent for styled markdown rendering with syntax highlighting. Perform general cleanup of unused imports and variables in design system files. Fix minor wording issues. 2025-11-02 13:33:47 +01:00
Felipe Cardoso
c3c6a18dd1 **Test Documentation Update:** Simplify test coverage description and clarify security-focused testing features, including CVE-2015-9235 prevention, session hijacking, and privilege escalation. 2025-11-02 13:28:49 +01:00
Felipe Cardoso
68e7ebc4e0 - **Middleware & Security Enhancements:** Add request size limit middleware to prevent DoS attacks via large payloads (10MB max).
- **Authentication Refactor:** Introduce `_create_login_session` utility to streamline session creation for login and OAuth flows.
- **Configurations:** Dynamically set app name in PostgreSQL connection (`application_name`) and adjust token expiration settings (`expires_in`) based on system configuration.
2025-11-02 13:25:53 +01:00
Felipe Cardoso
df299e3e45 Add pointer cursor style for interactive elements and exception for disabled states 2025-11-02 13:21:57 +01:00
Felipe Cardoso
8e497770c9 Add Dev Hub for interactive design system demos and /dev/forms with validation examples
- **Design System Hub:** Introduce `/dev` as a central hub for interactive design system showcases (components, layouts, spacing, etc.). Includes live demos, highlights, and documentation links.
- **Forms Demo:** Add `/dev/forms` for reactive forms with `react-hook-form` and `Zod`. Demonstrate validation patterns, error handling, loading states, and accessibility best practices.
- **Features:** Showcase reusable `Example`, `ExampleSection`, and `BeforeAfter` components for better UI demonstration and code previews.
2025-11-02 13:21:53 +01:00
Felipe Cardoso
58b761106b Add reusable Example, ExampleGrid, and ExampleSection components for live UI demonstrations with code previews. Refactor ComponentShowcase to use new components, improving structure, maintainability, and documentation coverage. Include semantic updates to labels and descriptions. 2025-11-02 13:21:25 +01:00
Felipe Cardoso
e734acf31d **Design System Documentation:** Add comprehensive project progress documentation summarizing Phase 1 completion, including created files, cleanup, and review results. Outline Phase 2 interactive demo plans and next steps. Reflect structure, content philosophy, and AI optimization guidelines. 2025-11-02 12:42:42 +01:00
Felipe Cardoso
76d36e1b12 - **Authentication & Lifespan Updates:** Add @asynccontextmanager for application lifecycle management, including startup/shutdown handling and daily session cleanup scheduling. Reduce token expiration from 24 hours to 15 minutes for enhanced security. Streamline superuser field validation via schema, removing redundant defensive checks. 2025-11-02 12:38:09 +01:00
Felipe Cardoso
6e95469d99 Remove version file 2025-11-02 12:34:47 +01:00
Felipe Cardoso
6d9b98943c Update documentation and tests for coverage, email integration, and authentication
- **Backend Documentation:** Improve authentication flow details, update token expiry times, and reflect defensive code in test coverage. Add guidance for email service integration with SMTP and third-party providers.
- **Test Coverage:** Backend overall coverage increased to **97%** with critical security tests added (JWT attacks, session hijacking, privilege escalation). Justify missing lines and update CI instructions.
- **Frontend Updates:** Update E2E worker configuration (`workers: 12` in non-CI mode) and maintain 100% E2E test pass rate.
- **Default Implementations:** Enhance email service with templates for registration and password resets. Document integration options for production use cases.
- **Consistency Improvements:** Align naming conventions and test configurations across backend and frontend to reflect current system architecture.
2025-11-02 12:32:08 +01:00
Felipe Cardoso
30cbaf8ad5 Add documentation for component creation and design system structure
- **Component Creation Guide:** Document best practices for creating reusable, accessible components using CVA patterns. Includes guidance on when to compose vs create, decision trees, templates, prop design, testing checklists, and real-world examples.
- **Design System README:** Introduce an organized structure for the design system documentation with quick navigation, learning paths, and reference links to key topics. Includes paths for quick starts, layouts, components, forms, and AI setup.
2025-11-02 12:32:01 +01:00
Felipe Cardoso
13f830ed6d Remove E2E tests for authenticated navigation and theme toggle 2025-11-02 12:30:57 +01:00
Felipe Cardoso
c051bbf0aa Add security tests for configurations, permissions, and authentication
- **Configurations:** Test minimum `SECRET_KEY` length validation to prevent weak JWT signing keys. Validate proper handling of secure defaults.
- **Permissions:** Add tests for inactive user blocking, API access control, and superuser privilege escalation across organizational roles.
- **Authentication:** Test logout safety, session revocation, token replay prevention, and defense against JWT algorithm confusion attacks.
- Include `# pragma: no cover` for unreachable defensive code in security-sensitive areas.
2025-11-02 11:55:58 +01:00
Felipe Cardoso
b39b7b4c94 Add E2E tests for authenticated navigation and theme toggle
- **Authenticated Navigation:** Test header, footer, settings navigation, user menu interactions, and settings tabs for authenticated users. Validate logout and active tab highlighting.
- **Theme Toggle:** Add tests for theme persistence and switching on both public and private pages. Verify localStorage integration and DOM updates across scenarios.
2025-11-02 07:56:31 +01:00
Felipe Cardoso
9f88736d13 Add comprehensive tests for schemas, validators, and exception handlers
- **Schemas:** Introduce unit tests for `OrganizationBase`, `OrganizationCreate`, and `OrganizationUpdate` schemas. Validate edge cases for slug and name validation.
- **Validators:** Add tests for `validate_password_strength`, `validate_phone_number`, `validate_email_format`, and `validate_slug`. Cover edge cases, boundary conditions, and defensive code paths.
- **Exception Handlers:** Ensure proper error handling in organization, user, and session CRUD operations. Mock database errors and validate exception responses.
- Include test cases to verify robust behavior, normalization, and failure scenarios across schema and validation logic.
2025-11-02 07:56:23 +01:00
Felipe Cardoso
ccd535cf0e Add # pragma: no cover to defensive code sections in validators and CRUD operations
- Mark unreachable code paths in `validators.py` and `base.py` with `# pragma: no cover` for coverage accuracy.
- Add comments to clarify defensive code's purpose and usage across methods.
2025-11-02 07:42:24 +01:00
Felipe Cardoso
30dca45097 Increase Jest coverage thresholds to enforce higher test quality 2025-11-02 07:35:50 +01:00
Felipe Cardoso
a460e0e4f2 Add unit tests for core components and layouts
- **ThemeToggle:** Introduce comprehensive tests to validate button functionality, dropdown options, and active theme indicators.
- **ThemeProvider:** Add tests for theme management, localStorage persistence, system preferences, and DOM updates.
- **Header & Footer:** Verify header rendering, user menu functionality, and footer content consistency.
- **AuthInitializer:** Ensure authentication state is correctly loaded from storage on mount.
2025-11-02 07:35:45 +01:00
Felipe Cardoso
08511ae07b Add comprehensive tests for database utilities and operations
- Introduce unit and integration tests for `get_async_database_url`, `get_db`, `async_transaction_scope`, `check_async_database_health`, `init_async_db`, and `close_async_db`.
- Cover success and failure scenarios, including session cleanup, transaction rollbacks, and database health checks.
- Ensure robust handling of exceptions and validation of utility function outputs across async database operations.
2025-11-02 07:00:35 +01:00
Felipe Cardoso
1439380126 Add Component Showcase and development preview page
- Introduce `ComponentShowcase` to display all design system components (buttons, cards, alerts, etc.) for development and testing purposes.
- Create a dedicated `/dev/components` route for accessing the showcase.
- Ensure reuse of existing `shadcn/ui` components with appropriate styling.
- Update `PasswordResetConfirmForm` to use `bg-muted` for the password strength indicator background.
2025-11-02 06:58:27 +01:00
Felipe Cardoso
378b04d505 Update semantic color tokens across components for improved consistency
- Refactor `text-*` and `bg-*` classes to use semantic color tokens such as `foreground`, `muted-foreground`, `card`, and `accent`.
- Adjust `Header`, `Footer`, and settings pages to align with the OKLCH-based design system.
- Ensure visual consistency and accessibility for both light and dark themes.
2025-11-02 06:55:18 +01:00
Felipe Cardoso
af260e4748 Add theme toggle with light, dark, and system support
- **Header:** Integrate `ThemeToggle` component into the user menu area.
- **Theme Provider:** Introduce `ThemeProvider` context for managing and persisting theme preferences.
- **New Components:** Add `ThemeToggle` for switching themes and `ThemeProvider` to handle state and system preferences.
- Ensure responsive updates and localStorage persistence for user-selected themes.
2025-11-02 06:53:46 +01:00
Felipe Cardoso
30f0ec5a64 Document initial design system guidelines and implementation details
- Introduce FastNext Design System based on `shadcn/ui` and `Tailwind CSS 4`.
- Detail semantic color tokens using the OKLCH color space for better accessibility.
- Define typography, spacing, shadows, and border radius standards.
- Provide component usage guidelines for consistent and accessible design.
- Outline responsive design, performance, and accessibility best practices.
- Add dark mode implementation strategy and tooling references.
- Include a version history for change tracking and future updates.
2025-11-02 06:49:43 +01:00
Felipe Cardoso
04110cbf1c Refactor Tailwind CSS setup and introduce OKLCH-based design system
- **Tailwind Config:** Clear custom config path and update base color to `zinc`.
- **Design System:** Replace existing CSS with OKLCH color model for improved accessibility and uniformity.
- **Typography & Themes:** Use Geist fonts, define light/dark themes with enhanced semantic variables.
- **Global Styles:** Add consistent border colors, smooth transitions, and reusable variables for Tailwind integration.
2025-11-02 06:49:34 +01:00
Felipe Cardoso
461d3caf31 Add comprehensive tests for security headers, permissions, CRUD operations, and organizations
- **Security Headers:** Add tests for HSTS in production, CSP in strict mode, and root endpoint response types.
- **Permissions:** Introduce tests for critical security paths, including superuser bypass and edge case scenarios.
- **CRUD Testing Enhancements:** Cover error scenarios for soft deletes, restores, and eager loading with SQLAlchemy options.
- **Organization Routes:** Validate user organization endpoints for memberships, details, and member listings.
- Add defensive code comments with `# pragma: no cover` for unreachable code sections.
2025-11-02 06:10:04 +01:00
Felipe Cardoso
789a76071d Refactor auth store tests to use createMockUser helper for improved readability and reusability 2025-11-02 05:59:30 +01:00
Felipe Cardoso
4536c607eb Add settings layout and page structure for authenticated routes
Introduce tabbed navigation for the settings page, including Profile, Password, Sessions, and Preferences sections. Add placeholders for each section with metadata and routes. Redirect `/settings` to `/settings/profile`. Integrate `AuthGuard` for settings and authenticated layouts while incorporating reusable `Header` and `Footer` components.
2025-11-02 05:59:20 +01:00
Felipe Cardoso
bf04c98408 Add Header and Footer components for authenticated page layouts. 2025-11-02 05:59:08 +01:00
Felipe Cardoso
4885df80a7 Integrate AuthInitializer component to restore authentication state on app load and enhance User type to align with OpenAPI spec. 2025-11-02 05:59:00 +01:00
Felipe Cardoso
29ff97f726 Suppress non-essential console output in tests unless VERBOSE=true; adjust Playwright config to respect verbosity settings and use appropriate reporter. 2025-11-02 05:41:16 +01:00
Felipe Cardoso
406c3bcc82 Update coverage report with resolved tracking issue and 88% overall coverage
Resolved `pytest-cov` tracking for async routes by adjusting `.coveragerc` to include `greenlet` concurrency. Coverage improved from 79% to 88%, with significant gains across key modules like `admin.py` (46% → 98%). Updated details on coverage gaps and priorities for reaching 95% target.
2025-11-02 05:27:24 +01:00
Felipe Cardoso
1aab73cb72 Adjust .coveragerc to support concurrency options and skip test environment checks 2025-11-02 05:27:13 +01:00
Felipe Cardoso
f77f2700f2 Simplify token response in authentication route by returning the entire Token object instead of manually formatting a subset. 2025-11-02 04:53:09 +01:00
Felipe Cardoso
f354ec610b Add clean-slate target to Makefile for removing containers and volumes 2025-11-02 04:36:35 +01:00
Felipe Cardoso
e25b010b57 Include user information and token expiration in authentication responses
Updated the `Token` schema to include `user` data and `expires_in` field. Adjusted backend `auth_service.py` to populate these fields while generating tokens. Replaced `getCurrentUserInfo` with `getCurrentUserProfile` in the frontend and disabled ESLint for generated files to suppress warnings.
2025-11-02 04:36:29 +01:00
Felipe Cardoso
0b0d1d2b06 Update POSTGRES_DB value in .env.template to use a lowercase name 2025-11-02 04:11:59 +01:00
Felipe Cardoso
bc53504cbf Remove redundant /api/v1 suffix from API URL configuration and update related test 2025-11-02 04:11:41 +01:00
Felipe Cardoso
d75a8de91b Add validation to prevent privilege escalation via is_superuser field and enhance related tests
- Added explicit Pydantic validation to reject modifications to `is_superuser` in `UserUpdate` schema.
- Updated backend logic in `users.py` to support defense-in-depth against privilege escalation.
- Introduced comprehensive tests for `/users` and `/users/me` endpoints to ensure `is_superuser` validation works correctly.
- Enhanced error handling and validation messages for better clarity and robustness.
2025-11-01 16:15:03 +01:00
Felipe Cardoso
a82e5ea0e6 Add extensive tests for user, admin, and organization API endpoints
- Introduced comprehensive test coverage for user-related API endpoints (`/users`, `/users/me`), including edge cases and error scenarios.
- Added success and error path tests for admin routes, including user management (CRUD operations, bulk actions) and organization management.
- Enhanced test reliability through improved exception handling and validation.
- Included test-specific scenarios for handling unexpected errors and reporting gaps in coverage with actionable recommendations.
- Added detailed coverage report to track progress and identify improvement areas.
2025-11-01 15:59:29 +01:00
Felipe Cardoso
189ad948ac Mark dead code in users API related to is_superuser checks with # pragma: no cover 2025-11-01 15:54:58 +01:00
Felipe Cardoso
e2a8656f81 Improve navigation and URL validation in Playwright authentication tests
- Replaced `waitForTimeout` with `Promise.all` for navigation events to improve reliability.
- Updated URL assertions to support regex patterns for handling query parameters.
- Adjusted worker count in `playwright.config.ts` for improved performance in local environments.
2025-11-01 15:49:28 +01:00
Felipe Cardoso
ce5ed70dd2 Adjust Playwright authentication tests for Firefox compatibility
- Increased `waitForTimeout` to 1500ms in registration and password reset tests to account for slower rendering in Firefox.
- Simplified password reset validation error checks by relying on URL assertions instead of specific locators.
- Improved test reliability and cross-browser compatibility across authentication flows.
2025-11-01 14:31:10 +01:00
Felipe Cardoso
230210f3db Add comprehensive tests for user API endpoints
- Introduced unit tests for `/users` and `/users/me` routes, covering listing, filtering, fetching, updating, and access control scenarios.
- Added tests for user password change functionality, including validation and success paths.
- Enhanced coverage for superuser-specific and user-specific operations, error handling, and edge cases.
2025-11-01 14:31:03 +01:00
Felipe Cardoso
a9e972d583 Add extensive tests for handling CRUD and API error scenarios
- Introduced comprehensive tests for session CRUD error cases, covering exception handling, rollback mechanics, and database failure propagation.
- Added robust API error handling tests for admin routes, including user and organization management.
- Enhanced test coverage for unexpected errors, edge cases, and validation flows in session and admin operations.
2025-11-01 13:12:36 +01:00
Felipe Cardoso
a95b25cab8 Enhance Playwright test coverage and refactor e2e authentication tests
- Improved validation checks with element ID and class-specific locators for better accuracy and resilience.
- Removed outdated form behaviors (e.g., "Remember me" and test-only shortcuts) for updated flows.
- Refactored test cases to reflect backend changes, and standardized password validation and error messages.
- Updated selector usage to leverage `getByRole` for improved accessibility testing.
- Reorganized and optimized test timeouts and interactivity delays for faster execution.
2025-11-01 13:12:15 +01:00