- Add admin PWA push notifications for order management
- Integrate TeleBot customer messaging service
- Add push notification endpoints and VAPID key support
- Implement order status notifications throughout workflow
- Add notification UI components in admin panel
- Create TeleBotMessagingService for customer updates
- Add WebPush configuration to appsettings
- Fix compilation issues (BotStatus, BotContacts DbSet)
- Add comprehensive testing documentation
Features:
- Real-time admin notifications for new orders and status changes
- Customer order progress updates via TeleBot
- Graceful failure handling for notification services
- Test endpoints for notification system validation
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
12 KiB
12 KiB
🧪 Notification System Testing Plan
✅ Prerequisites Checklist
Environment Setup
- LittleShop application running locally (port 8080)
- TeleBot service running (if testing TeleBot integration)
- Admin user account created (admin/admin)
- Web browser with push notification support (Chrome/Edge/Firefox)
- BTCPay Server test instance configured
Configuration Verification
- Check VAPID keys are configured in appsettings.json
- Verify TeleBot API URL and API key are set
- Ensure database has been migrated/created
- Confirm admin user has Admin role in database
📱 Test Scenario 1: Admin PWA Push Notification Setup
1.1 Initial Setup Test
Steps:
- Open admin panel at http://localhost:8080/admin
- Login with admin credentials
- Check for notification prompt in navbar
- Click "Enable Notifications" button
Expected Results:
- Browser permission prompt appears
- After accepting, success message shows
- Notification icon changes to active state
- Test notification is received
Verification Commands:
# Check if subscription was saved
curl http://localhost:8080/api/push/subscriptions \
-H "Cookie: [admin-cookie]"
1.2 Test Notification Endpoint
Steps:
- Navigate to admin panel
- Click notification test button
- Send test notification
API Test:
curl -X POST http://localhost:8080/api/push/test \
-H "Content-Type: application/json" \
-H "Cookie: [admin-cookie]" \
-d '{"title":"Test Alert","body":"This is a test notification"}'
Expected Results:
- Push notification appears on device
- Notification contains correct title and body
- Clicking notification opens admin panel
📱 Test Scenario 2: Order Lifecycle Notifications
2.1 New Order Creation
Steps:
- Create a new order via API or TeleBot
- Monitor admin notifications
API Test:
curl -X POST http://localhost:8080/api/orders \
-H "Content-Type: application/json" \
-d '{
"customerIdentity": "test-customer-001",
"items": [
{
"productId": "[product-guid]",
"quantity": 1,
"priceAtPurchase": 10.00
}
],
"shippingAddress": "123 Test St",
"shippingMethod": "standard",
"totalAmount": 15.00
}'
Expected Admin Notifications:
- "New Order Received - Order #abc12345 created for £15.00"
2.2 Payment Confirmation
Steps:
- Simulate BTCPay webhook for payment confirmation
- Monitor notifications
Webhook Simulation:
curl -X POST http://localhost:8080/api/orders/payments/webhook \
-H "Content-Type: application/json" \
-H "BTCPay-Sig: [webhook-signature]" \
-d '{
"invoiceId": "[invoice-id]",
"status": "Settled",
"orderId": "[order-id]"
}'
Expected Notifications:
- Admin: "Payment Confirmed - Order #abc12345 payment confirmed. Ready for acceptance."
- TeleBot: Customer receives payment confirmation message
2.3 Order Status Progression
Test Each Status Change:
| Status Change | Admin Notification | Customer Message |
|---|---|---|
| Accept Order | "Order Accepted - Order #abc12345 has been accepted" | "Great news! Your order has been accepted..." |
| Start Packing | "Being Packed - Order #abc12345 is being packed" | "Your order is currently being packed..." |
| Dispatch | "Order Dispatched - Order #abc12345 dispatched with tracking: ABC123" | "Your order is on its way! Tracking: ABC123..." |
| Deliver | "Order Delivered - Order #abc12345 has been delivered" | "Your order has been delivered successfully..." |
Status Update Command:
# Accept order
curl -X PUT http://localhost:8080/api/admin/orders/[order-id]/status \
-H "Content-Type: application/json" \
-H "Cookie: [admin-cookie]" \
-d '{"status": "Accepted"}'
🤖 Test Scenario 3: TeleBot Customer Messaging
3.1 TeleBot Service Availability
Check Service Status:
curl http://localhost:8080/api/push/telebot/status \
-H "Cookie: [admin-cookie]"
Expected Response:
{
"available": true,
"message": "TeleBot service is available"
}
3.2 Test Message to Customer
Send Test Message:
curl -X POST http://localhost:8080/api/push/telebot/test \
-H "Content-Type: application/json" \
-H "Cookie: [admin-cookie]" \
-d '{
"customerId": "[customer-guid]",
"message": "Test message from LittleShop admin"
}'
Expected Results:
- Customer receives message in Telegram
- API returns success response
- Message delivery logged in system
3.3 Order Progress Messages
Monitor TeleBot messages during order lifecycle:
-
Payment Received:
- Message: "💰 Your order #abc12345 has been paid successfully..."
-
Order Accepted:
- Message: "✅ Great news! Your order #abc12345 has been accepted..."
-
Packing Started:
- Message: "📦 Your order #abc12345 is currently being packed..."
-
Order Dispatched:
- Message: "🚚 Your order #abc12345 is on its way! Tracking: ABC123..."
-
Order Delivered:
- Message: "🎉 Your order #abc12345 has been delivered successfully..."
🔧 Test Scenario 4: Error Handling
4.1 TeleBot Service Unavailable
Steps:
- Stop TeleBot service
- Process an order status change
- Verify system continues without errors
Expected Behavior:
- Order processing continues normally
- Error logged but not shown to user
- Admin notifications still work
4.2 Push Notification Failure
Steps:
- Invalidate push subscription in database
- Process order status change
- Verify graceful failure
Expected Behavior:
- Order processing continues
- Invalid subscription removed from database
- Error logged for debugging
4.3 Network Interruption
Steps:
- Simulate network failure to TeleBot API
- Process multiple orders
- Verify queue/retry mechanism
Expected Behavior:
- Messages queued for retry
- System remains responsive
- Notifications sent when connection restored
📊 Test Scenario 5: Performance Testing
5.1 Concurrent Orders
Test Load:
# Create 10 orders simultaneously
for i in {1..10}; do
curl -X POST http://localhost:8080/api/orders \
-H "Content-Type: application/json" \
-d "{\"customerIdentity\":\"customer-$i\",\"items\":[{\"productId\":\"[guid]\",\"quantity\":1}]}" &
done
Expected Results:
- All orders created successfully
- Notifications sent for each order
- No message loss or duplication
5.2 Notification Delivery Time
Measure:
- Time from order creation to admin notification
- Time from status change to customer message
- Expected: < 2 seconds for both
🔍 Test Scenario 6: Integration Testing
6.1 Full Order Flow Test
Complete Workflow:
- Customer creates order via TeleBot
- Admin receives new order notification
- Payment processed via BTCPay
- Both admin and customer notified
- Admin accepts order (notification sent)
- Admin marks as packing (notification sent)
- Admin dispatches with tracking (notification sent)
- Admin marks as delivered (notification sent)
Verification Points:
- 8 admin notifications received
- 5 customer messages sent
- All messages have correct content
- Order status correctly updated
- Audit trail complete
6.2 Multi-Admin Testing
Setup:
- Create 3 admin users
- Enable push notifications for all
- Process an order
Expected Results:
- All 3 admins receive notifications
- Notifications are identical
- No performance degradation
📝 Manual Testing Checklist
Admin Panel UI
- Notification icon shows correct status
- Test button works
- Permission prompt handled correctly
- Subscription list shows active subscriptions
- Cleanup removes old subscriptions
Order Management
- New order triggers notification
- Payment confirmation triggers notification
- Each status change triggers notification
- Bulk status updates send notifications
- Notification content is accurate
TeleBot Integration
- Service status endpoint works
- Test message endpoint works
- Customer receives all expected messages
- Messages formatted correctly with emojis
- Links and tracking info included
Error Scenarios
- Handles offline TeleBot gracefully
- Handles invalid push subscriptions
- Continues on notification failures
- Logs errors appropriately
- No user-facing error messages
🚀 Automated Test Commands
Run All Tests
# 1. Start services
cd /mnt/c/Production/Source/LittleShop
dotnet run --project LittleShop/LittleShop.csproj &
dotnet run --project TeleBot/TeleBot/TeleBot.csproj &
# 2. Wait for startup
sleep 10
# 3. Run test suite
./test-notifications.sh
# 4. Check results
cat notification-test-results.log
Create Test Script
#!/bin/bash
# test-notifications.sh
echo "Testing Admin Push Notifications..."
curl -X POST http://localhost:8080/api/push/test \
-H "Content-Type: application/json" \
-H "Cookie: $ADMIN_COOKIE" \
-d '{"title":"Test","body":"Testing"}' \
-w "\nStatus: %{http_code}\n"
echo "Testing TeleBot Service..."
curl http://localhost:8080/api/push/telebot/status \
-H "Cookie: $ADMIN_COOKIE" \
-w "\nStatus: %{http_code}\n"
echo "Creating Test Order..."
ORDER_ID=$(curl -X POST http://localhost:8080/api/orders \
-H "Content-Type: application/json" \
-d '{"customerIdentity":"test-001","items":[]}' \
-s | jq -r '.id')
echo "Order created: $ORDER_ID"
# Test status updates
for status in "Accepted" "Packing" "Dispatched" "Delivered"; do
echo "Updating to status: $status"
curl -X PUT "http://localhost:8080/api/admin/orders/$ORDER_ID/status" \
-H "Content-Type: application/json" \
-H "Cookie: $ADMIN_COOKIE" \
-d "{\"status\":\"$status\"}" \
-w "\nStatus: %{http_code}\n"
sleep 2
done
echo "Tests completed!"
✅ Success Criteria
Functional Requirements
- ✅ Admin users receive push notifications for all order events
- ✅ Customers receive TeleBot messages for order updates
- ✅ Notifications sent within 2 seconds of events
- ✅ System continues operating if notifications fail
- ✅ All notification content is accurate and formatted correctly
Non-Functional Requirements
- ✅ No performance impact on order processing
- ✅ Handles 100+ concurrent orders without issues
- ✅ Graceful degradation when services unavailable
- ✅ Comprehensive error logging
- ✅ No sensitive data in notifications
Documentation
- ✅ API endpoints documented
- ✅ Configuration requirements clear
- ✅ Troubleshooting guide available
- ✅ Test scenarios reproducible
🐛 Common Issues and Solutions
Issue: Push notifications not received
Solution:
- Check browser permissions
- Verify VAPID keys configured
- Ensure HTTPS in production
- Check service worker registration
Issue: TeleBot messages not sent
Solution:
- Verify TeleBot service running
- Check API URL and credentials
- Ensure customer has Telegram ID
- Review TeleBot logs
Issue: Duplicate notifications
Solution:
- Check for multiple subscriptions
- Verify single service instance
- Review event handling logic
- Check database for duplicates
📋 Test Report Template
## Notification System Test Report
**Date:** [Date]
**Tester:** [Name]
**Environment:** [Dev/Staging/Prod]
### Test Results Summary
- Admin Push Notifications: [PASS/FAIL]
- TeleBot Customer Messages: [PASS/FAIL]
- Error Handling: [PASS/FAIL]
- Performance: [PASS/FAIL]
### Issues Found
1. [Issue description and severity]
2. [Issue description and severity]
### Recommendations
- [Recommendation 1]
- [Recommendation 2]
### Sign-off
- [ ] Ready for production
- [ ] Requires fixes