- Add double-click handler to make file names editable in UI - Remove duplicate IPC handler for rename-file in renderer.js - Fix checkEpisodeCountMatch to properly validate sequential episodes - Fix begin-mapping to handle both season folder and show folder cases - Improve open-file-in-player handler to properly log results
131 lines
4.2 KiB
JavaScript
131 lines
4.2 KiB
JavaScript
// Test file movement feature including behind-the-scenes folder
|
|
const { test } = require('node:test');
|
|
const assert = require('node:assert');
|
|
const fs = require('fs');
|
|
|
|
test('File movement validates behind-the-scenes folder', () => {
|
|
const mainJsContent = fs.readFileSync('./main.js', 'utf8');
|
|
|
|
// Verify behind-the-scenes is in valid folders list
|
|
assert.ok(
|
|
mainJsContent.includes("'behind-the-scenes'") ||
|
|
mainJsContent.includes('"behind-the-scenes"'),
|
|
'behind-the-scenes should be a valid folder name'
|
|
);
|
|
|
|
console.log('✅ File movement validates behind-the-scenes folder');
|
|
});
|
|
|
|
test('File movement maps behind-the-scenes to correct directory', () => {
|
|
const mainJsContent = fs.readFileSync('./main.js', 'utf8');
|
|
|
|
// Verify the mapping from behind-the-scenes to "behind the scenes"
|
|
assert.ok(
|
|
mainJsContent.includes("actualFolderName = 'behind the scenes'") ||
|
|
mainJsContent.includes('actualFolderName = "behind the scenes"'),
|
|
'Should map behind-the-scenes to "behind the scenes"'
|
|
);
|
|
|
|
// Verify the if statement checks for behind-the-scenes
|
|
assert.ok(
|
|
mainJsContent.includes("folderName === 'behind-the-scenes'") ||
|
|
mainJsContent.includes('folderName === "behind-the-scenes"'),
|
|
'Should have if condition for behind-the-scenes'
|
|
);
|
|
|
|
console.log('✅ File movement maps behind-the-scenes correctly');
|
|
});
|
|
|
|
test('File movement error message includes behind-the-scenes', () => {
|
|
const mainJsContent = fs.readFileSync('./main.js', 'utf8');
|
|
|
|
// Verify the error message includes behind-the-scenes
|
|
assert.ok(
|
|
mainJsContent.includes('behind-the-scenes'),
|
|
'Error message should include behind-the-scenes as valid option'
|
|
);
|
|
|
|
console.log('✅ File movement error message includes behind-the-scenes');
|
|
});
|
|
|
|
test('File movement handles all tag types', () => {
|
|
const mainJsContent = fs.readFileSync('./main.js', 'utf8');
|
|
|
|
// Verify all tag types are handled
|
|
assert.ok(
|
|
mainJsContent.includes("'extra'") &&
|
|
mainJsContent.includes("'behind-the-scenes'") &&
|
|
mainJsContent.includes("'commentary'") &&
|
|
mainJsContent.includes("'delete'"),
|
|
'Should handle all tag types'
|
|
);
|
|
|
|
// Verify extras mapping for extra
|
|
assert.ok(
|
|
mainJsContent.includes("actualFolderName = 'extras'"),
|
|
'Should map extra to extras'
|
|
);
|
|
|
|
// Verify delete stays as delete
|
|
assert.ok(
|
|
mainJsContent.includes("'delete'") &&
|
|
!mainJsContent.match(/folderName === 'delete'.*actualFolderName/),
|
|
'Should handle delete (no special mapping needed)'
|
|
);
|
|
|
|
console.log('✅ File movement handles all tag types');
|
|
});
|
|
|
|
test('Play button has click handler', () => {
|
|
const uiManagerContent = fs.readFileSync('./utils/renderer/UIManager.js', 'utf8');
|
|
|
|
// Verify the play button click handler is set up
|
|
assert.ok(
|
|
uiManagerContent.includes("play-button") &&
|
|
uiManagerContent.includes('handlePlayButtonClick'),
|
|
'Should have click handler for play button'
|
|
);
|
|
|
|
console.log('✅ Play button has click handler');
|
|
});
|
|
|
|
test('handlePlayButtonClick determines tag type', () => {
|
|
const uiManagerContent = fs.readFileSync('./utils/renderer/UIManager.js', 'utf8');
|
|
|
|
// Verify it checks for all tag types
|
|
assert.ok(
|
|
uiManagerContent.includes('data-tagged-extra') &&
|
|
uiManagerContent.includes('data-tagged-behind-the-scenes') &&
|
|
uiManagerContent.includes('data-tagged-delete'),
|
|
'Should check for all tag types'
|
|
);
|
|
|
|
// Verify it calls moveTaggedFile
|
|
assert.ok(
|
|
uiManagerContent.includes('moveTaggedFile'),
|
|
'Should call moveTaggedFile'
|
|
);
|
|
|
|
console.log('✅ handlePlayButtonClick determines tag type correctly');
|
|
});
|
|
|
|
test('handlePlayButtonClick removes file after move', () => {
|
|
const uiManagerContent = fs.readFileSync('./utils/renderer/UIManager.js', 'utf8');
|
|
|
|
// Verify it removes the item after successful move
|
|
assert.ok(
|
|
uiManagerContent.includes('fileItem.remove()') ||
|
|
uiManagerContent.includes('item.remove()'),
|
|
'Should remove file item after move'
|
|
);
|
|
|
|
// Verify it updates tagged count
|
|
assert.ok(
|
|
uiManagerContent.includes('updateTaggedCount'),
|
|
'Should update tagged count after move'
|
|
);
|
|
|
|
console.log('✅ handlePlayButtonClick removes file after move');
|
|
});
|
|
|
|
console.log('\n✅ All file movement tests passed!'); |