1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-27 08:21:03 +02:00

All: Fixes #2709: When modifying a conflicted note, it would disappear from the view

This commit is contained in:
Laurent Cozic 2020-04-07 23:06:29 +00:00
parent 6b8e84332d
commit 9b26378fdd
2 changed files with 54 additions and 1 deletions

View File

@ -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);
}));
});

View File

@ -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;
};