diff --git a/testBackupHealthFix.html b/testBackupHealthFix.html
deleted file mode 100644
index 93aa9f107..000000000
--- a/testBackupHealthFix.html
+++ /dev/null
@@ -1,153 +0,0 @@
-
-
-
- Test Backup Health Fix
-
-
-
- Backup Health Fix Test
-
-
-
Instructions:
-
- - Start the Pulse server:
npm run dev
- - Open this file in a browser
- - Open the browser console to see debug logs
- - Click "Connect to Pulse" below
- - Look for "[Backup Health Debug]" messages in the console
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/timestamp-validation-test.js b/timestamp-validation-test.js
deleted file mode 100644
index 217a239f4..000000000
--- a/timestamp-validation-test.js
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/usr/bin/env node
-
-/**
- * Timestamp Validation Test
- * Simple test to verify our timestamp validation logic works correctly
- */
-
-const AlertManager = require('./server/alertManager');
-
-function testTimestampValidation() {
- console.log('š Testing Timestamp Validation Logic...\n');
-
- const alertManager = new AlertManager();
-
- try {
- console.log('1. Testing with valid triggeredAt...');
- const alertWithTriggeredAt = {
- triggeredAt: 1640995200000,
- lastUpdate: 1640995260000
- };
- const timestamp1 = alertManager.getValidTimestamp(alertWithTriggeredAt);
- console.log(` Result: ${timestamp1} (should be ${alertWithTriggeredAt.triggeredAt})`);
- if (timestamp1 !== alertWithTriggeredAt.triggeredAt) {
- throw new Error('Should use triggeredAt when available');
- }
- console.log('ā
PASS');
-
- console.log('\n2. Testing with missing triggeredAt (should use lastUpdate)...');
- const alertWithLastUpdate = {
- lastUpdate: 1640995260000
- };
- const timestamp2 = alertManager.getValidTimestamp(alertWithLastUpdate);
- console.log(` Result: ${timestamp2} (should be ${alertWithLastUpdate.lastUpdate})`);
- if (timestamp2 !== alertWithLastUpdate.lastUpdate) {
- throw new Error('Should use lastUpdate when triggeredAt is missing');
- }
- console.log('ā
PASS');
-
- console.log('\n3. Testing with both timestamps missing (should use current time)...');
- const alertWithoutTimestamps = {};
- const before = Date.now();
- const timestamp3 = alertManager.getValidTimestamp(alertWithoutTimestamps);
- const after = Date.now();
- console.log(` Result: ${timestamp3} (should be between ${before} and ${after})`);
- if (timestamp3 < before || timestamp3 > after) {
- throw new Error('Should use current time when both timestamps are missing');
- }
- console.log('ā
PASS');
-
- console.log('\n4. Testing with invalid timestamps (should use current time)...');
- const alertWithInvalidTimestamps = {
- triggeredAt: 'invalid-date',
- lastUpdate: null
- };
- const before2 = Date.now();
- const timestamp4 = alertManager.getValidTimestamp(alertWithInvalidTimestamps);
- const after2 = Date.now();
- console.log(` Result: ${timestamp4} (should be between ${before2} and ${after2})`);
- if (timestamp4 < before2 || timestamp4 > after2) {
- throw new Error('Should use current time when timestamps are invalid');
- }
- console.log('ā
PASS');
-
- console.log('\n5. Testing ISO string generation (the original error)...');
- const testTimestamps = [
- 1640995200000, // Valid timestamp
- 'invalid-date', // Invalid string
- null, // Null
- undefined, // Undefined
- NaN // NaN
- ];
-
- testTimestamps.forEach((testTs, index) => {
- const testAlert = { triggeredAt: testTs };
- const validTs = alertManager.getValidTimestamp(testAlert);
- try {
- const isoString = new Date(validTs).toISOString();
- console.log(` Test ${index + 1}: ${testTs} ā ${validTs} ā ${isoString} ā
`);
- } catch (error) {
- throw new Error(`Failed to generate ISO string for ${testTs}: ${error.message}`);
- }
- });
- console.log('ā
PASS - No RangeError exceptions thrown');
-
- console.log('\nš All Timestamp Validation Tests Passed!');
- console.log(' ā
Valid timestamps are preserved');
- console.log(' ā
Invalid timestamps fall back to current time');
- console.log(' ā
ISO string generation never throws RangeError');
- console.log(' ā
Teams webhook "Time Value Error" is completely fixed');
-
- console.log('\nš Summary:');
- console.log(' - The original bug was caused by undefined alert.timestamp');
- console.log(' - Our fix adds robust validation with proper fallbacks');
- console.log(' - The getValidTimestamp() method ensures valid dates always');
- console.log(' - Teams webhook notifications will now work reliably');
-
- } catch (error) {
- console.error('ā Test failed:', error.message);
- process.exit(1);
- } finally {
- alertManager.destroy();
- }
-}
-
-testTimestampValidation();
\ No newline at end of file
diff --git a/webhook-integration-test.js b/webhook-integration-test.js
deleted file mode 100644
index ee4cd4010..000000000
--- a/webhook-integration-test.js
+++ /dev/null
@@ -1,132 +0,0 @@
-#!/usr/bin/env node
-
-/**
- * Webhook Integration Test
- * This script tests the webhook functionality by simulating alert triggers
- */
-
-const axios = require('axios');
-
-const PULSE_API_BASE = 'http://localhost:7655/api';
-const WEBHOOK_SERVER = 'http://localhost:3001/webhook';
-
-async function testWebhookIntegration() {
- console.log('š Testing Webhook Integration...\n');
-
- try {
- // 1. Check if Pulse server is running
- console.log('1. Checking Pulse server status...');
- const healthResponse = await axios.get(`${PULSE_API_BASE}/health`);
- console.log('ā
Pulse server is running');
-
- // 2. Check if webhook server is running
- console.log('\n2. Checking webhook server status...');
- const webhookTestResponse = await axios.post(WEBHOOK_SERVER, {
- test: true,
- message: 'Integration test ping'
- });
- console.log('ā
Webhook server is responding');
-
- // 3. Get current alert configuration
- console.log('\n3. Fetching current alert configuration...');
- const alertsResponse = await axios.get(`${PULSE_API_BASE}/alerts`);
- const alertData = alertsResponse.data;
-
- console.log(`š Alert System Status:`);
- console.log(` - Active alerts: ${alertData.stats.active}`);
- console.log(` - Total rules: ${alertData.stats.totalRules}`);
- console.log(` - Webhook channel enabled: ${alertData.stats.channels.find(c => c.id === 'default')?.enabled}`);
-
- // 4. Test webhook using Pulse's built-in test endpoint
- console.log('\n4. Testing webhook using Pulse API...');
- const testWebhookApiResponse = await axios.post(`${PULSE_API_BASE}/test-webhook`, {
- url: WEBHOOK_SERVER,
- enabled: true
- });
-
- if (testWebhookApiResponse.data.success) {
- console.log('ā
Webhook test via Pulse API succeeded');
- } else {
- console.log('ā Webhook test via Pulse API failed:', testWebhookApiResponse.data.error);
- }
-
- // 5. Test webhook payload format
- console.log('\n5. Testing webhook payload format...');
- const testPayload = {
- timestamp: new Date().toISOString(),
- alert: {
- id: "test_alert_" + Date.now(),
- rule: {
- name: "Webhook Integration Test",
- description: "Test alert to verify webhook functionality",
- severity: "warning",
- metric: "cpu"
- },
- guest: {
- name: "test-webhook-guest",
- id: "999",
- type: "test",
- node: "test-node",
- status: "running"
- },
- value: 92,
- threshold: 85,
- emoji: "ā ļø"
- },
- embeds: [{
- title: "ā ļø Webhook Integration Test",
- description: "Test alert to verify webhook functionality",
- color: 15844367,
- fields: [
- {
- name: "Test Type",
- value: "Integration Test",
- inline: true
- },
- {
- name: "Status",
- value: "SUCCESS",
- inline: true
- }
- ],
- footer: {
- text: "Pulse Monitoring System - Test Mode"
- }
- }]
- };
-
- const testWebhookResponse = await axios.post(WEBHOOK_SERVER, testPayload, {
- headers: {
- 'Content-Type': 'application/json',
- 'User-Agent': 'Pulse-Monitoring/1.0'
- }
- });
-
- console.log('ā
Webhook payload test successful');
-
- console.log('\nš Webhook Integration Test Results:');
- console.log(' ā
Pulse server: Running');
- console.log(' ā
Webhook server: Running');
- console.log(' ā
Alert system: Configured');
- console.log(' ā
Webhook channel: Enabled');
- console.log(' ā
Payload format: Valid');
-
- console.log('\nš Next Steps:');
- console.log(' 1. Monitor the test-webhook.js console for incoming webhooks');
- console.log(' 2. Check if alerts are triggered naturally by your system metrics');
- console.log(' 3. If needed, temporarily lower alert thresholds to test real alerts');
- console.log(' 4. Webhook URL configured in .env: http://localhost:3001/webhook');
-
- } catch (error) {
- console.error('ā Webhook integration test failed:', error.message);
-
- if (error.code === 'ECONNREFUSED') {
- console.log('\nš” Troubleshooting:');
- console.log(' - Make sure both Pulse (port 7655) and test-webhook.js (port 3001) are running');
- console.log(' - Check that WEBHOOK_URL is set in .env file');
- }
- }
-}
-
-// Run the test
-testWebhookIntegration();
\ No newline at end of file