mirror of
https://github.com/laurent22/joplin.git
synced 2025-02-01 19:15:01 +02:00
All: Fixed: Prevents notes with no title to break after synchronize (#1472)
Tests to confirm serialize/unserialize don't change body and title check if item title exists, otherwise display default title. added test checking serializing/unserializing Folders don't modify data
This commit is contained in:
parent
782aae4ddf
commit
d213e4ab57
@ -47,5 +47,20 @@ describe('models_BaseItem', function() {
|
||||
|
||||
expect('ignore_me' in unserialized).toBe(false);
|
||||
}));
|
||||
|
||||
it('should not modify title when unserializing', asyncTest(async () => {
|
||||
let folder1 = await Folder.save({ title: "" });
|
||||
let folder2 = await Folder.save({ title: "folder1" });
|
||||
|
||||
let serialized1 = await Folder.serialize(folder1);
|
||||
let unserialized1 = await Folder.unserialize(serialized1);
|
||||
|
||||
expect(unserialized1.title).toBe(folder1.title);
|
||||
|
||||
let serialized2 = await Folder.serialize(folder2);
|
||||
let unserialized2 = await Folder.unserialize(serialized2);
|
||||
|
||||
expect(unserialized2.title).toBe(folder2.title);
|
||||
}));
|
||||
|
||||
});
|
@ -86,5 +86,32 @@ describe('models_Note', function() {
|
||||
expect(changedNote === note1).toBe(false);
|
||||
expect(!!changedNote.is_todo).toBe(false);
|
||||
}));
|
||||
|
||||
it('should serialize and unserialize without modifying data', asyncTest(async () => {
|
||||
let folder1 = await Folder.save({ title: "folder1"});
|
||||
const testCases = [
|
||||
[ {title: '', body:'Body and no title\nSecond line\nThird Line', parent_id: folder1.id},
|
||||
'', 'Body and no title\nSecond line\nThird Line'],
|
||||
[ {title: 'Note title', body:'Body and title', parent_id: folder1.id},
|
||||
'Note title', 'Body and title'],
|
||||
[ {title: 'Title and no body', body:'', parent_id: folder1.id},
|
||||
'Title and no body', ''],
|
||||
]
|
||||
|
||||
for (let i = 0; i < testCases.length; i++) {
|
||||
const t = testCases[i];
|
||||
|
||||
const input = t[0];
|
||||
const expectedTitle = t[1];
|
||||
const expectedBody = t[1];
|
||||
|
||||
let note1 = await Note.save(input);
|
||||
let serialized = await Note.serialize(note1);
|
||||
let unserialized = await Note.unserialize( serialized);
|
||||
|
||||
expect(unserialized.title).toBe(input.title);
|
||||
expect(unserialized.body).toBe(input.body);
|
||||
}
|
||||
}));
|
||||
|
||||
});
|
@ -279,7 +279,7 @@ class BaseItem extends BaseModel {
|
||||
|
||||
let temp = [];
|
||||
|
||||
if (output.title) temp.push(output.title);
|
||||
if (typeof output.title === "string") temp.push(output.title);
|
||||
if (output.body) temp.push(output.body);
|
||||
if (output.props.length) temp.push(output.props.join("\n"));
|
||||
|
||||
@ -644,7 +644,7 @@ class BaseItem extends BaseModel {
|
||||
|
||||
static displayTitle(item) {
|
||||
if (!item) return '';
|
||||
return !!item.encryption_applied ? '🔑 ' + _('Encrypted') : item.title + '';
|
||||
return !!item.encryption_applied ? '🔑 ' + _('Encrypted') : (!!item.title)? item.title + '' : Note.defaultTitle(item);
|
||||
}
|
||||
|
||||
static async markAllNonEncryptedForSync() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user