diff --git a/CliClient/tests/feature_ForwardBackwardNoteHistory.js b/CliClient/tests/feature_ForwardBackwardNoteHistory.js deleted file mode 100644 index 331dcd25f13..00000000000 --- a/CliClient/tests/feature_ForwardBackwardNoteHistory.js +++ /dev/null @@ -1,129 +0,0 @@ -require('app-module-path').addPath(__dirname); -const { asyncTest, id, ids, createNTestFolders, createNTestNotes, TestApp } = require('test-utils.js'); - -let testApp = null; - -const goBackWard = (state) => { - const lastItem = state.backwardHistoryNotes[state.backwardHistoryNotes.length - 1]; - testApp.dispatch({ type: 'FOLDER_AND_NOTE_SELECT', noteId: lastItem.id, folderId: lastItem.parent_id, historyAction: 'pop' }); -}; - -const goForward = (state) => { - const lastItem = state.forwardHistoryNotes[state.forwardHistoryNotes.length - 1]; - testApp.dispatch({ type: 'FOLDER_AND_NOTE_SELECT', noteId: lastItem.id, folderId: lastItem.parent_id, historyAction: 'push' }); -}; - -describe('integration_ForwardBackwardNoteHistory', 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(); - }); - - it('should save history when navigating through notes', asyncTest(async () => { - // setup - const folders = await createNTestFolders(2); - await testApp.wait(); - const notes0 = await createNTestNotes(5, folders[0]); - await testApp.wait(); - - testApp.dispatch({ type: 'FOLDER_SELECT', id: id(folders[0]) }); - await testApp.wait(); - - let state = testApp.store().getState(); - expect(state.backwardHistoryNotes).toEqual([]); - expect(state.forwardHistoryNotes).toEqual([]); - - testApp.dispatch({ type: 'NOTE_SELECT', id: notes0[3].id, historyAction: 'goto' }); - await testApp.wait(); - testApp.dispatch({ type: 'NOTE_SELECT', id: notes0[2].id, historyAction: 'goto' }); - await testApp.wait(); - testApp.dispatch({ type: 'NOTE_SELECT', id: notes0[1].id, historyAction: 'goto' }); - await testApp.wait(); - testApp.dispatch({ type: 'NOTE_SELECT', id: notes0[0].id, historyAction: 'goto' }); - await testApp.wait(); - - state = testApp.store().getState(); - expect(ids(state.backwardHistoryNotes)).toEqual(ids([notes0[4], notes0[3], notes0[2], notes0[1]])); - expect(ids(state.forwardHistoryNotes)).toEqual([]); - - goBackWard(state); - await testApp.wait(); - - state = testApp.store().getState(); - expect(ids(state.backwardHistoryNotes)).toEqual(ids([notes0[4], notes0[3], notes0[2]])); - expect(ids(state.forwardHistoryNotes)).toEqual(ids([notes0[0]])); - - goBackWard(state); - await testApp.wait(); - - state = testApp.store().getState(); - expect(ids(state.backwardHistoryNotes)).toEqual(ids([notes0[4], notes0[3]])); - expect(ids(state.forwardHistoryNotes)).toEqual(ids([notes0[0], notes0[1]])); - - goForward(state); - await testApp.wait(); - - state = testApp.store().getState(); - expect(ids(state.backwardHistoryNotes)).toEqual(ids([notes0[4], notes0[3], notes0[2]])); - expect(ids(state.forwardHistoryNotes)).toEqual(ids([notes0[0]])); - - testApp.dispatch({ type: 'NOTE_SELECT', id: notes0[4].id, historyAction: 'goto' }); - await testApp.wait(); - - state = testApp.store().getState(); - expect(ids(state.backwardHistoryNotes)).toEqual(ids([notes0[4], notes0[3], notes0[2], notes0[1]])); - expect(ids(state.forwardHistoryNotes)).toEqual([]); - })); - - it('should save history when navigating through notebooks', asyncTest(async () => { - const folders = await createNTestFolders(2); - await testApp.wait(); - const notes0 = await createNTestNotes(5, folders[0]); - const notes1 = await createNTestNotes(5, folders[1]); - await testApp.wait(); - - testApp.dispatch({ type: 'FOLDER_SELECT', id: id(folders[0]) }); - await testApp.wait(); - - let state = testApp.store().getState(); - expect(state.backwardHistoryNotes).toEqual([]); - expect(state.forwardHistoryNotes).toEqual([]); - - testApp.dispatch({ type: 'FOLDER_SELECT', id: id(folders[1]), historyAction: 'goto' }); - await testApp.wait(); - - state = testApp.store().getState(); - expect(ids(state.backwardHistoryNotes)).toEqual(ids([notes0[4]])); // notes0[4] was last created - expect(ids(state.forwardHistoryNotes)).toEqual([]); - - testApp.dispatch({ type: 'FOLDER_SELECT', id: id(folders[0]), historyAction: 'goto' }); - await testApp.wait(); - - state = testApp.store().getState(); - expect(ids(state.backwardHistoryNotes)).toEqual(ids([notes0[4], notes1[4]])); - expect(state.forwardHistoryNotes).toEqual([]); - - goBackWard(state); - await testApp.wait(); - - state = testApp.store().getState(); - expect(ids(state.backwardHistoryNotes)).toEqual(ids([notes0[4]])); - expect(ids(state.forwardHistoryNotes)).toEqual(ids([notes0[4]])); - - goForward(state); - await testApp.wait(); - - state = testApp.store().getState(); - expect(ids(state.backwardHistoryNotes)).toEqual(ids([notes0[4], notes1[4]])); - expect(state.forwardHistoryNotes).toEqual([]); - })); - -}); diff --git a/CliClient/tests/feature_ShowAllNotes.js b/CliClient/tests/feature_ShowAllNotes.js index 986ae11cfc0..fe447f1a3a6 100644 --- a/CliClient/tests/feature_ShowAllNotes.js +++ b/CliClient/tests/feature_ShowAllNotes.js @@ -95,13 +95,12 @@ describe('integration_ShowAllNotes', function() { const folder2 = await Folder.save({ title: 'folder2' }); const note1 = await Note.save({ title: 'note1', parent_id: folder1.id }); const note2 = await Note.save({ title: 'note2', parent_id: folder2.id }); - await testApp.wait(); testApp.dispatch({ type: 'FOLDER_SELECT', id: folder1.id }); // active folder - await testApp.wait(); + await time.msleep(100); testApp.dispatch({ type: 'NOTE_SELECT', id: note1.id }); - await testApp.wait(); + await time.msleep(100); testApp.dispatch({ type: 'SMART_FILTER_SELECT', id: ALL_NOTES_FILTER_ID }); - await testApp.wait(); + await time.msleep(100); // check the state is set up as expected let state = testApp.store().getState(); @@ -110,7 +109,7 @@ describe('integration_ShowAllNotes', function() { // TEST ACTION: duplicate a note from the active folder const newNote1 = await Note.duplicate(note1.id); - await testApp.wait(); + await time.msleep(100); // check the note is duplicated and the view updated state = testApp.store().getState(); @@ -119,7 +118,7 @@ describe('integration_ShowAllNotes', function() { // TEST ACTION: duplicate a note from a non-active folder const newNote2 = await Note.duplicate(note2.id); - await testApp.wait(); + await time.msleep(100); // check the note is duplicated and the view updated state = testApp.store().getState(); @@ -133,13 +132,12 @@ describe('integration_ShowAllNotes', function() { const folder2 = await Folder.save({ title: 'folder2' }); const note1 = await Note.save({ title: 'note1', parent_id: folder1.id }); const note2 = await Note.save({ title: 'note1', parent_id: folder2.id }); - await testApp.wait(); testApp.dispatch({ type: 'FOLDER_SELECT', id: folder1.id }); // active folder - await testApp.wait(); + await time.msleep(100); testApp.dispatch({ type: 'NOTE_SELECT', id: note1.id }); - await testApp.wait(); + await time.msleep(100); testApp.dispatch({ type: 'SMART_FILTER_SELECT', id: ALL_NOTES_FILTER_ID }); - await testApp.wait(); + await time.msleep(100); // check the state is set up as expected let state = testApp.store().getState(); @@ -149,9 +147,9 @@ describe('integration_ShowAllNotes', function() { // TEST ACTION: change the notes parent await Note.moveToFolder(note1.id, folder2.id); - await testApp.wait(); + await time.msleep(100); - // check the note is updated and remains in view + // check the note is duplicated and the view updated state = testApp.store().getState(); expect(state.notes.length).toEqual(2); let n1 = await Note.load(note1.id); @@ -159,9 +157,9 @@ describe('integration_ShowAllNotes', function() { // TEST ACTION: change the notes parent await Note.moveToFolder(note1.id, folder1.id); - await testApp.wait(); + await time.msleep(100); - // check the note is updated and remains in view + // check the note is duplicated and the view updated state = testApp.store().getState(); expect(state.notes.length).toEqual(2); n1 = await Note.load(note1.id);