Skip to content

feat: Add test suite for web#74

Merged
StoynovAngel merged 14 commits into
mainfrom
feat/add-coverage-for-frontend
May 20, 2026
Merged

feat: Add test suite for web#74
StoynovAngel merged 14 commits into
mainfrom
feat/add-coverage-for-frontend

Conversation

@StoynovAngel
Copy link
Copy Markdown
Owner

@StoynovAngel StoynovAngel commented May 20, 2026

Summary by CodeRabbit

  • Tests

    • Added comprehensive test suites for components, hooks, and services across frontend and web platforms
  • Chores

    • Added GitHub Actions workflows for automated testing on the main branch
    • Updated package configurations with testing dependencies
    • Added test setup and configuration files

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c518aa51-a775-4569-abed-00083f038811

📥 Commits

Reviewing files that changed from the base of the PR and between 83505e0 and 3005332.

⛔ Files ignored due to path filters (2)
  • frontend/package-lock.json is excluded by !**/package-lock.json
  • web/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (29)
  • .github/workflows/mobile-tests.yml
  • .github/workflows/web-tests.yml
  • frontend/jest.config.cjs
  • frontend/jest.setup.cjs
  • frontend/package.json
  • frontend/src/components/ErrorBoundary.test.tsx
  • frontend/src/components/company/CompanyCard.test.tsx
  • frontend/src/components/company/CompanyListHeader.test.tsx
  • frontend/src/components/company/EmptyState.test.tsx
  • frontend/src/components/company/ErrorState.test.tsx
  • frontend/src/components/company/LoadingState.test.tsx
  • frontend/src/hooks/useAuth.test.tsx
  • frontend/src/hooks/useCompanies.test.ts
  • frontend/src/services/ApiClient.test.ts
  • frontend/src/services/authService.test.ts
  • frontend/src/services/companyService.test.ts
  • frontend/src/services/storage.test.ts
  • frontend/src/test-utils/renderWithProviders.tsx
  • web/package.json
  • web/src/contexts/AuthContext.test.tsx
  • web/src/hooks/useCompanies.test.ts
  • web/src/hooks/useDrivers.test.ts
  • web/src/services/apiClient.test.ts
  • web/src/services/company/companyService.test.ts
  • web/src/services/company/driverService.test.ts
  • web/src/services/company/vehicleService.test.ts
  • web/src/test/setup.ts
  • web/tsconfig.app.json
  • web/vite.config.ts

📝 Walkthrough

Walkthrough

This PR adds comprehensive testing infrastructure and test coverage across both frontend (React Native/Expo with Jest) and web (React with Vitest) applications, including CI/CD workflows, test frameworks, mock setups, and extensive test suites for components, hooks, and services.

Changes

Frontend (React Native) Testing

Layer / File(s) Summary
Jest configuration and setup
frontend/jest.config.cjs, frontend/jest.setup.cjs, frontend/src/test-utils/renderWithProviders.tsx
Jest preset and setup mocks expo-constants, expo-secure-store, react-i18next, and @expo/vector-icons; test helper wraps components with ThemeProvider for consistent rendering.
Component test coverage
frontend/src/components/ErrorBoundary.test.tsx, frontend/src/components/company/CompanyCard.test.tsx, frontend/src/components/company/CompanyListHeader.test.tsx, frontend/src/components/company/EmptyState.test.tsx, frontend/src/components/company/ErrorState.test.tsx, frontend/src/components/company/LoadingState.test.tsx
Tests verify UI behavior: error boundary fallback rendering, company card conditional displays and phone interaction, header loading states, empty/error/loading state feedback, and icon rendering.
Hook test coverage
frontend/src/hooks/useAuth.test.tsx, frontend/src/hooks/useCompanies.test.ts
Hook tests cover: useAuth initialization, token restoration, login/register/logout, and decode failure; useCompanies fetching on mount, refetch on type change, error handling, and reload.
Service and integration tests
frontend/src/services/ApiClient.test.ts, frontend/src/services/authService.test.ts, frontend/src/services/companyService.test.ts, frontend/src/services/storage.test.ts
Test API client configuration and Bearer token handling, auth service token encode/decode and persistence, company service endpoints, and storage platform-conditional delegation.
Package configuration and CI
frontend/package.json, .github/workflows/mobile-tests.yml
Added test/test:ci scripts and Jest devDependencies; GitHub Actions workflow runs tests on frontend changes targeting main.

Web (React) Testing

Layer / File(s) Summary
Vitest configuration and setup
web/vite.config.ts, web/tsconfig.app.json, web/src/test/setup.ts
Vitest config enables globals, jsdom environment, and setup file; TypeScript config includes vitest/globals types; setup provides localStorage polyfill and testing library cleanup.
Context and hook test coverage
web/src/contexts/AuthContext.test.tsx, web/src/hooks/useCompanies.test.ts, web/src/hooks/useDrivers.test.ts
AuthContext tests verify initialization, localStorage persistence, login/logout, and partial-state handling; useCompanies tests cover fetching, error handling, selection, and refresh; useDrivers tests verify company-dependent fetching, vehicle loading, and selection cleanup.
Service test coverage
web/src/services/apiClient.test.ts, web/src/services/company/companyService.test.ts, web/src/services/company/driverService.test.ts, web/src/services/company/vehicleService.test.ts
Tests verify API client base URL and Bearer token handling with 401 logout/redirect, and CRUD operations for companies, drivers, and vehicles.
Package configuration and CI
web/package.json, .github/workflows/web-tests.yml
Added test/test:run scripts using Vitest and testing-library devDependencies; GitHub Actions workflow runs tests on web changes targeting main.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • StoynovAngel/AutoNow#70: Introduces company endpoint and screen implementation that this PR tests (useCompanies, CompanyCard, companyService)
  • StoynovAngel/AutoNow#71: Modifies CompanyCard behavior that is validated by the new CompanyCard test suite expectations
  • StoynovAngel/AutoNow#67: Introduces auth implementation that this PR tests (useAuth, AuthContext, ApiClient, authService)

Poem

🐰 A rabbit hops through tests with glee,
Jest and Vitest, setup spree!
Mock the icons, storage too,
Component checks and API crews—
Now the code runs tried and true!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/add-coverage-for-frontend

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@StoynovAngel StoynovAngel merged commit 203357e into main May 20, 2026
6 of 8 checks passed
@StoynovAngel StoynovAngel deleted the feat/add-coverage-for-frontend branch May 20, 2026 08:55
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