-
-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/testing infrastructure #104
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
Open
itskritix
wants to merge
16
commits into
main
Choose a base branch
from
feat/testing-infrastructure
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
0933036
test: add E2E and backend testing infrastructure
itskritix 6046c8d
feat: add data-testid attributes for E2E testing
itskritix 325b2dc
docs: add testing documentation with coverage status
itskritix 5e8efc2
fix: update Node.js version to 22 for @electron/rebuild compatibility
itskritix 62d840a
fix: resolve Greptile code review comments
itskritix 58f8da6
fix: use bitnami/minio image for CI services
itskritix 61470fc
fix: run MinIO as docker container step instead of service
itskritix 88d3773
fix: remove db:migrate steps - migrations run on server startup
itskritix d0a37a5
fix: run server with node dist/index.js and increase timeout
itskritix 31fa587
fix: add debugging for E2E service startup
itskritix 730ad43
fix: add SERVER_MODE env var for server startup
itskritix 736f1d5
fix: use 'serve' script instead of 'preview' for web app
itskritix 6bafc93
fix: simplify CI workflow - use npx vite preview for web app
itskritix 2c96f9d
fix: use pgvector/pgvector:pg16 image for PostgreSQL with vector exte…
itskritix 76e8818
fix: add vite preview config with COOP/COEP headers for SQLite WASM
itskritix 071a13b
fix: use empty object destructuring in Playwright fixture
itskritix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,237 @@ | ||
| name: Test | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| env: | ||
| NODE_ENV: test | ||
| SERVER_MODE: standalone | ||
| DATABASE_URL: postgresql://brainbox:brainbox@localhost:5432/brainbox | ||
| POSTGRES_URL: postgresql://brainbox:brainbox@localhost:5432/brainbox | ||
| REDIS_URL: redis://localhost:6379/0 | ||
| STORAGE_S3_ENDPOINT: http://localhost:9000 | ||
| STORAGE_S3_ACCESS_KEY: minioadmin | ||
| STORAGE_S3_SECRET_KEY: minioadmin | ||
| STORAGE_S3_BUCKET: brainbox | ||
| STORAGE_S3_REGION: us-east-1 | ||
| JWT_SECRET: test-jwt-secret | ||
| ACCOUNT_VERIFICATION_TYPE: automatic | ||
|
|
||
| jobs: | ||
| lint: | ||
| name: Lint & Type Check | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
| cache: 'npm' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Run linter | ||
| run: npm run lint | ||
|
|
||
| - name: Type check | ||
| run: npm run compile | ||
|
|
||
| unit-tests: | ||
| name: Unit Tests | ||
| runs-on: ubuntu-latest | ||
| needs: lint | ||
| services: | ||
| redis: | ||
| image: redis:7-alpine | ||
| ports: | ||
| - 6379:6379 | ||
| options: >- | ||
| --health-cmd "redis-cli ping" | ||
| --health-interval 10s | ||
| --health-timeout 5s | ||
| --health-retries 5 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
| cache: 'npm' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Run unit tests | ||
| run: npm run test -- --reporter=verbose | ||
| working-directory: apps/server | ||
|
|
||
| integration-tests: | ||
| name: Integration Tests | ||
| runs-on: ubuntu-latest | ||
| needs: lint | ||
| services: | ||
| postgres: | ||
| image: pgvector/pgvector:pg16 | ||
| env: | ||
| POSTGRES_USER: brainbox | ||
| POSTGRES_PASSWORD: brainbox | ||
| POSTGRES_DB: brainbox | ||
| ports: | ||
| - 5432:5432 | ||
| options: >- | ||
| --health-cmd pg_isready | ||
| --health-interval 10s | ||
| --health-timeout 5s | ||
| --health-retries 5 | ||
|
|
||
| redis: | ||
| image: redis:7-alpine | ||
| ports: | ||
| - 6379:6379 | ||
| options: >- | ||
| --health-cmd "redis-cli ping" | ||
| --health-interval 10s | ||
| --health-timeout 5s | ||
| --health-retries 5 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
| cache: 'npm' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Start MinIO | ||
| run: | | ||
| docker run -d --name minio \ | ||
| -p 9000:9000 \ | ||
| -e MINIO_ROOT_USER=minioadmin \ | ||
| -e MINIO_ROOT_PASSWORD=minioadmin \ | ||
| minio/minio server /data | ||
| sleep 5 | ||
|
|
||
| - name: Create MinIO bucket | ||
| run: | | ||
| curl -O https://dl.min.io/client/mc/release/linux-amd64/mc | ||
| chmod +x mc | ||
| ./mc alias set myminio http://localhost:9000 minioadmin minioadmin | ||
| ./mc mb myminio/brainbox || true | ||
|
|
||
| - name: Run integration tests | ||
| run: npm run test -- --reporter=verbose | ||
| working-directory: apps/server | ||
|
|
||
| e2e-tests: | ||
| name: E2E Tests | ||
| runs-on: ubuntu-latest | ||
| needs: [unit-tests, integration-tests] | ||
| services: | ||
| postgres: | ||
| image: pgvector/pgvector:pg16 | ||
| env: | ||
| POSTGRES_USER: brainbox | ||
| POSTGRES_PASSWORD: brainbox | ||
| POSTGRES_DB: brainbox | ||
| ports: | ||
| - 5432:5432 | ||
| options: >- | ||
| --health-cmd pg_isready | ||
| --health-interval 10s | ||
| --health-timeout 5s | ||
| --health-retries 5 | ||
|
|
||
| redis: | ||
| image: redis:7-alpine | ||
| ports: | ||
| - 6379:6379 | ||
| options: >- | ||
| --health-cmd "redis-cli ping" | ||
| --health-interval 10s | ||
| --health-timeout 5s | ||
| --health-retries 5 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
| cache: 'npm' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Install Playwright browsers | ||
| run: npx playwright install --with-deps chromium | ||
|
|
||
| - name: Start MinIO | ||
| run: | | ||
| docker run -d --name minio \ | ||
| -p 9000:9000 \ | ||
| -e MINIO_ROOT_USER=minioadmin \ | ||
| -e MINIO_ROOT_PASSWORD=minioadmin \ | ||
| minio/minio server /data | ||
| sleep 5 | ||
|
|
||
| - name: Create MinIO bucket | ||
| run: | | ||
| curl -O https://dl.min.io/client/mc/release/linux-amd64/mc | ||
| chmod +x mc | ||
| ./mc alias set myminio http://localhost:9000 minioadmin minioadmin | ||
| ./mc mb myminio/brainbox || true | ||
|
|
||
| - name: Build all packages | ||
| run: npm run build | ||
|
|
||
| - name: Start server | ||
| run: node dist/index.js & | ||
| working-directory: apps/server | ||
|
|
||
| - name: Start web app | ||
| run: npx vite preview & | ||
| working-directory: apps/web | ||
|
|
||
| - name: Wait for services | ||
| run: | | ||
| sleep 10 | ||
| npx wait-on http://localhost:3000/config http://localhost:4000 --timeout 120000 | ||
|
|
||
| - name: Run E2E tests | ||
| run: npm run e2e -- --project=chromium | ||
| env: | ||
| E2E_BASE_URL: http://localhost:4000 | ||
| CI: true | ||
|
|
||
| - name: Upload test results | ||
| uses: actions/upload-artifact@v4 | ||
| if: always() | ||
| with: | ||
| name: playwright-report | ||
| path: playwright-report/ | ||
| retention-days: 7 | ||
|
|
||
| - name: Upload test screenshots | ||
| uses: actions/upload-artifact@v4 | ||
| if: failure() | ||
| with: | ||
| name: test-screenshots | ||
| path: e2e/screenshots/ | ||
| retention-days: 7 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import { describe, it, expect } from 'vitest'; | ||
|
|
||
| import { generatePasswordHash, verifyPassword } from '../accounts'; | ||
|
|
||
| describe('accounts - password', () => { | ||
| describe('generatePasswordHash', () => { | ||
| it('should generate argon2 hash', async () => { | ||
| const hash = await generatePasswordHash('TestPassword123'); | ||
| expect(hash).toMatch(/^\$argon2/); | ||
| }); | ||
|
|
||
| it('should generate different hashes for same password', async () => { | ||
| const hash1 = await generatePasswordHash('TestPassword123'); | ||
| const hash2 = await generatePasswordHash('TestPassword123'); | ||
| expect(hash1).not.toBe(hash2); | ||
| }); | ||
|
|
||
| it('should generate hash with expected format', async () => { | ||
| const hash = await generatePasswordHash('TestPassword123'); | ||
| expect(hash).toMatch(/^\$argon2id\$v=\d+\$m=\d+,t=\d+,p=\d+\$/); | ||
| }); | ||
| }); | ||
|
|
||
| describe('verifyPassword', () => { | ||
| it('should verify correct password', async () => { | ||
| const password = 'TestPassword123'; | ||
| const hash = await generatePasswordHash(password); | ||
| const result = await verifyPassword(password, hash); | ||
| expect(result).toBe(true); | ||
| }); | ||
|
|
||
| it('should reject incorrect password', async () => { | ||
| const hash = await generatePasswordHash('TestPassword123'); | ||
| const result = await verifyPassword('WrongPassword', hash); | ||
| expect(result).toBe(false); | ||
| }); | ||
|
|
||
| it('should reject empty password', async () => { | ||
| const hash = await generatePasswordHash('TestPassword123'); | ||
| const result = await verifyPassword('', hash); | ||
| expect(result).toBe(false); | ||
| }); | ||
|
|
||
| it('should handle special characters in password', async () => { | ||
| const password = 'Test@Password!123#$%'; | ||
| const hash = await generatePasswordHash(password); | ||
| const result = await verifyPassword(password, hash); | ||
| expect(result).toBe(true); | ||
| }); | ||
|
|
||
| it('should handle unicode characters in password', async () => { | ||
| const password = 'Test\u00e9\u00e0\u00fc123'; | ||
| const hash = await generatePasswordHash(password); | ||
| const result = await verifyPassword(password, hash); | ||
| expect(result).toBe(true); | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Environment variable inconsistency:
POSTGRES_URLis defined but migration steps useDATABASE_URLPrompt To Fix With AI