Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 90 additions & 15 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,76 @@ EasyTransfer is a free, anonymous, encrypted, and easy-to-use E2EE file transfer
### Client (in `/client` directory)

```bash
npm run dev # Start development server
npm run build # Build for production
npm run preview # Preview production build
npm run lint # Run ESLint with auto-fix
npm run format # Format code with Prettier
npm run dev # Start development server
npm run build # Build for production
npm run preview # Preview production build
npm run lint # Run ESLint with auto-fix
npm run format # Format code with Prettier
npm test # Run tests
npm run test:watch # Run tests in watch mode
npm run test:ui # Run tests with UI
```

### Server (in `/server` directory)

```bash
npm run dev # Build and start with nodemon
npm run build # Compile TypeScript
npm run start # Start production server
npm run lint # Run ESLint with auto-fix
npm run format # Format code with Prettier
npm run dev # Build and start with nodemon
npm run build # Compile TypeScript
npm run start # Start production server
npm run lint # Run ESLint with auto-fix
npm run format # Format code with Prettier
npm test # Run tests
npm run test:watch # Run tests in watch mode
npm run test:ui # Run tests with UI
```

## Commit Message Guidelines

Follow the [Conventional Commits](https://www.conventionalcommits.org/) specification for semantic commit messages:

### Format

```plaintext
<type>(<scope>): <description>

[optional body]

[optional footer(s)]
```

### Types

- **feat**: A new feature
- **fix**: A bug fix
- **docs**: Documentation only changes
- **style**: Changes that don't affect code meaning (formatting, whitespace)
- **refactor**: Code change that neither fixes a bug nor adds a feature
- **perf**: Performance improvement
- **test**: Adding or updating tests
- **build**: Changes to build system or dependencies
- **ci**: Changes to CI configuration files and scripts
- **chore**: Other changes that don't modify src or test files

### Examples

```
feat(client): add dark mode theme support
fix(server): resolve connection timeout issue
docs(readme): update installation instructions
test(client): add FileChunkManager unit tests
refactor(utils): extract ID generation to utils
ci: add automated testing to GitHub Actions
chore(dependencies): update dependencies to latest versions
```

### Best Practices

- Use present tense (`add` not `added`)
- Use imperative mood (`move` not `moves`)
- Keep first line under 72 characters
- Reference issues/PRs in footer: `Fixes #123`
- Break long descriptions into body paragraphs

## Code Style Guidelines

### General
Expand Down Expand Up @@ -123,11 +176,33 @@ npm run format # Format code with Prettier

## Testing Considerations

- Test WebRTC connection establishment
- Verify file transfer integrity
- Test connection across different networks
- Validate encryption implementation
- Test edge cases (large files, network interruptions)
The project uses Vitest for unit testing:

- **Client**: 157 tests covering utilities, protocol handling, retry logic, theming, and WebRTC
- **Server**: 13 tests covering ID generation and validation

### Running Tests

```bash
# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with UI
npm run test:ui
```

### Test Coverage Areas

- WebRTC connection establishment
- File transfer integrity and chunking
- Protocol message encoding/decoding
- Retry mechanisms and timeout handling
- Theme management
- ID generation and validation
- Edge cases (large files, network interruptions)

## Security Considerations

Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check Lint and Format
name: Check Lint, Format, and Tests

permissions:
contents: read
Expand All @@ -13,7 +13,7 @@ on:
workflow_dispatch:

jobs:
lint-and-format:
lint-format-and-test:
runs-on: ubuntu-latest

steps:
Expand All @@ -25,21 +25,25 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: latest
node-version: '22'

- name: Check server
run: |
cd server
npm install
npm run lint
npm run format -- --check
npm run build
npm test

- name: Check client
run: |
cd client
npm install
npm run lint
npm run format -- --check
npm run build
npm test

- name: Check if the code is formatted and linted
run: |
Expand Down
102 changes: 87 additions & 15 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,60 @@ npm run format
# Lint and format server (in /server)
npm run lint
npm run format

# Run tests (in /client or /server)
npm test # Run all tests
npm run test:watch # Run tests in watch mode
npm run test:ui # Run tests with UI
```

## Commit Message Guidelines

Follow the [Conventional Commits](https://www.conventionalcommits.org/) specification for semantic commit messages:

### Format

```plaintext
<type>(<scope>): <description>

[optional body]

[optional footer(s)]
```

### Types

- **feat**: A new feature
- **fix**: A bug fix
- **docs**: Documentation only changes
- **style**: Changes that don't affect code meaning (formatting, whitespace)
- **refactor**: Code change that neither fixes a bug nor adds a feature
- **perf**: Performance improvement
- **test**: Adding or updating tests
- **build**: Changes to build system or dependencies
- **ci**: Changes to CI configuration files and scripts
- **chore**: Other changes that don't modify src or test files

### Examples

```bash
feature(client): add dark mode theme support
fix(server): resolve connection timeout issue
docs(readme): update installation instructions
test(client): add FileChunkManager unit tests
refactor(utils): extract ID generation to utils
ci: add automated testing to GitHub Actions
chore(dependencies): update dependencies to latest versions
```

### Best Practices

- Use present tense (`add` not `added`)
- Use imperative mood (`move` not `moves`)
- Keep first line under 72 characters
- Reference issues/PRs in footer when applicable
- Break long descriptions into body paragraphs

## Key Concepts for AI Agents

### Architecture Understanding
Expand Down Expand Up @@ -252,27 +304,45 @@ export const useMyStore = defineStore('myStore', () => {

## Testing Strategy

### What to Test
### Test Infrastructure

1. **WebRTC Connection**: Verify peers can connect
2. **File Transfer**: Test various file sizes and types
3. **Network Conditions**: Test on LAN and WAN
4. **Error Handling**: Test disconnections and failures
5. **UI Responsiveness**: Verify UI updates correctly
The project uses **Vitest** for comprehensive unit testing:

- **Client Tests (157 tests)**:
- FileChunkManager (28 tests): file slicing, chunk management, merging, validation
- msgType utilities (33 tests): link detection, file type identification
- FileProtocol (24 tests): message parsing, encoding/decoding, round-trip validation
- RetryManager (28 tests): timeout handling, retry logic, state management
- ThemeManager (17 tests): theme application, color validation, accessibility
- WebRTC Connection Workflow (27 tests): connection lifecycle, signaling, data channels

- **Server Tests (13 tests)**: ID generation, character validation, collision prevention

### Running Tests

Currently, the project uses:
```bash
# In /client or /server directory
npm test # Run all tests once
npm run test:watch # Run tests in watch mode (auto-rerun on changes)
npm run test:ui # Run tests with interactive UI
```

### What to Test

- ESLint for code quality
- Prettier for formatting
- Manual testing for functionality
1. **WebRTC Connection**: Verify peers can connect through signaling
2. **File Transfer**: Test various file sizes and types
3. **Protocol Handling**: Validate message encoding/decoding
4. **Retry Logic**: Test timeout handling and retry mechanisms
5. **Error Handling**: Test disconnections and failures
6. **UI Components**: Verify theming and state management

**Note**: No automated test suite exists yet. When making changes:
### Testing Best Practices

- Test manually with the running application
- Verify WebRTC connections work
- Test file transfers complete successfully
- Write tests for new utilities and functions
- Mock external dependencies (WebRTC, Socket.io)
- Test edge cases and error conditions
- Keep tests focused and isolated
- Run tests before committing changes

## Common Pitfalls and How to Avoid Them

Expand Down Expand Up @@ -340,12 +410,14 @@ Before committing changes:

- [ ] Run `npm run lint` in both client and server
- [ ] Run `npm run format` in both client and server
- [ ] Run `npm test` in both client and server (all tests pass)
- [ ] Build succeeds: `npm run build` in both directories
- [ ] Manual testing completed
- [ ] Manual testing completed (if applicable)
- [ ] No console.log statements left in code
- [ ] TypeScript types are correct
- [ ] No new ESLint warnings
- [ ] Changes follow existing code style
- [ ] Commit message follows semantic commit format

## Dependencies Management

Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

All notable changes to this project will be documented in this file.

## [3.4.1] - 2025-11-04

### Added

- Comprehensive unit tests
- Automated testing in GitHub Actions CI/CD pipeline

### Changed

- Improved ID generation algorithm for better reliability
- Refactored server code to extract testable utility functions

## [3.4.0] - 2025-11-04

**New Features:** The new version introduces settings for language preference and theme preference.
Expand Down
Loading