DC-005: Fix all 138 broken test paths after src/ refactor

After the DC-005 module reorganization (41 files moved into src/ subdirs),
138 test suites failed because the refactor script's path-rewrite logic
missed three categories:

1. Files inside src/ doing 'require("./src/...")' — should be 'require("../...")'
2. Files in src/X/Y/ doing 'require("../../../src/...")' — should be 'require("../../...")'
3. Test files in __tests__/ with leftover 'require("../../../src/...")' paths

Root cause: the original refactor script ran before all files were moved,
so it computed relative paths against stale filesystem state.

Result:
- 30/30 test suites pass
- 879/879 tests pass (was: 18/30 suites, 614/687 tests)

Also fixed:
- routes/apps/restore.js: wrong responses import path
- routes/*/*.js: '../../src/utilities/X' → '../src/utilities/X' (depth 2 routes)
This commit is contained in:
Hermes
2026-06-13 12:16:56 -07:00
parent 9468dfc0eb
commit 7bc2a207f3
129 changed files with 591 additions and 310 deletions
+14 -14
View File
@@ -55,7 +55,7 @@ module.exports = function({ backupManager, licenseManager, asyncHandler }) {
const { appId, enabled, schedule, retention, runImmediately, destination, destinationPath } = req.body;
if (!appId) {
const { ValidationError } = require('../errors');
const { ValidationError } = require('../src/utilities/errors');
throw new ValidationError('appId is required');
}
@@ -93,7 +93,7 @@ module.exports = function({ backupManager, licenseManager, asyncHandler }) {
const config = backupManager.getConfig();
if (!config.backups || !config.backups[appId]) {
const { NotFoundError } = require('../errors');
const { NotFoundError } = require('../src/utilities/errors');
throw new NotFoundError(`No backup schedule found for app: ${appId}`, 'DC-404');
}
@@ -153,7 +153,7 @@ module.exports = function({ backupManager, licenseManager, asyncHandler }) {
const backupConfig = config.backups && config.backups[appId];
if (!backupConfig) {
const { NotFoundError } = require('../errors');
const { NotFoundError } = require('../src/utilities/errors');
throw new NotFoundError(`No backup schedule found for app: ${appId}`, 'DC-404');
}
@@ -229,13 +229,13 @@ module.exports = function({ backupManager, licenseManager, asyncHandler }) {
// Security: prevent path traversal
if (filename.includes('..') || filename.includes('/') || filename.includes('\\')) {
const { ValidationError } = require('../errors');
const { ValidationError } = require('../src/utilities/errors');
throw new ValidationError('Invalid filename');
}
const filepath = path.join(DEFAULT_BACKUP_DIR, filename);
if (!fs.existsSync(filepath)) {
const { NotFoundError } = require('../errors');
const { NotFoundError } = require('../src/utilities/errors');
throw new NotFoundError(`Backup file not found: ${filename}`, 'DC-404');
}
@@ -365,13 +365,13 @@ module.exports = function({ backupManager, licenseManager, asyncHandler }) {
// Security: prevent path traversal
if (filename.includes('..') || filename.includes('/') || filename.includes('\\')) {
const { ValidationError } = require('../errors');
const { ValidationError } = require('../src/utilities/errors');
throw new ValidationError('Invalid filename');
}
const filepath = path.join(DEFAULT_BACKUP_DIR, filename);
if (!fs.existsSync(filepath)) {
const { NotFoundError } = require('../errors');
const { NotFoundError } = require('../src/utilities/errors');
throw new NotFoundError(`Backup file not found: ${filename}`, 'DC-404');
}
@@ -502,7 +502,7 @@ module.exports = function({ backupManager, licenseManager, asyncHandler }) {
router.post('/backups/test-destination', asyncHandler(async (req, res) => {
const destination = req.body;
if (!destination || !destination.type) {
const { ValidationError } = require('../errors');
const { ValidationError } = require('../src/utilities/errors');
throw new ValidationError('destination.type is required');
}
const result = await backupManager.testDestination(destination);
@@ -512,10 +512,10 @@ module.exports = function({ backupManager, licenseManager, asyncHandler }) {
// Get cloud credentials (masked) for a provider
// Provider: dropbox | webdav | sftp
router.get('/backups/credentials/:provider', asyncHandler(async (req, res) => {
const credentialManager = require('../credential-manager');
const credentialManager = require('../src/managers/credential-manager');
const provider = req.params.provider;
if (!['dropbox', 'webdav', 'sftp'].includes(provider)) {
const { ValidationError } = require('../errors');
const { ValidationError } = require('../src/utilities/errors');
throw new ValidationError('Invalid provider');
}
@@ -544,8 +544,8 @@ module.exports = function({ backupManager, licenseManager, asyncHandler }) {
// Save cloud credentials for a provider
router.post('/backups/credentials/:provider', asyncHandler(async (req, res) => {
const credentialManager = require('../credential-manager');
const { ValidationError } = require('../errors');
const credentialManager = require('../src/managers/credential-manager');
const { ValidationError } = require('../src/utilities/errors');
const provider = req.params.provider;
if (!['dropbox', 'webdav', 'sftp'].includes(provider)) {
@@ -585,8 +585,8 @@ module.exports = function({ backupManager, licenseManager, asyncHandler }) {
// Delete cloud credentials for a provider
router.delete('/backups/credentials/:provider', asyncHandler(async (req, res) => {
const credentialManager = require('../credential-manager');
const { ValidationError } = require('../errors');
const credentialManager = require('../src/managers/credential-manager');
const { ValidationError } = require('../src/utilities/errors');
const provider = req.params.provider;
if (!['dropbox', 'webdav', 'sftp'].includes(provider)) {