-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
All: Conflict notes will now populate a new field conflict_parent with the id of the conflict note. #5049
All: Conflict notes will now populate a new field conflict_parent with the id of the conflict note. #5049
Changes from 11 commits
861f69a
763a822
a597284
8b3a1d9
3c9097e
3819ddc
b293b80
07158ff
322f11c
555a4b7
7599fb2
85ba6c5
21811c8
1b8fdca
c162d50
06ab8ed
3b99bab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -332,4 +332,57 @@ describe('models_Note', function() { | |
expect(sortedNotes3[4].id).toBe(note2.id); | ||
})); | ||
|
||
it('should copy conflicted note to target folder and cancel conflict', (async () => { | ||
// Prepare | ||
const srcfolder = await Folder.save({ title: 'Source Folder' }); | ||
const targetfolder = await Folder.save({ title: 'Target Folder' }); | ||
|
||
const note1 = await Note.save({ title: 'note', parent_id: srcfolder.id }); | ||
|
||
const tmpConflictedNote = Object.assign({}, note1); | ||
delete tmpConflictedNote.id; | ||
tmpConflictedNote.is_conflict = 1; | ||
tmpConflictedNote.conflict_original_id = note1.id; | ||
const conflictedNote = await Note.save(tmpConflictedNote, { autoTimestamp: false }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't copy and paste large blocks of code in this codebase, it's just a mess to maintain otherwise. So please do this:
As a general rule if you see you are copying more than two or three lines of code, you should stop and think if the code can be refactored. Such refactoring improves the code quality because it wraps and names (using the function name) business logic and makes it re-usable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be good now. |
||
|
||
// COPY File | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your comment explains nothing and is even confusing since we aren't moving files but notes, so please remove it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noted. Also no idea myself where did "File" come from 😂 sorry about that |
||
const note2 = await Note.copyToFolder(conflictedNote.id, targetfolder.id); | ||
|
||
// Targed should be copied and have conflict removed. | ||
expect(note2.id === conflictedNote.id).toBe(false); // ID must be different. | ||
expect(note2.title).toBe(conflictedNote.title); | ||
expect(note2.is_conflict).toBe(0); | ||
expect(note2.conflict_original_id).toBe(''); | ||
expect(note2.parent_id).toBe(targetfolder.id); | ||
|
||
// Source conflict should stay as is | ||
expect(conflictedNote.is_conflict).toBe(1); | ||
expect(conflictedNote.conflict_original_id).toBe(note1.id); | ||
expect(conflictedNote.parent_id).toBe(srcfolder.id); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you want to test the output of createConflictNote, it should be in a separate test, so please remove this part. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll move it to a separate test. |
||
})); | ||
|
||
it('should move conflicted note to target folder and cancel conflict', (async () => { | ||
// Prepare | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove |
||
const srcFolder = await Folder.save({ title: 'Source Folder' }); | ||
const targetFolder = await Folder.save({ title: 'Target Folder' }); | ||
const note1 = await Note.save({ title: 'note', parent_id: srcFolder.id }); | ||
|
||
const tmpConflictedNote = Object.assign({}, note1); | ||
delete tmpConflictedNote.id; | ||
tmpConflictedNote.is_conflict = 1; | ||
tmpConflictedNote.conflict_original_id = note1.id; | ||
const conflictedNote = await Note.save(tmpConflictedNote, { autoTimestamp: false }); | ||
|
||
// Move | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In your comments you should explain why, not what. We know that a function called "Note.moveToFolder" is going to move the note to a folder, and a comment for this is just noise. I don't think you need to explain anything here, so please remove the comment. |
||
const movedNote = await Note.moveToFolder(conflictedNote.id, targetFolder.id); | ||
|
||
// Note should be moved over. | ||
expect(movedNote.parent_id).toBe(targetFolder.id); | ||
|
||
// Note should have conflicts removed. | ||
expect(movedNote.is_conflict).toBe(0); | ||
expect(movedNote.conflict_original_id).toBe(''); | ||
|
||
})); | ||
|
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove