Files
harbor-ci-cd-demo/tests/api.tests.js
stephenminakian daf3dbe0ef
Some checks failed
CI/CD Pipeline - Build, Test, and Deploy / 🧪 Test & Lint (push) Failing after 5m24s
CI/CD Pipeline - Build, Test, and Deploy / 🔒 Security Scan (push) Successful in 10m1s
CI/CD Pipeline - Build, Test, and Deploy / 🏗️ Build & Push Image (push) Has been skipped
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
Add System Monitoring Dashboard with Harbor CI/CD integration
2025-07-02 15:03:15 -06:00

87 lines
3.0 KiB
JavaScript

const request = require('supertest');
const app = require('../src/app');
describe('API Endpoints', () => {
describe('GET /api/system', () => {
it('should return system information', async () => {
const response = await request(app)
.get('/api/system')
.expect(200);
expect(response.body.success).toBe(true);
expect(response.body.data).toHaveProperty('hostname');
expect(response.body.data).toHaveProperty('platform');
expect(response.body.data).toHaveProperty('cpus');
expect(response.body.data).toHaveProperty('totalMemory');
expect(typeof response.body.data.cpus).toBe('number');
});
});
describe('GET /api/memory', () => {
it('should return memory information', async () => {
const response = await request(app)
.get('/api/memory')
.expect(200);
expect(response.body.success).toBe(true);
expect(response.body.data).toHaveProperty('system');
expect(response.body.data).toHaveProperty('process');
expect(response.body.data.system).toHaveProperty('total');
expect(response.body.data.system).toHaveProperty('used');
expect(response.body.data.process).toHaveProperty('rss');
});
});
describe('GET /api/process', () => {
it('should return process information', async () => {
const response = await request(app)
.get('/api/process')
.expect(200);
expect(response.body.success).toBe(true);
expect(response.body.data).toHaveProperty('pid');
expect(response.body.data).toHaveProperty('uptime');
expect(response.body.data).toHaveProperty('version');
expect(typeof response.body.data.pid).toBe('number');
});
});
describe('GET /api/metrics', () => {
it('should return application metrics', async () => {
const response = await request(app)
.get('/api/metrics')
.expect(200);
expect(response.body.success).toBe(true);
expect(response.body.data).toHaveProperty('counters');
expect(response.body.data).toHaveProperty('gauges');
expect(response.body.data).toHaveProperty('histograms');
expect(response.body.data).toHaveProperty('runtime');
expect(Array.isArray(response.body.data.counters)).toBe(true);
});
});
describe('GET /api/test', () => {
it('should return test response', async () => {
const response = await request(app)
.get('/api/test')
.expect(200);
expect(response.body.success).toBe(true);
expect(response.body.message).toBe('API is working correctly');
expect(response.body).toHaveProperty('version');
expect(response.body).toHaveProperty('timestamp');
});
});
describe('Error handling', () => {
it('should return 404 for unknown API endpoints', async () => {
const response = await request(app)
.get('/api/nonexistent')
.expect(404);
expect(response.body).toHaveProperty('error');
expect(response.body.error).toBe('Not Found');
});
});
});