Conversation
WalkthroughAdds disk-based synchronization for template text_parts: a new fsUtils scanner maps on-disk text parts, templates refresh their in-memory configs from disk during reads/creates, changed configs are persisted back to disk, and tests cover moved, nested, missing, and unlisted text parts. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
tests/lib/templates/reconciliationTexts.test.js (1)
635-654: Test relies on exception handling for incomplete verification.The test correctly verifies that the config entry remains unchanged when a file is missing from disk. However, the test catches and ignores the exception from
ReconciliationText.read(handle)without verifying it was thrown for the expected reason.Consider adding an assertion to verify the exception was thrown:
💡 Suggested improvement
// read() will fail at readPartsLiquid, but the config should not have been altered + let errorThrown = false; try { ReconciliationText.read(handle); } catch (e) { // Expected to fail when reading the missing file + errorThrown = true; + expect(e.code).toBe('ENOENT'); } + expect(errorThrown).toBe(true); const configAfter = JSON.parse(fs.readFileSync(configPath, "utf-8")); expect(configAfter.text_parts.part_1).toBe("text_parts/part_1.liquid");lib/templates/accountTemplate.js (1)
211-236: Consider extracting duplicated methods to a shared utility.The
#updateConfigIfChangedand#syncTextPartsFromDiskmethods are nearly identical to those inReconciliationText. This duplication increases maintenance burden.Since both classes already use
fsUtils, consider moving these helper functions there:// In fsUtils.js function syncTextPartsInConfig(templateType, handle, templateConfig) { ... } function updateConfigIfChanged(templateType, handle, originalConfig, currentConfig) { ... }This would allow both
ReconciliationTextandAccountTemplateto share the same implementation.
54bf138 to
4f4d617
Compare
4f4d617 to
5726497
Compare
Fixes # #240
Description
This feature allows you to create a folder structure within the text_parts of a reconciliation and account template. First it builds a map of the actual folder structure. Then based on the map, the text parts in the config are updated to to reflect the correct path. If a file was not mentioned in the config file, it will not be suddenly be included.
Testing Instructions
Steps:
Keep into account that you may have to disable the extension for testing. Because it seems that when you move files around in subfolders, the Extension automatically removes them from the config when you save. In order for it to work properly, we may need to update the Extension as well still.
Author Checklist
Reviewer Checklist