From 9b26378fdd5fd710d5d320d4043110b988791d3e Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Tue, 7 Apr 2020 23:06:29 +0000 Subject: [PATCH] All: Fixes #2709: When modifying a conflicted note, it would disappear from the view --- CliClient/tests/feature_NoteList.js | 52 +++++++++++++++++++++++++++++ ReactNativeClient/lib/reducer.js | 3 +- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 CliClient/tests/feature_NoteList.js diff --git a/CliClient/tests/feature_NoteList.js b/CliClient/tests/feature_NoteList.js new file mode 100644 index 0000000000..96fa9b627a --- /dev/null +++ b/CliClient/tests/feature_NoteList.js @@ -0,0 +1,52 @@ +/* eslint-disable no-unused-vars */ +require('app-module-path').addPath(__dirname); +const { setupDatabaseAndSynchronizer, switchClient, asyncTest, createNTestFolders, createNTestNotes, createNTestTags, TestApp } = require('test-utils.js'); +const Setting = require('lib/models/Setting.js'); +const Folder = require('lib/models/Folder.js'); +const Note = require('lib/models/Note.js'); +const Tag = require('lib/models/Tag.js'); +const { time } = require('lib/time-utils.js'); + +let testApp = null; + +describe('integration_NoteList', function() { + + beforeEach(async (done) => { + testApp = new TestApp(); + await testApp.start(['--no-welcome']); + done(); + }); + + afterEach(async (done) => { + if (testApp !== null) await testApp.destroy(); + testApp = null; + done(); + }); + + // Reference: https://github.com/laurent22/joplin/issues/2709 + it('should leave a conflict note in the conflict folder when it modified', asyncTest(async () => { + const folder = await Folder.save({ title: 'test' }); + const note = await Note.save({ title: 'note 1', parent_id: folder.id, is_conflict: 1 }); + await testApp.wait(); + + testApp.dispatch({ type: 'FOLDER_SELECT', id: Folder.conflictFolderId() }); + await testApp.wait(); + + testApp.dispatch({ type: 'NOTE_SELECT', id: note.id }); + await testApp.wait(); + + // Check that the conflict folder is selected and that the conflict note is inside + let state = testApp.store().getState(); + expect(state.selectedFolderId).toBe(Folder.conflictFolderId()); + expect(state.selectedNoteIds[0]).toBe(note.id); + + await Note.save({ id: note.id, title: 'note 1 mod', is_conflict: 1 }); + await testApp.wait(); + + // Check that the conflict folder is still selected with the note still inside + state = testApp.store().getState(); + expect(state.selectedFolderId).toBe(Folder.conflictFolderId()); + expect(state.selectedNoteIds[0]).toBe(note.id); + })); + +}); diff --git a/ReactNativeClient/lib/reducer.js b/ReactNativeClient/lib/reducer.js index 1fb7a0c548..9390f4c032 100644 --- a/ReactNativeClient/lib/reducer.js +++ b/ReactNativeClient/lib/reducer.js @@ -524,9 +524,10 @@ const reducer = (state = defaultState, action) => { { const modNote = action.note; const isViewingAllNotes = (state.notesParentType === 'SmartFilter' && state.selectedSmartFilterId === ALL_NOTES_FILTER_ID); + const isViewingConflictFolder = state.notesParentType === 'Folder' && state.selectedFolderId === Folder.conflictFolderId(); const noteIsInFolder = function(note, folderId) { - if (note.is_conflict) return folderId === Folder.conflictFolderId(); + if (note.is_conflict && isViewingConflictFolder) return true; if (!('parent_id' in modNote) || note.parent_id == folderId) return true; return false; };