CoolFace
Apppublic

Aigenthix/Graph_RAG7

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
TESTING.md507 linesDownload Raw Back to root
1# Testing Guide ๐Ÿงช2 3Complete guide to test all features of the Graph RAG Chatbot.4 5## Prerequisites6 7- Application running (local or Docker)8- Groq API Key configured9- Test documents prepared10 11## Test Documents12 13### 1. Sample CSV (test_data.csv)14 15Create this file for testing:16 17```csv18Name,Role,Department,Salary19Alice Johnson,Senior Engineer,Engineering,12000020Bob Smith,Product Manager,Product,11000021Carol White,Designer,Design,10000022David Lee,Engineer,Engineering,9500023Emma Davis,Analyst,Data,9000024```25 26**Save as**: `test_data.csv`27 28### 2. Sample PDF29 30Use any PDF document about:31- Technology32- Business33- Science34- General knowledge35 36**Recommended**: Download a sample PDF from https://www.w3.org/WAI/test-evaluate/37 38### 3. Sample TXT39 40Create `sample.txt` with text like:41 42```43Natural Language Processing (NLP) is a subfield of linguistics, 44computer science, and artificial intelligence concerned with the 45interactions between computers and human language.46 47Machine learning is a method of data analysis that automates analytical 48model building. It is a branch of artificial intelligence based on the 49idea that systems can learn from data.50 51Graph databases are specialized databases designed to store and retrieve 52relational data. They are particularly useful for managing large, 53interconnected datasets where relationships are as important as the data itself.54```55 56**Save as**: `sample.txt`57 58## Test Cases59 60### Test 1: Upload Single Document61 62**Objective**: Verify basic file upload functionality63 64**Steps**:651. Navigate to "๐Ÿ“ค Upload Documents" section662. Click on upload zone or drag `test_data.csv`673. Observe the file appears in "Uploaded Documents"684. Status should change: queued โ†’ processing โ†’ ready69 70**Expected Results**:71- โœ… File appears immediately72- โœ… Progress bar fills to 100%73- โœ… Status changes to "ready"74- โœ… Shows chunk count (e.g., "~1 chunks")75- โœ… Shows entity count (e.g., "~12 entities")76- โœ… "View Full Graph" link appears77 78**Time**: ~3-5 seconds79 80---81 82### Test 2: Upload Multiple Documents83 84**Objective**: Test concurrent document processing85 86**Steps**:871. Prepare 3 test files: `test_data.csv`, `sample.txt`, and a PDF882. Click upload zone893. Select all 3 files at once904. Hold Ctrl/Cmd and select all files91 92**Expected Results**:93- โœ… All 3 files queued simultaneously94- โœ… Each processes independently95- โœ… UI remains responsive96- โœ… All reach "ready" status97 98**Time**: ~10-15 seconds total99 100---101 102### Test 3: View Knowledge Graph103 104**Objective**: Verify graph visualization105 106**Steps**:1071. Ensure a document has "ready" status1082. Click "๐Ÿ“ˆ View Full Graph" link1093. Switch to "Knowledge Graph" tab1104. Select document from dropdown111 112**Expected Results**:113- โœ… Image loads without errors114- โœ… Graph shows nodes (blue = chunks, green = entities)115- โœ… Edges show relationships116- โœ… Layout is readable and clear117 118**Image Properties**:119- Resolution: 150 DPI120- Format: PNG121- Size: 800x600px (approximately)122 123---124 125### Test 4: Simple Query126 127**Objective**: Test RAG functionality with CSV data128 129**Steps**:1301. Upload `test_data.csv`1312. Wait for "ready" status1323. In chat section:133   - Select document from dropdown134   - Type query: "Who is the senior engineer?"135   - Click "Send"136 137**Expected Results**:138- โœ… Chat message appears139- โœ… Loading indicator shows140- โœ… Bot responds with answer141- โœ… Response references Alice Johnson142- โœ… Response appears in 2-5 seconds143 144**Example Expected Answer**:145```146Based on the provided data, Alice Johnson is the Senior Engineer 147in the Engineering Department with a salary of $120,000.148```149 150---151 152### Test 5: Knowledge-based Query153 154**Objective**: Test with text document155 156**Steps**:1571. Upload `sample.txt` (NLP/ML content)1582. Wait for "ready" status1593. Query: "What is machine learning?"160 161**Expected Results**:162- โœ… Bot provides accurate explanation163- โœ… Answer comes from the document context164- โœ… Response is relevant and coherent165 166**Example Expected Answer**:167```168Machine learning is a method of data analysis that automates 169analytical model building. It is a branch of artificial 170intelligence based on the idea that systems can learn from data.171```172 173---174 175### Test 6: Multi-chunk Context176 177**Objective**: Test queries that require context from multiple chunks178 179**Steps**:1801. Upload `sample.txt`1812. Query: "What are the relationships between NLP, machine learning, and graph databases?"182 183**Expected Results**:184- โœ… Answer synthesizes information across multiple chunks185- โœ… Shows understanding of relationships186- โœ… Confidence score is shown187 188---189 190### Test 7: Out-of-context Query191 192**Objective**: Test handling of irrelevant queries193 194**Steps**:1951. Upload `test_data.csv` (employee data)1962. Query: "What is quantum physics?"197 198**Expected Results**:199- โœ… Bot responds: "No relevant information found in the document"200- โœ… No incorrect information is generated201- โœ… Error is handled gracefully202 203---204 205### Test 8: Document Deletion206 207**Objective**: Verify document removal208 209**Steps**:2101. Upload `test_data.csv`2112. Wait for "ready" status2123. Click "Delete" button2134. Confirm deletion214 215**Expected Results**:216- โœ… Document disappears from list217- โœ… Graph image is removed218- โœ… Cannot query deleted document219- โœ… Dropdown option removed220 221---222 223### Test 9: Error Handling - Invalid File224 225**Objective**: Test upload of unsupported format226 227**Steps**:2281. Try to upload file with unsupported extension (.exe, .jpg, etc.)2292. Observe UI response230 231**Expected Results**:232- โœ… File is accepted (upload endpoint)233- โœ… Processing fails with meaningful error234- โœ… Status shows "error"235- โœ… Error message visible: "Unsupported file type"236 237---238 239### Test 10: Error Handling - Large File240 241**Objective**: Test max file size limit242 243**Steps**:2441. Create a file > 50MB2452. Try to upload246 247**Expected Results**:248- โœ… Upload is rejected249- โœ… Error message: "File too large"250- โœ… File not added to list251 252---253 254### Test 11: UI Responsiveness255 256**Objective**: Verify UI doesn't freeze during processing257 258**Steps**:2591. Upload a large PDF2602. While processing, try:261   - Typing in chat box โ† Should work262   - Clicking buttons โ† Should respond263   - Switching tabs โ† Should work smoothly264   - Scrolling document list โ† Should scroll265 266**Expected Results**:267- โœ… All interactions responsive268- โœ… No UI freezing269- โœ… Processing continues in background270 271---272 273### Test 12: Document List Auto-refresh274 275**Objective**: Verify real-time status updates276 277**Steps**:2781. Upload document2792. Watch the status bar update2803. Monitor without manual refresh281 282**Expected Results**:283- โœ… Status updates every 1.5 seconds284- โœ… Progress bar moves smoothly285- โœ… No manual refresh needed286- โœ… Final status appears automatically287 288---289 290### Test 13: Browser Compatibility291 292**Test on**: Chrome, Firefox, Safari, Edge293 294**Steps for each browser**:2951. Load application homepage2962. Test file upload2973. Test chat functionality2984. Check graph visualization299 300**Expected Results**:301- โœ… UI loads correctly302- โœ… All features work303- โœ… No console errors304- โœ… Styling renders properly305 306---307 308### Test 14: Mobile Responsiveness309 310**Steps**:3111. Open on mobile device (or DevTools)3122. Set viewport to 375ร—667 (iPhone)3133. Test all features:314   - Upload315   - Chat316   - Graph viewing317   - Navigation318 319**Expected Results**:320- โœ… Layout adapts to mobile321- โœ… Single column layout322- โœ… Touch interactions work323- โœ… Text is readable324 325---326 327### Test 15: API Endpoints Directly328 329**Tool**: curl, Postman, or Python requests330 331#### Upload Request332```bash333curl -X POST \334  -F "files=@test_data.csv" \335  http://localhost:7860/api/upload336```337 338**Expected Response**:339```json340{341  "success": true,342  "message": "โœ… 1 file(s) queued for processing",343  "successful": 1,344  "failed": 0,345  "files": ["test_data.csv"]346}347```348 349#### Get Documents350```bash351curl http://localhost:7860/api/documents352```353 354**Expected Response**:355```json356{357  "documents": {358    "test_data.csv": {359      "status": "ready",360      "chunks": 1,361      "entities": 10,362      "graph_image": "/graph-image/test_data.csv"363    }364  },365  "api_key_set": true,366  "timestamp": "2024-01-15T10:30:00"367}368```369 370#### Query371```bash372curl -X POST \373  -H "Content-Type: application/json" \374  -d '{"query": "Who is the senior engineer?", "document": "test_data.csv"}' \375  http://localhost:7860/api/query376```377 378**Expected Response**:379```json380{381  "answer": "Based on the data, Alice Johnson is the Senior Engineer...",382  "sources": ["Chunk 1"],383  "confidence": 0.85384}385```386 387---388 389## Performance Benchmarks390 391### Expected Processing Times392 393| Document Type | Size | Processing Time |394|---|---|---|395| CSV (5 rows) | ~1KB | 2-3s |396| Small TXT | ~5KB | 3-5s |397| Medium PDF | 20 pages | 10-15s |398| Large PDF | 50+ pages | 30-60s |399 400### Query Response Times401 402- Simple query (1-2 words): 1-2s403- Complex query (5+ words): 2-4s404- Graph visualization load: <100ms405 406---407 408## Load Testing409 410### Single User411- 10 queries: Should complete in ~20-30s412- 5 uploads: Should complete in ~30-45s413 414### Concurrent Users (Docker)415- 3 simultaneous uploads: Should handle smoothly416- 5 concurrent queries: Should not block417 418---419 420## Checklist Summary421 422- [ ] Single document upload works423- [ ] Multiple document upload works424- [ ] Document shows processing status425- [ ] Graph visualization loads426- [ ] Simple query works427- [ ] Multi-context query works428- [ ] Out-of-context query handled429- [ ] Document deletion works430- [ ] Error messages appear for errors431- [ ] UI remains responsive432- [ ] Status updates automatically433- [ ] Works in multiple browsers434- [ ] Mobile responsive layout435- [ ] API endpoints work436- [ ] Performance acceptable437 438---439 440## Debugging Tips441 442### Check Logs443```bash444# Docker445docker-compose logs -f446 447# Local448python app.py  # Watch console output449```450 451### Common Issues452 453**Issue**: Graph doesn't load454- Check: `data/graph_data/` folder exists455- Check: Matplotlib installed456- Check: file permissions457 458**Issue**: Chat unresponsive459- Check: GROQ_API_KEY set460- Check: Document status is "ready"461- Check: Network connectivity462 463**Issue**: Slow processing464- Check: File size465- Check: System RAM/CPU466- Check: Model download complete467 468**Issue**: Files disappear469- Note: HF Spaces ephemeral storage470- Solution: Use persistent storage option471 472---473 474## Test Report Template475 476```477Test Run Date: ____478Tester Name: ____479Environment: (Local/Docker/HF Spaces)480OS: ____481Browser: ____482 483PASS/FAIL | Test Case | Notes484---|---|---485 | Test 1 |486 | Test 2 |487 | Test 3 |488...489 490Issues Found:4911. 4922.4933.494 495Overall Result: PASS/FAIL496```497 498---499 500**Happy Testing! ๐ŸŽ‰**501 502If you find issues, report them with:503- Steps to reproduce504- Expected vs actual behavior505- Browser/OS information506- Relevant logs507