- Implemented a new test suite for production API verification using curl, ensuring all critical endpoints respond correctly and return valid JSON. - Added frontend integration tests to check for critical errors in the UI and verify key UI elements are present and functional. - Created test data for quotes and project calculations to facilitate testing. - Developed a script to check offers in the Ordrestyring system, including detailed task descriptions. - Added tests for generating PDFs from quote data, ensuring the output is valid and contains expected information. - Implemented a test script for the Røsevangen project, integrating with the Ordrestyring API and verifying database entries.
69 lines
2.0 KiB
JavaScript
69 lines
2.0 KiB
JavaScript
const express = require('express');
|
|
const path = require('path');
|
|
const cors = require('cors');
|
|
|
|
const app = express();
|
|
const PORT = process.env.PORT || 4031;
|
|
|
|
// Basic CORS and middleware
|
|
app.use(cors());
|
|
app.use(express.json({ limit: '50mb' }));
|
|
app.use(express.urlencoded({ extended: true, limit: '50mb' }));
|
|
|
|
// Mock API endpoints for testing
|
|
app.get('/api/enhanced/roof-types', (req, res) => {
|
|
console.log('📋 GET /api/enhanced/roof-types requested');
|
|
const roofTypes = [
|
|
{ value: 'sadeltag', label: 'Sadeltag/Skråttag' },
|
|
{ value: 'valmtag', label: 'Valmtag' },
|
|
{ value: 'kobenhavnertag', label: 'Københavnertag' }
|
|
];
|
|
res.json({ roofTypes, status: 'success' });
|
|
});
|
|
|
|
// Calendar/Planning endpoint mock
|
|
app.get('/api/planning/employees', (req, res) => {
|
|
console.log('👥 GET /api/planning/employees requested');
|
|
res.json({
|
|
employees: [
|
|
{ id: 1, name: 'Jannick', skills: ['carpenter', 'planner'] },
|
|
{ id: 2, name: 'Michael', skills: ['carpenter'] }
|
|
],
|
|
status: 'success'
|
|
});
|
|
});
|
|
|
|
app.get('/api/planning/calendar', (req, res) => {
|
|
console.log('📅 GET /api/planning/calendar requested');
|
|
res.json({
|
|
calendar: [],
|
|
message: 'Ingen planlagte opgaver endnu',
|
|
status: 'success'
|
|
});
|
|
});
|
|
|
|
// SmartPackages mock endpoints
|
|
app.get('/api/packages', (req, res) => {
|
|
console.log('📦 GET /api/packages requested with search:', req.query.search);
|
|
res.json({
|
|
packages: [
|
|
{ id: 1, name: 'Test Pakke', materials: [{ name: 'Spær 45x195', quantity: 10 }] }
|
|
],
|
|
status: 'success'
|
|
});
|
|
});
|
|
|
|
// Serve frontend
|
|
const frontendBuildPath = path.join(__dirname, 'frontend/build');
|
|
app.use(express.static(frontendBuildPath));
|
|
|
|
// Catch-all for React routes
|
|
app.get('*', (req, res) => {
|
|
res.sendFile(path.join(frontendBuildPath, 'index.html'));
|
|
});
|
|
|
|
app.listen(PORT, () => {
|
|
console.log(`🚀 Test server running on port ${PORT}`);
|
|
console.log('📋 Testing all 22 features with mock endpoints');
|
|
console.log('✅ Ready for frontend testing');
|
|
}); |