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.
104 lines
3.7 KiB
JavaScript
Executable File
104 lines
3.7 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Test: Back Button Data Save from Final Review
|
|
* Verifies that edits made in Final Review are saved when going back
|
|
*/
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
// Read the built FinalReview component
|
|
const finalReviewPath = '/mnt/HC_Volume_103713257/tilbudgivern/frontend/build/static/js';
|
|
const files = fs.readdirSync(finalReviewPath);
|
|
const mainJs = files.find(f => f.startsWith('main.') && f.endsWith('.js'));
|
|
|
|
if (!mainJs) {
|
|
console.error('❌ Cannot find main.js in build');
|
|
process.exit(1);
|
|
}
|
|
|
|
const mainJsContent = fs.readFileSync(path.join(finalReviewPath, mainJs), 'utf8');
|
|
|
|
// Verify the fixes are in the production build
|
|
const tests = [
|
|
{
|
|
name: 'handleBackWithData handler exists',
|
|
test: () => mainJsContent.includes('handleBackWithData'),
|
|
description: 'FinalReview must have handleBackWithData function'
|
|
},
|
|
{
|
|
name: 'onBackWithData prop passed to FinalReview',
|
|
test: () => mainJsContent.includes('onBackWithData'),
|
|
description: 'ProjectFlow must pass onBackWithData callback'
|
|
},
|
|
{
|
|
name: 'handleBackFromFinalReview implemented',
|
|
test: () => mainJsContent.includes('handleBackFromFinalReview'),
|
|
description: 'ProjectFlow must have handleBackFromFinalReview handler'
|
|
},
|
|
{
|
|
name: 'editableMaterials used in back handler',
|
|
test: () => mainJsContent.includes('editableMaterials'),
|
|
description: 'Back handler must capture edited materials'
|
|
},
|
|
{
|
|
name: 'editableLaborTasks used in back handler',
|
|
test: () => mainJsContent.includes('editableLaborTasks'),
|
|
description: 'Back handler must capture edited labor tasks'
|
|
},
|
|
{
|
|
name: 'saveToSession called on back',
|
|
test: () => mainJsContent.includes('saveToSession') && mainJsContent.includes('packageData'),
|
|
description: 'Data must be saved to session before navigation'
|
|
}
|
|
];
|
|
|
|
console.log('🧪 Final Review Back Button Save Test\n');
|
|
console.log('Testing production build for data save functionality...\n');
|
|
|
|
let passed = 0;
|
|
let failed = 0;
|
|
|
|
tests.forEach((test, index) => {
|
|
const result = test.test();
|
|
const status = result ? '✅' : '❌';
|
|
|
|
if (result) {
|
|
passed++;
|
|
} else {
|
|
failed++;
|
|
}
|
|
|
|
console.log(`${status} Test ${index + 1}: ${test.name}`);
|
|
console.log(` ${test.description}\n`);
|
|
});
|
|
|
|
console.log('═══════════════════════════════════════════════════════════');
|
|
console.log(`RESULTS: ${passed} passed, ${failed} failed`);
|
|
console.log('═══════════════════════════════════════════════════════════\n');
|
|
|
|
if (failed === 0) {
|
|
console.log('✅ All back button save tests PASSED!\n');
|
|
console.log('📋 What This Means:');
|
|
console.log(' • FinalReview captures edited materials and tasks');
|
|
console.log(' • ProjectFlow has handler to save data on back');
|
|
console.log(' • onBackWithData callback is properly wired');
|
|
console.log(' • Session storage updated with latest edits');
|
|
console.log(' • Data persists when returning to Smart Pakke step\n');
|
|
|
|
console.log('🎯 Workflow:');
|
|
console.log(' 1. User goes to Final Review');
|
|
console.log(' 2. User edits prices/materials');
|
|
console.log(' 3. User clicks "← Tilbage til Smart Pakke"');
|
|
console.log(' 4. handleBackWithData captures edited data');
|
|
console.log(' 5. handleBackFromFinalReview saves to session');
|
|
console.log(' 6. Step changes to 3 (Smart Pakke)');
|
|
console.log(' 7. User sees their edits preserved ✅\n');
|
|
|
|
process.exit(0);
|
|
} else {
|
|
console.log('❌ Some tests failed!');
|
|
process.exit(1);
|
|
}
|