Revert "Tests: Fix random failures (#2777)"

This reverts commit d1cab4b7f5.
Part of this revert: d2582f4fdf

For rationale see https://github.com/laurent22/joplin/pull/2819#issuecomment-616148984
pull/3148/head^2
Laurent Cozic 2020-05-02 16:45:14 +01:00
parent cb8dca747b
commit ec8ccc94aa
2 changed files with 12 additions and 143 deletions

View File

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

View File

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