Graph_RAG7 / TESTING.md
Aigenthix's picture
Upload 19 files
bc10808 verified
|
Raw
History Blame Contribute Delete
10.6 kB

Testing Guide πŸ§ͺ

Complete guide to test all features of the Graph RAG Chatbot.

Prerequisites

  • Application running (local or Docker)
  • Groq API Key configured
  • Test documents prepared

Test Documents

1. Sample CSV (test_data.csv)

Create this file for testing:

Name,Role,Department,Salary
Alice Johnson,Senior Engineer,Engineering,120000
Bob Smith,Product Manager,Product,110000
Carol White,Designer,Design,100000
David Lee,Engineer,Engineering,95000
Emma Davis,Analyst,Data,90000

Save as: test_data.csv

2. Sample PDF

Use any PDF document about:

  • Technology
  • Business
  • Science
  • General knowledge

Recommended: Download a sample PDF from https://www.w3.org/WAI/test-evaluate/

3. Sample TXT

Create sample.txt with text like:

Natural Language Processing (NLP) is a subfield of linguistics, 
computer science, and artificial intelligence concerned with the 
interactions between computers and human language.

Machine learning is a method of data analysis that automates analytical 
model building. It is a branch of artificial intelligence based on the 
idea that systems can learn from data.

Graph databases are specialized databases designed to store and retrieve 
relational data. They are particularly useful for managing large, 
interconnected datasets where relationships are as important as the data itself.

Save as: sample.txt

Test Cases

Test 1: Upload Single Document

Objective: Verify basic file upload functionality

Steps:

  1. Navigate to "πŸ“€ Upload Documents" section
  2. Click on upload zone or drag test_data.csv
  3. Observe the file appears in "Uploaded Documents"
  4. Status should change: queued β†’ processing β†’ ready

Expected Results:

  • βœ… File appears immediately
  • βœ… Progress bar fills to 100%
  • βœ… Status changes to "ready"
  • βœ… Shows chunk count (e.g., "~1 chunks")
  • βœ… Shows entity count (e.g., "~12 entities")
  • βœ… "View Full Graph" link appears

Time: ~3-5 seconds


Test 2: Upload Multiple Documents

Objective: Test concurrent document processing

Steps:

  1. Prepare 3 test files: test_data.csv, sample.txt, and a PDF
  2. Click upload zone
  3. Select all 3 files at once
  4. Hold Ctrl/Cmd and select all files

Expected Results:

  • βœ… All 3 files queued simultaneously
  • βœ… Each processes independently
  • βœ… UI remains responsive
  • βœ… All reach "ready" status

Time: ~10-15 seconds total


Test 3: View Knowledge Graph

Objective: Verify graph visualization

Steps:

  1. Ensure a document has "ready" status
  2. Click "πŸ“ˆ View Full Graph" link
  3. Switch to "Knowledge Graph" tab
  4. Select document from dropdown

Expected Results:

  • βœ… Image loads without errors
  • βœ… Graph shows nodes (blue = chunks, green = entities)
  • βœ… Edges show relationships
  • βœ… Layout is readable and clear

Image Properties:

  • Resolution: 150 DPI
  • Format: PNG
  • Size: 800x600px (approximately)

Test 4: Simple Query

Objective: Test RAG functionality with CSV data

Steps:

  1. Upload test_data.csv
  2. Wait for "ready" status
  3. In chat section:
    • Select document from dropdown
    • Type query: "Who is the senior engineer?"
    • Click "Send"

Expected Results:

  • βœ… Chat message appears
  • βœ… Loading indicator shows
  • βœ… Bot responds with answer
  • βœ… Response references Alice Johnson
  • βœ… Response appears in 2-5 seconds

Example Expected Answer:

Based on the provided data, Alice Johnson is the Senior Engineer 
in the Engineering Department with a salary of $120,000.

Test 5: Knowledge-based Query

Objective: Test with text document

Steps:

  1. Upload sample.txt (NLP/ML content)
  2. Wait for "ready" status
  3. Query: "What is machine learning?"

Expected Results:

  • βœ… Bot provides accurate explanation
  • βœ… Answer comes from the document context
  • βœ… Response is relevant and coherent

Example Expected Answer:

Machine learning is a method of data analysis that automates 
analytical model building. It is a branch of artificial 
intelligence based on the idea that systems can learn from data.

Test 6: Multi-chunk Context

Objective: Test queries that require context from multiple chunks

Steps:

  1. Upload sample.txt
  2. Query: "What are the relationships between NLP, machine learning, and graph databases?"

Expected Results:

  • βœ… Answer synthesizes information across multiple chunks
  • βœ… Shows understanding of relationships
  • βœ… Confidence score is shown

Test 7: Out-of-context Query

Objective: Test handling of irrelevant queries

Steps:

  1. Upload test_data.csv (employee data)
  2. Query: "What is quantum physics?"

Expected Results:

  • βœ… Bot responds: "No relevant information found in the document"
  • βœ… No incorrect information is generated
  • βœ… Error is handled gracefully

Test 8: Document Deletion

Objective: Verify document removal

Steps:

  1. Upload test_data.csv
  2. Wait for "ready" status
  3. Click "Delete" button
  4. Confirm deletion

Expected Results:

  • βœ… Document disappears from list
  • βœ… Graph image is removed
  • βœ… Cannot query deleted document
  • βœ… Dropdown option removed

Test 9: Error Handling - Invalid File

Objective: Test upload of unsupported format

Steps:

  1. Try to upload file with unsupported extension (.exe, .jpg, etc.)
  2. Observe UI response

Expected Results:

  • βœ… File is accepted (upload endpoint)
  • βœ… Processing fails with meaningful error
  • βœ… Status shows "error"
  • βœ… Error message visible: "Unsupported file type"

Test 10: Error Handling - Large File

Objective: Test max file size limit

Steps:

  1. Create a file > 50MB
  2. Try to upload

Expected Results:

  • βœ… Upload is rejected
  • βœ… Error message: "File too large"
  • βœ… File not added to list

Test 11: UI Responsiveness

Objective: Verify UI doesn't freeze during processing

Steps:

  1. Upload a large PDF
  2. While processing, try:
    • Typing in chat box ← Should work
    • Clicking buttons ← Should respond
    • Switching tabs ← Should work smoothly
    • Scrolling document list ← Should scroll

Expected Results:

  • βœ… All interactions responsive
  • βœ… No UI freezing
  • βœ… Processing continues in background

Test 12: Document List Auto-refresh

Objective: Verify real-time status updates

Steps:

  1. Upload document
  2. Watch the status bar update
  3. Monitor without manual refresh

Expected Results:

  • βœ… Status updates every 1.5 seconds
  • βœ… Progress bar moves smoothly
  • βœ… No manual refresh needed
  • βœ… Final status appears automatically

Test 13: Browser Compatibility

Test on: Chrome, Firefox, Safari, Edge

Steps for each browser:

  1. Load application homepage
  2. Test file upload
  3. Test chat functionality
  4. Check graph visualization

Expected Results:

  • βœ… UI loads correctly
  • βœ… All features work
  • βœ… No console errors
  • βœ… Styling renders properly

Test 14: Mobile Responsiveness

Steps:

  1. Open on mobile device (or DevTools)
  2. Set viewport to 375Γ—667 (iPhone)
  3. Test all features:
    • Upload
    • Chat
    • Graph viewing
    • Navigation

Expected Results:

  • βœ… Layout adapts to mobile
  • βœ… Single column layout
  • βœ… Touch interactions work
  • βœ… Text is readable

Test 15: API Endpoints Directly

Tool: curl, Postman, or Python requests

Upload Request

curl -X POST \
  -F "files=@test_data.csv" \
  http://localhost:7860/api/upload

Expected Response:

{
  "success": true,
  "message": "βœ… 1 file(s) queued for processing",
  "successful": 1,
  "failed": 0,
  "files": ["test_data.csv"]
}

Get Documents

curl http://localhost:7860/api/documents

Expected Response:

{
  "documents": {
    "test_data.csv": {
      "status": "ready",
      "chunks": 1,
      "entities": 10,
      "graph_image": "/graph-image/test_data.csv"
    }
  },
  "api_key_set": true,
  "timestamp": "2024-01-15T10:30:00"
}

Query

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"query": "Who is the senior engineer?", "document": "test_data.csv"}' \
  http://localhost:7860/api/query

Expected Response:

{
  "answer": "Based on the data, Alice Johnson is the Senior Engineer...",
  "sources": ["Chunk 1"],
  "confidence": 0.85
}

Performance Benchmarks

Expected Processing Times

Document Type Size Processing Time
CSV (5 rows) ~1KB 2-3s
Small TXT ~5KB 3-5s
Medium PDF 20 pages 10-15s
Large PDF 50+ pages 30-60s

Query Response Times

  • Simple query (1-2 words): 1-2s
  • Complex query (5+ words): 2-4s
  • Graph visualization load: <100ms

Load Testing

Single User

  • 10 queries: Should complete in ~20-30s
  • 5 uploads: Should complete in ~30-45s

Concurrent Users (Docker)

  • 3 simultaneous uploads: Should handle smoothly
  • 5 concurrent queries: Should not block

Checklist Summary

  • Single document upload works
  • Multiple document upload works
  • Document shows processing status
  • Graph visualization loads
  • Simple query works
  • Multi-context query works
  • Out-of-context query handled
  • Document deletion works
  • Error messages appear for errors
  • UI remains responsive
  • Status updates automatically
  • Works in multiple browsers
  • Mobile responsive layout
  • API endpoints work
  • Performance acceptable

Debugging Tips

Check Logs

# Docker
docker-compose logs -f

# Local
python app.py  # Watch console output

Common Issues

Issue: Graph doesn't load

  • Check: data/graph_data/ folder exists
  • Check: Matplotlib installed
  • Check: file permissions

Issue: Chat unresponsive

  • Check: GROQ_API_KEY set
  • Check: Document status is "ready"
  • Check: Network connectivity

Issue: Slow processing

  • Check: File size
  • Check: System RAM/CPU
  • Check: Model download complete

Issue: Files disappear

  • Note: HF Spaces ephemeral storage
  • Solution: Use persistent storage option

Test Report Template

Test Run Date: ____
Tester Name: ____
Environment: (Local/Docker/HF Spaces)
OS: ____
Browser: ____

PASS/FAIL | Test Case | Notes
---|---|---
 | Test 1 |
 | Test 2 |
 | Test 3 |
...

Issues Found:
1. 
2.
3.

Overall Result: PASS/FAIL

Happy Testing! πŸŽ‰

If you find issues, report them with:

  • Steps to reproduce
  • Expected vs actual behavior
  • Browser/OS information
  • Relevant logs