Forgot to lint again
Some checks failed
CI/CD Pipeline - Build, Test, and Deploy / 🧪 Test & Lint (push) Successful in 9m31s
CI/CD Pipeline - Build, Test, and Deploy / 🔒 Security Scan (push) Successful in 9m29s
CI/CD Pipeline - Build, Test, and Deploy / 🏗️ Build & Push Image (push) Failing after 11m19s
CI/CD Pipeline - Build, Test, and Deploy / 🛡️ Image Security Scan (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🚀 Deploy to Development (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🏭 Deploy to Production (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🧹 Cleanup (push) Successful in 1s
Some checks failed
CI/CD Pipeline - Build, Test, and Deploy / 🧪 Test & Lint (push) Successful in 9m31s
CI/CD Pipeline - Build, Test, and Deploy / 🔒 Security Scan (push) Successful in 9m29s
CI/CD Pipeline - Build, Test, and Deploy / 🏗️ Build & Push Image (push) Failing after 11m19s
CI/CD Pipeline - Build, Test, and Deploy / 🛡️ Image Security Scan (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🚀 Deploy to Development (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🏭 Deploy to Production (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🧹 Cleanup (push) Successful in 1s
This commit is contained in:
93
tests/app.test.js
Normal file
93
tests/app.test.js
Normal file
@ -0,0 +1,93 @@
|
||||
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');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user