Fix settings button on library view
Template tests / tests (push) Failing after 46s

This commit is contained in:
Iisyourdad
2026-06-11 10:47:32 -05:00
parent a5d0013c3a
commit 572b66650b
3 changed files with 39 additions and 2 deletions
+30
View File
@@ -3,12 +3,16 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const {
systemPlaceholders, resolveScopes, expandPlaceholders,
listPlaceholders, collectGuidePlaceholders,
} = require('../../core/placeholders');
const { createGuide, createStep } = require('../../core/schema');
const { Settings, DEFAULT_SETTINGS } = require('../../core/settings');
const { writeJsonSync } = require('../../core/util');
const { makeTmpDir, rmrf } = require('./helpers');
test('placeholder expansion respects guide > global > system precedence', () => {
@@ -61,3 +65,29 @@ test('settings persist, deep-merge with defaults, and store global placeholders'
assert.equal(s2.get('capture.clickMarker'), DEFAULT_SETTINGS.capture.clickMarker);
assert.deepEqual(s2.getGlobalPlaceholders(), { Company: 'Acme', Author: 'Tyler' });
});
test('a corrupted placeholders/settings file falls back instead of crashing the settings dialog', (t) => {
const dir = makeTmpDir('settings-corrupt');
t.after(() => rmrf(dir));
// Simulate a file left over from a past bug: literal "undefined" instead of JSON.
fs.writeFileSync(path.join(dir, 'placeholders.json'), 'undefined\n');
fs.writeFileSync(path.join(dir, 'app-settings.json'), 'undefined\n');
const s = new Settings(dir);
assert.deepEqual(s.getGlobalPlaceholders(), {});
assert.equal(s.get('appearance'), DEFAULT_SETTINGS.appearance);
// Saving afterwards overwrites the corrupted file with valid JSON.
s.setGlobalPlaceholders({ Author: 'Tyler' });
assert.deepEqual(s.getGlobalPlaceholders(), { Author: 'Tyler' });
});
test('writeJsonSync refuses to write a non-JSON value instead of writing the literal string "undefined"', () => {
const dir = makeTmpDir('write-json-guard');
try {
assert.throws(() => writeJsonSync(path.join(dir, 'bad.json'), undefined), TypeError);
} finally {
rmrf(dir);
}
});