Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added test infrastructure and initial component tests #253

Closed
wants to merge 26 commits into from

Conversation

amjedidiah
Copy link
Contributor

@amjedidiah amjedidiah commented Nov 26, 2024

Description

Sets up Jest testing infrastructure and initial tests for the Upup component library.

Changes

  • Configured Jest and JSDOM test environment
  • Added tests for:
    • MetaVersion component
    • checkFileType utility
    • s3GeneratePresignedUrl service
  • Set up test coverage requirements (1% across all metrics until tests for prior features are added)

Test Setup

  • Frontend: @testing-library/react
  • Backend: Jest mocking for AWS services
  • Essential mocks for Google and Framer Motion

Usage

pnpm test           # Run tests
pnpm test:coverage  # View coverage

BREAKING CHANGE: Replaced direct cloud storage configuration with pre-signed URLs

- Added pre-signed URL endpoint configuration
- Removed cloud storage credentials from frontend
- Deleted cloud storage config files
- Updated upload logic to use pre-signed URLs
- Simplified configuration interface
- Added CORS mode to uploadObject fetch request
- Prettier fixes

BREAKING CHANGE: Requires S3 bucket CORS configuration
- Added client-side SDK approach for cloud storage providers
- Implemented AWS integration with presigned URLs
- Added credential refresh and SAS token management
- Implemented progress tracking and retry mechanisms
- Fixed type errors and improve error handling
- Removed unused code and align with latest SDK versions

BREAKING CHANGE: Storage configuration requires provider-specific SDK setup
- Added client-side SDK approach for Azure provider
- Implemented Azure integration with presigned URLs
- Implemented progress tracking
- Removed unused code and align with latest SDK versions
- Storage config only requires `provider` and `tokenEndpoint` values
- Added client-side SDK approach for DO provider
- Implemented DO integration with presigned URLs
- Unified s3 client-side upload approach for S3 complaint storage providers
- preview url for uploaded files
- made ETag header conditional
- removed `previewUrl` from object returned to FE
- changed folder structure to accommodate BE logic
- undid setting `Content-Type ` header when sending fetch request from `uploadObject`
- improved logic for `handleError`
- improved validation of required configuration
- Enhanced error handling by including `xhr.status` and `xhr.statusText` when reporting error from `uploadWithProgress`
- fixed issue with build failing when temp dist directory exists
- Configured Jest environment for React components and JSDOM
- Added setupTests with necessary mocks for Google, Framer Motion
- Implemented detailed test suite for MetaVersion, checkFileType, and s3GeneratePresignedUrl
@amjedidiah amjedidiah changed the title feat: Added test infrastructure and initial component tests [WIP] feat: Added test infrastructure and initial component tests Nov 26, 2024
@amjedidiah amjedidiah changed the title [WIP] feat: Added test infrastructure and initial component tests feat: Added test infrastructure and initial component tests Nov 26, 2024
Copy link
Collaborator

@BSalaeddin BSalaeddin left a comment

Choose a reason for hiding this comment

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

Suggestions additional Test Cases:

Invalid s3ClientConfig: Test how the function behaves when provided with an invalid or incomplete s3ClientConfig.

it('should handle invalid s3ClientConfig', async () => {
    const invalidS3Config = { ...mockS3Config, region: '' } // Empty region
    await expect(
        s3GeneratePresignedUrl({
            fileParams: mockFileParams,
            bucketName: mockBucketName,
            s3ClientConfig: invalidS3Config,
            origin: mockOrigin,
            provider: mockProvider,
        })
    ).rejects.toThrow(UploadError)
})

Missing Parameters: Ensure the function properly handles cases where required parameters are missing.

it('should throw an error when required parameters are missing', async () => {
    await expect(
        s3GeneratePresignedUrl({
            fileParams: mockFileParams,
            bucketName: '',
            s3ClientConfig: mockS3Config,
            origin: mockOrigin,
            provider: mockProvider,
        })
    ).rejects.toThrow(UploadError)
})

…graded coverage reporting

feat:
- Removed Codecov in favour of native Jest coverage reporting in CI
- Added GitHub Actions artifact storage for coverage reports
- Added detailed coverage threshold checks in CI pipeline
- Updated `s3GeneratePresignedUrl` test suite per review to test for Invalid s3ClientConfig and Missing Parameters
- Updated jest config to support coverage requirements
@MedAmine1212 MedAmine1212 self-requested a review November 27, 2024 17:44
@amjedidiah amjedidiah closed this Jan 31, 2025
@amjedidiah amjedidiah deleted the feat/test-setup branch January 31, 2025 14:49
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.

3 participants