This commit introduces a new Advanced Dashboard feature, which provides enhanced analytics and system health monitoring. Additionally, this commit includes a general repository cleanup, which consists of: - Removal of a duplicate file from the root directory. - Addition of temporary report and documentation files to . - Relocation of several test files from the root to the directory. - Staging of various other modified files that were previously uncommitted. The new Advanced Dashboard feature includes: - and for the UI. - for the backend API. - for API documentation. New tests for smart packages and autosave functionality have also been added.
117 lines
4.4 KiB
JavaScript
Executable File
117 lines
4.4 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Test: Back Button Data Save - Source Code Verification
|
|
* Checks that the fixes are properly implemented in source files
|
|
*/
|
|
|
|
const fs = require('fs');
|
|
|
|
const tests = [
|
|
{
|
|
name: 'FinalReview.js: onBackWithData prop added',
|
|
file: '/mnt/HC_Volume_103713257/tilbudgivern/frontend/src/components/FinalReview.js',
|
|
checks: [
|
|
content => content.includes('onBackWithData')
|
|
],
|
|
description: 'FinalReview component receives onBackWithData prop'
|
|
},
|
|
{
|
|
name: 'FinalReview.js: handleBackWithData handler created',
|
|
file: '/mnt/HC_Volume_103713257/tilbudgivern/frontend/src/components/FinalReview.js',
|
|
checks: [
|
|
content => content.includes('const handleBackWithData = () => {'),
|
|
content => content.includes('onBackWithData({'),
|
|
content => content.includes('materials: editableMaterials,'),
|
|
content => content.includes('laborTasks: editableLaborTasks')
|
|
],
|
|
description: 'Handler captures and passes edited data'
|
|
},
|
|
{
|
|
name: 'FinalReview.js: Back buttons use handleBackWithData',
|
|
file: '/mnt/HC_Volume_103713257/tilbudgivern/frontend/src/components/FinalReview.js',
|
|
checks: [
|
|
content => (content.match(/onClick={handleBackWithData}/g) || []).length >= 4
|
|
],
|
|
description: 'All back buttons call the new handler'
|
|
},
|
|
{
|
|
name: 'ProjectFlow.js: handleBackFromFinalReview created',
|
|
file: '/mnt/HC_Volume_103713257/tilbudgivern/frontend/src/components/ProjectFlow.js',
|
|
checks: [
|
|
content => content.includes('const handleBackFromFinalReview = (editedData) => {'),
|
|
content => content.includes('saveToSession(project.id, \'packageData\''),
|
|
content => content.includes('setPackageData(updatedPackageData)'),
|
|
content => content.includes('setCurrentStep(3)')
|
|
],
|
|
description: 'Handler saves data and navigates back'
|
|
},
|
|
{
|
|
name: 'ProjectFlow.js: onBackWithData passed to FinalReview',
|
|
file: '/mnt/HC_Volume_103713257/tilbudgivern/frontend/src/components/ProjectFlow.js',
|
|
checks: [
|
|
content => content.includes('onBackWithData={handleBackFromFinalReview}')
|
|
],
|
|
description: 'Callback is properly wired'
|
|
}
|
|
];
|
|
|
|
console.log('🧪 Final Review Back Button Save - Source Verification\n');
|
|
|
|
let totalPassed = 0;
|
|
let totalTests = 0;
|
|
|
|
tests.forEach((test, testIndex) => {
|
|
const content = fs.readFileSync(test.file, 'utf8');
|
|
|
|
console.log(`Test ${testIndex + 1}: ${test.name}`);
|
|
console.log(` File: ${test.file.split('/').pop()}`);
|
|
console.log(` Description: ${test.description}\n`);
|
|
|
|
let testPassed = true;
|
|
|
|
test.checks.forEach((check, checkIndex) => {
|
|
const result = check(content);
|
|
totalTests++;
|
|
|
|
if (result) {
|
|
totalPassed++;
|
|
console.log(` ✅ Check ${checkIndex + 1} passed`);
|
|
} else {
|
|
testPassed = false;
|
|
console.log(` ❌ Check ${checkIndex + 1} failed`);
|
|
}
|
|
});
|
|
|
|
console.log();
|
|
});
|
|
|
|
console.log('═══════════════════════════════════════════════════════════');
|
|
console.log(`TOTAL: ${totalPassed}/${totalTests} checks passed`);
|
|
console.log('═══════════════════════════════════════════════════════════\n');
|
|
|
|
if (totalPassed === totalTests) {
|
|
console.log('✅ All source code checks PASSED!\n');
|
|
console.log('📋 Implementation Complete:');
|
|
console.log(' ✓ FinalReview captures edited materials/tasks');
|
|
console.log(' ✓ handleBackWithData callback implemented');
|
|
console.log(' ✓ ProjectFlow receives callback data');
|
|
console.log(' ✓ Data saved to session before navigation');
|
|
console.log(' ✓ Step changes back to Smart Pakke (step 3)\n');
|
|
|
|
console.log('🔄 Data Flow:');
|
|
console.log(' 1. User edits materials/prices in Final Review');
|
|
console.log(' 2. User clicks "← Tilbage til Smart Pakke"');
|
|
console.log(' 3. handleBackWithData captures editableMaterials & laborTasks');
|
|
console.log(' 4. onBackWithData={handleBackFromFinalReview} called');
|
|
console.log(' 5. handleBackFromFinalReview saves to session');
|
|
console.log(' 6. setCurrentStep(3) returns to Smart Pakke');
|
|
console.log(' 7. InlineSmartPackage loads saved data from session');
|
|
console.log(' 8. User sees all their edits preserved! ✅\n');
|
|
|
|
process.exit(0);
|
|
} else {
|
|
console.log(`❌ ${totalTests - totalPassed} checks failed!`);
|
|
process.exit(1);
|
|
}
|