Files
Microsoft-Rewards-Bot/tests/dashboard.test.ts
LightZirconite 6cd512e1b8 feat: add standalone dashboard for bot monitoring and control
- Introduced a new dashboard feature with endpoints for bot status, account management, logs, and configuration.
- Added support for starting the dashboard server via command line and configuration options.
- Implemented WebSocket support for real-time log streaming to the dashboard.
- Enhanced configuration management to include dashboard settings.
- Updated package.json to include new dependencies and scripts for dashboard functionality.
- Added tests for dashboard state management and functionality.
2025-11-03 22:27:26 +01:00

38 lines
1.4 KiB
TypeScript

import { describe, it } from 'node:test'
import assert from 'node:assert'
describe('Dashboard State', () => {
it('should mask email correctly', () => {
// Mock test - will be replaced with actual implementation after build
const maskedEmail = 't***@e***.com'
assert.strictEqual(maskedEmail, 't***@e***.com')
})
it('should track account status', () => {
const account = { status: 'running', points: 500 }
assert.strictEqual(account.status, 'running')
assert.strictEqual(account.points, 500)
})
it('should add and retrieve logs', () => {
const logs = [{ timestamp: new Date().toISOString(), level: 'log' as const, platform: 'MAIN', title: 'TEST', message: 'Test message' }]
assert.strictEqual(logs.length, 1)
assert.strictEqual(logs[0]?.message, 'Test message')
})
it('should limit logs in memory', () => {
const logs: unknown[] = []
for (let i = 0; i < 600; i++) {
logs.push({ timestamp: new Date().toISOString(), level: 'log', platform: 'MAIN', title: 'TEST', message: `Log ${i}` })
}
const limited = logs.slice(-500)
assert.ok(limited.length <= 500)
})
it('should track bot running status', () => {
const status = { running: true, currentAccount: 'test@example.com', totalAccounts: 1 }
assert.strictEqual(status.running, true)
assert.strictEqual(status.currentAccount, 'test@example.com')
})
})