1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-16 00:14:34 +02:00

Desktop: Fixes #5086: Prevent app from crashing when loading a setting value that has been removed

This commit is contained in:
Laurent Cozic
2021-06-16 18:22:32 +01:00
parent 8c56cf98be
commit 313c8bbe8c
2 changed files with 20 additions and 2 deletions

View File

@ -30,6 +30,24 @@ describe('models_Setting', function() {
expect('username' in output).toBe(false);
}));
it('should not fail when trying to load a key that no longer exist from the setting file', (async () => {
// To handle the case where a setting value exists in the database but
// the metadata has been removed in a new Joplin version.
// https://github.com/laurent22/joplin/issues/5086
Setting.setValue('sync.target', 9); // Saved to file
await Setting.saveAll();
const settingValues = await Setting.fileHandler.load();
settingValues['itsgone'] = 'myvalue';
await Setting.fileHandler.save(settingValues);
await Setting.reset();
await expectNotThrow(async () => Setting.load());
await expectThrow(async () => Setting.value('itsgone'));
}));
it('should allow registering new settings dynamically', (async () => {
await expectThrow(async () => Setting.setValue('myCustom', '123'));