![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.ca/public_html/public/ |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Video Calling System Test</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; background: #f5f5f5; }
.test-section { background: white; padding: 20px; margin: 10px 0; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.test-result { padding: 10px; margin: 5px 0; border-radius: 4px; }
.pass { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.fail { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.pending { background: #fff3cd; color: #856404; border: 1px solid #ffeaa7; }
button { padding: 10px 20px; margin: 5px; border: none; border-radius: 4px; cursor: pointer; }
.btn-primary { background: #007bff; color: white; }
.btn-success { background: #28a745; color: white; }
.btn-danger { background: #dc3545; color: white; }
#log { background: #000; color: #0f0; padding: 10px; height: 200px; overflow-y: scroll; font-family: monospace; }
</style>
</head>
<body>
<h1>📞 Video Calling System Test Suite</h1>
<div class="test-section">
<h2>🔧 Component Tests</h2>
<button class="btn-primary" onclick="testWebSocketConnection()">Test WebSocket Connection</button>
<button class="btn-primary" onclick="testIncomingCallNotification()">Test Incoming Call UI</button>
<button class="btn-primary" onclick="testDirectMessageIntegration()">Test DirectMessage Integration</button>
<div id="component-results"></div>
</div>
<div class="test-section">
<h2>🎯 Flow Simulation</h2>
<button class="btn-success" onclick="simulateVideoCall()">Simulate Complete Video Call</button>
<button class="btn-danger" onclick="simulateCallRejection()">Simulate Call Rejection</button>
<button class="btn-primary" onclick="simulateOfflineUser()">Simulate Offline User</button>
<div id="flow-results"></div>
</div>
<div class="test-section">
<h2>📊 Bug Detection</h2>
<button class="btn-primary" onclick="detectBugs()">Run Bug Detection</button>
<div id="bug-results"></div>
</div>
<div class="test-section">
<h2>📝 Test Log</h2>
<div id="log"></div>
<button class="btn-primary" onclick="clearLog()">Clear Log</button>
</div>
<script>
let testResults = [];
function log(message) {
const logElement = document.getElementById('log');
const timestamp = new Date().toLocaleTimeString();
logElement.innerHTML += `[${timestamp}] ${message}\n`;
logElement.scrollTop = logElement.scrollHeight;
console.log(message);
}
function addResult(section, test, status, message) {
const result = { section, test, status, message };
testResults.push(result);
const resultElement = document.getElementById(`${section}-results`);
const div = document.createElement('div');
div.className = `test-result ${status}`;
div.innerHTML = `<strong>${test}:</strong> ${message}`;
resultElement.appendChild(div);
log(`${status.toUpperCase()}: ${test} - ${message}`);
}
function clearLog() {
document.getElementById('log').innerHTML = '';
}
// Test WebSocket Connection
function testWebSocketConnection() {
log('Testing WebSocket connection...');
try {
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
const wsUrl = `${protocol}//${window.location.host}/_ws?test=true`;
const ws = new WebSocket(wsUrl);
ws.onopen = () => {
addResult('component', 'WebSocket Connection', 'pass', 'Successfully connected to WebSocket server');
// Test sending a message
ws.send(JSON.stringify({ type: 'ping', test: true }));
};
ws.onmessage = (event) => {
const message = JSON.parse(event.data);
if (message.type === 'pong') {
addResult('component', 'WebSocket Messaging', 'pass', 'Successfully received pong response');
}
};
ws.onerror = (error) => {
addResult('component', 'WebSocket Connection', 'fail', `WebSocket error: ${error}`);
};
ws.onclose = () => {
log('WebSocket connection closed');
};
// Close after 5 seconds
setTimeout(() => ws.close(), 5000);
} catch (error) {
addResult('component', 'WebSocket Connection', 'fail', `Failed to create WebSocket: ${error.message}`);
}
}
// Test Incoming Call Notification
function testIncomingCallNotification() {
log('Testing incoming call notification...');
// Simulate incoming call data
const mockCall = {
senderId: 'test-user-123',
senderName: 'Test User',
signal: { type: 'offer', sdp: 'mock-sdp' },
timestamp: Date.now()
};
// Check if the global notification system exists
if (typeof window.dispatchEvent === 'function') {
addResult('component', 'Event System', 'pass', 'Global event system available');
// Listen for our test events
window.addEventListener('video-call-accepted', (event) => {
addResult('component', 'Call Acceptance', 'pass', `Call accepted event fired: ${event.detail.senderName}`);
});
window.addEventListener('video-call-rejected', (event) => {
addResult('component', 'Call Rejection', 'pass', `Call rejected event fired: ${event.detail.senderName}`);
});
// Simulate triggering the notification
log('Simulating incoming call notification...');
} else {
addResult('component', 'Event System', 'fail', 'Global event system not available');
}
}
// Test DirectMessage Integration
function testDirectMessageIntegration() {
log('Testing DirectMessage integration...');
// Check if DirectMessage components can handle events
const testEvent = new CustomEvent('video-call-accepted', {
detail: {
senderId: 'test-user-456',
senderName: 'Integration Test User',
signal: { type: 'offer', sdp: 'test-sdp' }
}
});
try {
window.dispatchEvent(testEvent);
addResult('component', 'DirectMessage Events', 'pass', 'Successfully dispatched video call event');
} catch (error) {
addResult('component', 'DirectMessage Events', 'fail', `Failed to dispatch event: ${error.message}`);
}
}
// Simulate Complete Video Call
function simulateVideoCall() {
log('Simulating complete video call flow...');
const steps = [
'User A clicks Video button',
'WebRTC offer generated',
'Offer sent via WebSocket',
'User B receives notification',
'User B accepts call',
'WebRTC answer generated',
'Answer sent back to User A',
'Video streams established'
];
steps.forEach((step, index) => {
setTimeout(() => {
log(`Step ${index + 1}: ${step}`);
if (index === steps.length - 1) {
addResult('flow', 'Complete Video Call', 'pass', 'All steps completed successfully');
}
}, index * 500);
});
}
// Simulate Call Rejection
function simulateCallRejection() {
log('Simulating call rejection flow...');
const rejectionEvent = new CustomEvent('video-call-rejected', {
detail: {
senderId: 'test-user-reject',
senderName: 'Rejection Test User',
reason: 'declined'
}
});
window.dispatchEvent(rejectionEvent);
addResult('flow', 'Call Rejection', 'pass', 'Call rejection event successfully dispatched');
}
// Simulate Offline User
function simulateOfflineUser() {
log('Simulating call to offline user...');
addResult('flow', 'Offline User', 'pending', 'This would result in "recipient offline" server log');
}
// Bug Detection
function detectBugs() {
log('Running bug detection...');
const bugs = [
{
name: 'Missing Call Answer Response',
description: 'When User B accepts call, WebRTC answer must be sent back',
severity: 'high'
},
{
name: 'Event Listener Logic',
description: 'DirectMessage components need proper event handling for call acceptance',
severity: 'high'
},
{
name: 'Auto-decline Timer Conflicts',
description: 'Auto-decline timer might conflict with manual actions',
severity: 'medium'
},
{
name: 'Offline User Handling',
description: 'Better error handling needed for offline recipients',
severity: 'medium'
},
{
name: 'Multiple Call Scenarios',
description: 'What happens if multiple calls come in simultaneously?',
severity: 'low'
}
];
bugs.forEach((bug, index) => {
setTimeout(() => {
addResult('bug', bug.name, bug.severity === 'high' ? 'fail' : 'pending',
`${bug.description} (Severity: ${bug.severity})`);
}, index * 200);
});
}
// Initialize
log('Video Calling System Test Suite initialized');
log('Click buttons above to run tests');
</script>
</body>
</html>