Commit Graph

269 Commits

Author SHA1 Message Date
Felipe Cardoso
0e554ef35e Add tests for AuthGuard, Skeleton components, and AdminPage
- Enhance `AuthGuard` tests with 150ms delay skeleton rendering.
- Add new test files: `Skeletons.test.tsx` to validate skeleton components and `admin/page.test.tsx` for admin dashboard.
- Refactor `AuthGuard` tests to utilize `jest.useFakeTimers` for delay simulation.
- Improve coverage for loading states, fallback behavior, and rendering logic.
2025-11-02 17:07:15 +01:00
Felipe Cardoso
aedc770afb Update Lighthouse report for /settings/profile and fix runtime errors
- Updated `lighthouse-report.json` to reflect audit for `http://localhost:3000/settings/profile`.
- Resolved `CHROME_INTERSTITIAL_ERROR` runtime issues.
- Added HTTPS and performance audit metrics, improving accuracy and insights.
2025-11-02 16:59:36 +01:00
Felipe Cardoso
54c32bf97f Introduce AuthLoadingSkeleton and HeaderSkeleton for smoother loading, replace spinner in AuthGuard, update ReactQueryDevtools toggle, enable Docker ports for local development. 2025-11-02 16:56:23 +01:00
Felipe Cardoso
1b9854d412 Performance optimizations: Bundle size reduction
Optimizations implemented:
1. Font display: swap + preload for critical fonts
2. ReactQueryDevtools: Lazy load in dev only, exclude from production
3. Auth forms code splitting: LoginForm, PasswordResetRequestForm
4. Remove invalid swcMinify option (default in Next.js 15)

Results:
- Login page: 178 kB → 104 kB (74 kB saved, 42% reduction)
- Password reset: 178 kB → 104 kB (74 kB saved, 42% reduction)
- Homepage: 108 kB (baseline 102 kB shared + 6 kB page)

Remaining issue:
- 102 kB baseline shared by all pages (React Query + Auth loaded globally)
2025-11-02 16:16:13 +01:00
Felipe Cardoso
911d4a594e Introduce DevBreadcrumbs component for navigation and replace headers in /dev pages with breadcrumb navigation. Adjust spacing for consistent layout. 2025-11-02 16:07:39 +01:00
Felipe Cardoso
86d8e1cace Remove analysis documents (ANALYSIS_SUMMARY.md, COMPONENT_IMPLEMENTATION_GUIDE.md, DEV_PAGES_QUICK_REFERENCE.md) for /dev/ pages refactor. Content has been fully implemented in codebase. 2025-11-02 16:07:12 +01:00
Felipe Cardoso
2c05f17ec5 Fix authStore tests after reverting persist middleware
- Replace deprecation tests with functional tests
- Test loadAuthFromStorage actually loads tokens
- Test initializeAuth calls loadAuthFromStorage
- All 281 tests passing
2025-11-02 14:54:00 +01:00
Felipe Cardoso
68e28e4c76 Revert Zustand persist middleware approach and restore AuthInitializer
- Remove persist middleware from authStore (causing hooks timing issues)
- Restore original AuthInitializer component pattern
- Keep good Phase 3 optimizations:
  - Theme FOUC fix (inline script)
  - React Query refetchOnWindowFocus disabled
  - Code splitting for dev/auth components
  - Shared form components (FormField, useFormError)
  - Store location in lib/stores
2025-11-02 14:52:12 +01:00
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