Skip to content

Comments

Added unit tests#965

Open
umeshmore45 wants to merge 10 commits intodevfrom
feat/add-unit-tests
Open

Added unit tests#965
umeshmore45 wants to merge 10 commits intodevfrom
feat/add-unit-tests

Conversation

@umeshmore45
Copy link
Contributor

Adds comprehensive unit test coverage including:

  • Controller tests (auth, migration, org, projects, user, contentMapper)
  • Service tests (auth, contentMapper, extension, globalField, marketplace, migration, org, projects, taxonomy, user)
  • Middleware tests (auth, error, req-headers, unmatched-routes, uploadService)
  • Model tests (FieldMapper, authentication, contentTypesMapper-lowdb, project-lowdb)
  • Route tests (auth, contentMapper, migration, org, projects, user)
  • Utility tests (async-router, auth, batch-processor, custom-errors, field-attacher, get-project, https, jwt, mimeTypes, pagination, sanitize-path, search, index)
  • Validator tests (affix, affix-confirmation, auth, cms, destination-stack, file-format, fileformat-confirmation, index, project, stack)
  • Test fixtures and setup configuration
  • Vitest configuration
  • GitHub Actions test workflow

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive unit test coverage to the API layer using Vitest as the testing framework. The changes introduce test files across all major components including controllers, services, middleware, models, routes, validators, and utilities, along with test fixtures, setup configuration, and a GitHub Actions workflow for automated testing.

Changes:

  • Adds Vitest configuration with coverage thresholds (80% lines, 80% functions, 60% branches, 80% statements)
  • Implements 50+ unit test files covering validators, utilities, models, middleware, routes, controllers, and services
  • Adds test fixtures for common data structures (user, project, contentMapper, auth)
  • Configures GitHub Actions workflow for automated test execution on push/PR
  • Removes several existing GitHub Actions workflows (security scanning, repo sync, policy checks, Jira integration)

Reviewed changes

Copilot reviewed 67 out of 69 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
api/vitest.config.ts Vitest configuration with coverage settings and file exclusions
api/tests/setup.ts Global test setup with environment variable stubs
api/tests/fixtures/*.ts Test data fixtures for users, projects, content mappers, and auth
api/tests/unit/validators/*.test.ts Validator tests for auth, project, CMS, file format, affix, stack
api/tests/unit/utils/*.test.ts Utility function tests for search, sanitization, pagination, mimeTypes, JWT, batch processing, etc.
api/tests/unit/models/*.test.ts Model tests for lowdb-based data stores
api/tests/unit/middlewares/*.test.ts Middleware tests for auth, error handling, headers, routes
api/tests/unit/routes/*.test.ts Route registration tests
api/tests/unit/controllers/*.test.ts Controller tests verifying service delegation
api/tests/unit/services/*.test.ts Service layer tests with mocked dependencies
api/package.json Adds vitest, coverage, and test scripts
.github/workflows/test.yml New CI workflow for running tests with coverage
.github/workflows/*.yml Deleted security, sync, and policy workflows
Files not reviewed (1)
  • api/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 121 out of 125 changed files in this pull request and generated 4 comments.

Files not reviewed (3)
  • api/package-lock.json: Language not supported
  • ui/package-lock.json: Language not supported
  • upload-api/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@umeshmore45 umeshmore45 changed the title Add unit tests for API layer Addwd unit tests Feb 19, 2026
@umeshmore45 umeshmore45 changed the title Addwd unit tests Added unit tests Feb 19, 2026
sayalijoshi27
sayalijoshi27 previously approved these changes Feb 20, 2026
umeshmore45 and others added 9 commits February 20, 2026 16:15
Adds comprehensive unit test coverage including:
- Controller tests (auth, migration, org, projects, user, contentMapper)
- Service tests (auth, contentMapper, extension, globalField, marketplace, migration, org, projects, taxonomy, user)
- Middleware tests (auth, error, req-headers, unmatched-routes, uploadService)
- Model tests (FieldMapper, authentication, contentTypesMapper-lowdb, project-lowdb)
- Route tests (auth, contentMapper, migration, org, projects, user)
- Utility tests (async-router, auth, batch-processor, custom-errors, field-attacher, get-project, https, jwt, mimeTypes, pagination, sanitize-path, search, index)
- Validator tests (affix, affix-confirmation, auth, cms, destination-stack, file-format, fileformat-confirmation, index, project, stack)
- Test fixtures and setup configuration
- Vitest configuration
- GitHub Actions test workflow

Co-authored-by: Cursor <cursoragent@cursor.com>
…y checks, and source composition analysis

- Introduced a workflow to create Jira tickets automatically when GitHub issues are opened.
- Added a security policy scan to check for the presence of SECURITY.md and license files on pull request events.
- Implemented a source composition analysis scan using Snyk to identify vulnerabilities in the codebase.

These enhancements improve issue tracking and security compliance in the repository.
…y checks, and source composition analysis

- Introduced a workflow to create Jira tickets automatically when GitHub issues are opened.
- Added a security policy scan to check for the presence of SECURITY.md and license files on pull request events.
- Implemented a source composition analysis scan using Snyk to identify vulnerabilities in the codebase.

These enhancements improve issue tracking and security compliance in the repository.

Co-authored-by: Cursor <cursoragent@cursor.com>
- Updated GitHub Actions workflow to include separate jobs for API and UI tests, improving clarity and organization.
- Increased Node.js version in the workflow to 22 for better compatibility.
- Added Vitest configuration for UI testing, including coverage reporting.
- Introduced multiple unit tests for hooks, services, and components, ensuring comprehensive coverage and reliability.
- Updated package dependencies for testing libraries to the latest versions.

These changes enhance the testing framework and ensure robust coverage for both API and UI components.
…r improved dependency management during testing
…or improved compatibility with legacy peer dependencies during testing
- Updated auth and project validator tests to include the beforeAll hook for improved test setup.
- Added import of vi in the config fixture to facilitate mocking capabilities.

These changes improve the structure and functionality of the testing framework.
… npm ci

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants