Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
86 changes: 86 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: E2E Tests

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

permissions:
contents: read

jobs:
e2e-tests:
runs-on: ubuntu-latest

services:
falkordb:
image: falkordb/falkordb:latest
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
Comment thread
coderabbitai[bot] marked this conversation as resolved.

- name: Install pipenv
run: |
python -m pip install --upgrade pip
pip install pipenv

- name: Install dependencies
run: |
pipenv sync --dev

- name: Install Playwright browsers
run: |
pipenv run playwright install chromium
pipenv run playwright install-deps

- name: Create test environment file
run: |
cp .env.example .env
echo "FALKORDB_HOST=localhost" >> .env
echo "FALKORDB_PORT=6379" >> .env
echo "FLASK_SECRET_KEY=test-secret-key-for-ci" >> .env
echo "FLASK_DEBUG=False" >> .env

- name: Wait for FalkorDB
run: |
until docker exec $(docker ps -q --filter ancestor=falkordb/falkordb:latest) redis-cli ping; do
echo "Waiting for FalkorDB..."
sleep 2
done
Comment thread
coderabbitai[bot] marked this conversation as resolved.

- name: Run E2E tests
run: |
pipenv run pytest tests/e2e/ --browser chromium --headed=false --video=on --screenshot=on
env:
CI: true

- name: Upload test artifacts
uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-report
path: |
test-results/
playwright-report/
retention-days: 30

- name: Upload screenshots
uses: actions/upload-artifact@v4
if: failure()
with:
name: screenshots
path: tests/e2e/screenshots/
retention-days: 30
110 changes: 110 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Tests

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

permissions:
contents: read

jobs:
unit-tests:
runs-on: ubuntu-latest

Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

- name: Install pipenv
run: |
python -m pip install --upgrade pip
pip install pipenv

- name: Install dependencies
run: |
pipenv sync --dev

- name: Create test environment file
run: |
cp .env.example .env
echo "FLASK_SECRET_KEY=test-secret-key" >> .env
echo "FLASK_DEBUG=False" >> .env

- name: Run unit tests
run: |
pipenv run pytest tests/ -k "not e2e" --verbose

- name: Run pylint
run: |
pipenv run pylint $(git ls-files '*.py') || true
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

e2e-tests:
runs-on: ubuntu-latest
needs: unit-tests

services:
falkordb:
image: falkordb/falkordb:latest
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Install pipenv
run: |
python -m pip install --upgrade pip
pip install pipenv

- name: Install dependencies
run: |
pipenv sync --dev

- name: Install Playwright browsers
run: |
pipenv run playwright install chromium
pipenv run playwright install-deps

- name: Create test environment file
run: |
cp .env.example .env
echo "FALKORDB_HOST=localhost" >> .env
echo "FALKORDB_PORT=6379" >> .env
echo "FLASK_SECRET_KEY=test-secret-key-for-ci" >> .env
echo "FLASK_DEBUG=False" >> .env

- name: Wait for FalkorDB
run: |
timeout 60 bash -c 'until docker exec $(docker ps -q --filter ancestor=falkordb/falkordb:latest) redis-cli ping; do sleep 2; done'

- name: Run E2E tests
run: |
pipenv run pytest tests/e2e/ --browser chromium --headed=false
env:
CI: true

- name: Upload test artifacts
uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-report
path: |
test-results/
playwright-report/
retention-days: 30
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@
*_conf*
.ruff_code/
.vercel/

# Test artifacts
test-results/
playwright-report/
tests/e2e/screenshots/*.png
.pytest_cache/

# Temporary test files
*.tmp
tmp_*
57 changes: 57 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
.PHONY: help install test test-unit test-e2e test-e2e-headed lint format clean setup-dev

Comment on lines +1 to +2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Declare a default all target and keep the .PHONY list in sync

GNU Make expects an all target in most projects; several tools assume it’s the canonical entry-point.
Additionally, the .PHONY declaration is missing the targets that appear later in the file (run-dev, run-prod, docker-falkordb, docker-stop) so they can be shadowed by files or directories of the same name.

-.PHONY: help install test test-unit test-e2e test-e2e-headed lint format clean setup-dev
+.PHONY: all help install test test-unit test-e2e test-e2e-headed lint format clean \
+        setup-dev run-dev run-prod docker-falkordb docker-stop
+
+all: test            ## Default target: run the full test suite
🧰 Tools
🪛 checkmake (0.2.2)

[warning] 1-1: Missing required phony target "all"

(minphony)

🤖 Prompt for AI Agents
In the Makefile at lines 1 to 2, add a default target named `all` as the first
target in the file to serve as the canonical entry point. Also, update the
`.PHONY` declaration to include all targets defined later in the file such as
`run-dev`, `run-prod`, `docker-falkordb`, and `docker-stop` to prevent conflicts
with files or directories of the same names.

help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST)

install: ## Install dependencies
pipenv sync --dev

setup-dev: install ## Set up development environment
pipenv run playwright install chromium
pipenv run playwright install-deps
@echo "Development environment setup complete!"
@echo "Don't forget to copy .env.example to .env and configure your settings"

test: test-unit test-e2e ## Run all tests

test-unit: ## Run unit tests only
pipenv run pytest tests/ -k "not e2e" --verbose

test-e2e: ## Run E2E tests headless
pipenv run pytest tests/e2e/ --browser chromium --headed=false

test-e2e-headed: ## Run E2E tests with browser visible
pipenv run pytest tests/e2e/ --browser chromium --headed=true

test-e2e-debug: ## Run E2E tests with debugging enabled
pipenv run pytest tests/e2e/ --browser chromium --headed=true --slowmo=1000

lint: ## Run linting
pipenv run pylint $(shell git ls-files '*.py')

format: ## Format code (placeholder - add black/autopep8 if needed)
@echo "Add code formatting tool like black here"

clean: ## Clean up test artifacts
rm -rf test-results/
rm -rf playwright-report/
rm -rf tests/e2e/screenshots/
rm -rf __pycache__/
find . -name "*.pyc" -delete
find . -name "*.pyo" -delete

run-dev: ## Run development server
pipenv run flask --app api.index run --debug

run-prod: ## Run production server
pipenv run flask --app api.index run

docker-falkordb: ## Start FalkorDB in Docker for testing
docker run -d --name falkordb-test -p 6379:6379 falkordb/falkordb:latest

docker-stop: ## Stop test containers
docker stop falkordb-test || true
docker rm falkordb-test || true
3 changes: 3 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ flask-dance = "~=7.1.0"
[dev-packages]
pytest = "~=8.2.0"
pylint = "~=3.3.4"
playwright = "~=1.47.0"
pytest-playwright = "~=0.5.2"
pytest-asyncio = "~=0.24.0"

[requires]
python_version = "3.12"
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,48 @@ pipenv run flask --app api.index run

The application will be available at `http://localhost:5000`.

## Testing

QueryWeaver includes a comprehensive test suite with both unit and End-to-End (E2E) tests.

### Quick Start

```bash
# Set up test environment
./setup_e2e_tests.sh

# Run all tests
make test

# Run only unit tests
make test-unit

# Run E2E tests (headless)
make test-e2e

# Run E2E tests with visible browser
make test-e2e-headed
```

### Test Types

- **Unit Tests**: Test individual components and functions
- **E2E Tests**: Test complete user workflows using Playwright
- Basic functionality (page loading, UI structure)
- Authentication flows (OAuth integration)
- File upload and processing
- Chat interface and query handling
- API endpoint testing

See [tests/e2e/README.md](tests/e2e/README.md) for detailed E2E testing documentation.

### CI/CD

Tests run automatically in GitHub Actions:
- Unit tests run on every push/PR
- E2E tests run with FalkorDB service
- Test artifacts and screenshots saved on failure

## Introduction

<img width="1863" height="996" alt="image" src="https://github.com/user-attachments/assets/a0be7bbd-0c99-4399-a302-2b9f7b419dd2" />
Expand Down
21 changes: 21 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[tool:pytest]
testpaths = tests
python_files = test_*.py
python_classes = Test*
python_functions = test_*
addopts =
--verbose
--tb=short
--strict-markers
--disable-warnings
--browser chromium
--headed
markers =
e2e: End-to-end tests using Playwright
slow: Tests that take a long time to run
auth: Tests that require authentication
integration: Integration tests
unit: Unit tests
filterwarnings =
ignore::DeprecationWarning
ignore::PendingDeprecationWarning
Loading