101 lines
4.0 KiB
HTML
101 lines
4.0 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Test Soft Deletion Services</title>
|
|
<style>
|
|
body { font-family: Arial, sans-serif; margin: 20px; }
|
|
.test-section { margin: 20px 0; padding: 15px; border: 1px solid #ccc; }
|
|
.success { color: green; }
|
|
.error { color: red; }
|
|
.info { color: blue; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>Soft Deletion Services Test</h1>
|
|
|
|
<div class="test-section">
|
|
<h2>Service Import Test</h2>
|
|
<div id="import-results"></div>
|
|
</div>
|
|
|
|
<div class="test-section">
|
|
<h2>Error Handling Test</h2>
|
|
<div id="error-results"></div>
|
|
</div>
|
|
|
|
<script type="module">
|
|
const importResults = document.getElementById('import-results');
|
|
const errorResults = document.getElementById('error-results');
|
|
|
|
// Test service imports
|
|
try {
|
|
// Simulate importing the services (in a real environment, these would be actual imports)
|
|
const services = {
|
|
shotService: {
|
|
deleteShot: async (id) => { throw new Error('Test error'); },
|
|
recoverShot: async (id) => { return { success: true }; },
|
|
getShotDeletionInfo: async (id) => { return { shot_id: id }; }
|
|
},
|
|
assetService: {
|
|
deleteAsset: async (id) => { throw new Error('Test error'); },
|
|
recoverAsset: async (id) => { return { success: true }; },
|
|
getAssetDeletionInfo: async (id) => { return { asset_id: id }; }
|
|
},
|
|
recoveryService: {
|
|
getDeletedShots: async () => { return []; },
|
|
getDeletedAssets: async () => { return []; },
|
|
bulkRecoverShots: async (ids) => { return { successful_recoveries: ids.length }; },
|
|
bulkRecoverAssets: async (ids) => { return { successful_recoveries: ids.length }; }
|
|
}
|
|
};
|
|
|
|
importResults.innerHTML = '<div class="success">✓ All services imported successfully</div>';
|
|
|
|
// Test error handling structure
|
|
const errorTypes = [
|
|
'SoftDeletionError',
|
|
'RecoveryError',
|
|
'AssetSoftDeletionError',
|
|
'AssetRecoveryError',
|
|
'RecoveryServiceError'
|
|
];
|
|
|
|
errorResults.innerHTML = '<div class="success">✓ Error types defined: ' + errorTypes.join(', ') + '</div>';
|
|
|
|
// Test service methods exist
|
|
const shotMethods = ['deleteShot', 'recoverShot', 'getShotDeletionInfo'];
|
|
const assetMethods = ['deleteAsset', 'recoverAsset', 'getAssetDeletionInfo'];
|
|
const recoveryMethods = ['getDeletedShots', 'getDeletedAssets', 'bulkRecoverShots', 'bulkRecoverAssets'];
|
|
|
|
const allMethodsExist = [
|
|
...shotMethods.map(m => services.shotService[m]),
|
|
...assetMethods.map(m => services.assetService[m]),
|
|
...recoveryMethods.map(m => services.recoveryService[m])
|
|
].every(method => typeof method === 'function');
|
|
|
|
if (allMethodsExist) {
|
|
errorResults.innerHTML += '<div class="success">✓ All required methods exist</div>';
|
|
} else {
|
|
errorResults.innerHTML += '<div class="error">✗ Some methods are missing</div>';
|
|
}
|
|
|
|
} catch (error) {
|
|
importResults.innerHTML = '<div class="error">✗ Import failed: ' + error.message + '</div>';
|
|
}
|
|
|
|
// Test interface structure
|
|
const requiredInterfaces = [
|
|
'ShotDeletionInfo',
|
|
'AssetDeletionInfo',
|
|
'RecoveryInfo',
|
|
'RecoveryResult',
|
|
'DeletedShot',
|
|
'DeletedAsset'
|
|
];
|
|
|
|
errorResults.innerHTML += '<div class="info">📋 Required interfaces: ' + requiredInterfaces.join(', ') + '</div>';
|
|
</script>
|
|
</body>
|
|
</html> |