const request = require('supertest'); const app = require('../src/app'); describe('Main Application', () => { describe('Static file serving', () => { it('should serve the main dashboard page', async() => { const response = await request(app) .get('/') .expect(200); expect(response.headers['content-type']).toMatch(/html/); }); it('should serve static CSS files', async() => { const response = await request(app) .get('/style.css') .expect(200); expect(response.headers['content-type']).toMatch(/css/); }); it('should serve static JavaScript files', async() => { const response = await request(app) .get('/app.js') .expect(200); expect(response.headers['content-type']).toMatch(/javascript/); }); }); describe('Debug endpoints', () => { it('should return debug file information', async() => { const response = await request(app) .get('/debug/files') .expect(200); expect(response.body).toHaveProperty('publicPath'); expect(response.body).toHaveProperty('files'); expect(Array.isArray(response.body.files)).toBe(true); }); it('should serve test static page', async() => { const response = await request(app) .get('/test-static') .expect(200); expect(response.text).toContain('Static File Test'); expect(response.headers['content-type']).toMatch(/html/); }); }); describe('Error handling', () => { it('should return 404 for unknown routes', async() => { const response = await request(app) .get('/nonexistent-route') .expect(404); expect(response.body).toHaveProperty('error', 'Not Found'); expect(response.body).toHaveProperty('url', '/nonexistent-route'); }); }); describe('CORS and Security', () => { it('should include CORS headers', async() => { const response = await request(app) .get('/api/system') .expect(200); expect(response.headers).toHaveProperty('access-control-allow-origin'); }); it('should include basic Express headers', async() => { const response = await request(app) .get('/') .expect(200); // Check for basic Express headers that should be present expect(response.headers).toHaveProperty('x-powered-by', 'Express'); expect(response.headers).toHaveProperty('content-type'); }); }); describe('Request logging', () => { it('should log requests without errors', async() => { // This test ensures the logging middleware doesn't crash const response = await request(app) .get('/health') .expect(200); expect(response.body).toHaveProperty('status', 'healthy'); }); }); });