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
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI

permissions:
contents: read

on:
push:
branches: [master, v6.60]
pull_request:
branches: [master, v6.60]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x, 22.x, 24.x]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Check code formatting
run: npm run format:check

- name: Run tests
run: npm test
36 changes: 18 additions & 18 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: "CodeQL Advanced"
name: 'CodeQL Advanced'

on:
push:
branches: [ "master", "v5.112", "v5.114", "v5.64", "v5.68", "v5.70", "v6.11", "v6.24", "v6.60" ]
branches: ['master', 'v5.112', 'v5.114', 'v5.64', 'v5.68', 'v5.70', 'v6.11', 'v6.24', 'v6.60']
pull_request:
branches: [ "master" ]
branches: ['master']
schedule:
- cron: '38 10 * * 2'

Expand All @@ -23,22 +23,22 @@ jobs:
fail-fast: false
matrix:
include:
- language: actions
build-mode: none
- language: javascript-typescript
build-mode: none
- language: actions
build-mode: none
- language: javascript-typescript
build-mode: none

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{matrix.language}}"
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
category: '/language:${{matrix.language}}'
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ software.tar.gz
coverage
mysql_move_data.log
mysqld.cnf
.github
.nyc_output
logs/
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,75 @@ The \<API Key\> value is the value you entered during the configuration of the W
## Usage:
* For full documentation and for information on all of the endpoints and requirements visit: https://wickrinc.github.io/wickrio-docs/#web-interface-rest-api

## Testing

This project includes a comprehensive test suite built with Vitest and Supertest for integration testing.

### Running Tests

```bash
# Run all tests once
npm test

# Run tests in watch mode (reruns on file changes)
npm run test:watch

# Run tests with coverage report
npm run test:coverage
```

### Test Structure

The test suite includes:
- **Authentication Tests** (`tests/auth.test.js`) - Basic auth and API key validation
- **Messages Tests** (`tests/messages.test.js`) - Sending/receiving messages and attachments
- **Rooms Tests** (`tests/rooms.test.js`) - Room creation, modification, and deletion
- **Files Tests** (`tests/files.test.js`) - File upload and distribution
- **Statistics Tests** (`tests/statistics.test.js`) - Statistics retrieval and clearing
- **Group Conversation Tests** (`tests/groupconvo.test.js`) - Group conversation management
- **Callbacks Tests** (`tests/callbacks.test.js`) - Message callback configuration
- **Directory Tests** (`tests/directory.test.js`) - Directory retrieval

### Test Coverage

All major API endpoints are covered with integration tests that:
- Mock the WickrIO bot API to avoid requiring an actual bot connection
- Test both V1 and V2 API endpoints
- Verify request validation and error handling
- Confirm proper authentication and authorization
- Test successful operations and edge cases

### Writing New Tests

To add new tests:
1. Create a new test file in the `tests/` directory
2. Import the test helpers from `tests/setup/test-server.js`
3. Use the mock responses from `tests/setup/mocks.js`
4. Follow the existing test patterns for consistency

Example:
```javascript
import { describe, it, expect, beforeAll } from 'vitest'
import request from 'supertest'
import { createTestServer, createAuthHeader } from './setup/test-server.js'

describe('My New Tests', () => {
let app

beforeAll(async () => {
app = await createTestServer()
})

it('should test something', async () => {
const response = await request(app)
.get('/some/endpoint')
.set('Authorization', createAuthHeader())

expect(response.status).toBe(200)
})
})
```

# License

This software is distributed under the [Apache License, version 2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
Expand Down
Loading