1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00

Desktop: Fixes #10236: Fix note disappears while editing during search (#10568)

This commit is contained in:
Henry Heino 2024-06-12 07:11:53 -07:00 committed by GitHub
parent 73d3f92ae2
commit 7d0cc675aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 47 additions and 1 deletions

View File

@ -456,6 +456,7 @@ packages/app-desktop/integration-tests/models/MainScreen.js
packages/app-desktop/integration-tests/models/NoteEditorScreen.js
packages/app-desktop/integration-tests/models/SettingsScreen.js
packages/app-desktop/integration-tests/models/Sidebar.js
packages/app-desktop/integration-tests/noteList.spec.js
packages/app-desktop/integration-tests/richTextEditor.spec.js
packages/app-desktop/integration-tests/sidebar.spec.js
packages/app-desktop/integration-tests/simpleBackup.spec.js

1
.gitignore vendored
View File

@ -435,6 +435,7 @@ packages/app-desktop/integration-tests/models/MainScreen.js
packages/app-desktop/integration-tests/models/NoteEditorScreen.js
packages/app-desktop/integration-tests/models/SettingsScreen.js
packages/app-desktop/integration-tests/models/Sidebar.js
packages/app-desktop/integration-tests/noteList.spec.js
packages/app-desktop/integration-tests/richTextEditor.spec.js
packages/app-desktop/integration-tests/sidebar.spec.js
packages/app-desktop/integration-tests/simpleBackup.spec.js

View File

@ -48,4 +48,9 @@ export default class MainScreen {
throw new Error('Unable to find settings menu item in application menus.');
}
}
public async search(text: string) {
const searchBar = this.page.getByPlaceholder('Search...');
await searchBar.fill(text);
}
}

View File

@ -0,0 +1,38 @@
import { test, expect } from './util/test';
import MainScreen from './models/MainScreen';
test.describe('noteList', () => {
test('should be possible to edit notes in a different notebook when searching', async ({ mainWindow }) => {
const mainScreen = new MainScreen(mainWindow);
const sidebar = mainScreen.sidebar;
const folderAHeader = await sidebar.createNewFolder('Folder A');
await expect(folderAHeader).toBeVisible();
const folderBHeader = await sidebar.createNewFolder('Folder B');
await expect(folderBHeader).toBeVisible();
await folderBHeader.click();
await mainScreen.createNewNote('note-1');
await folderAHeader.click();
await mainScreen.createNewNote('note-2');
// Search for and focus a note different from the folder we were in before searching.
await mainScreen.search('/note-1');
const note1Result = mainScreen.noteListContainer.getByText('note-1');
await expect(note1Result).toBeAttached();
await note1Result.click();
// Typing should not cause the note to disappear
const editor = mainScreen.noteEditor;
await editor.codeMirrorEditor.click();
await mainWindow.keyboard.type('[Testing...](http://example.com/)');
// Wait to render
await expect(editor.getNoteViewerIframe().locator('a', { hasText: 'Testing...' })).toBeVisible();
// Updating the title should force the sidebar to update sooner
await expect(editor.noteTitleInput).toHaveValue('note-1');
});
});

View File

@ -963,13 +963,14 @@ const reducer = produce((draft: Draft<State> = defaultState, action: any) => {
for (let i = 0; i < newNotes.length; i++) {
const n = newNotes[i];
if (n.id === modNote.id) {
const previousDisplayParentId = ('parent_id' in n) ? getDisplayParentId(n, draft.folders.find(f => f.id === n.parent_id)) : '';
if (n.is_conflict && !modNote.is_conflict) {
// Note was a conflict but was moved outside of
// the conflict folder
newNotes.splice(i, 1);
noteFolderHasChanged = true;
movedNotePreviousIndex = i;
} else if (isViewingAllNotes || noteIsInFolder(modNote, draft.selectedFolderId)) {
} else if (isViewingAllNotes || noteIsInFolder(modNote, previousDisplayParentId)) {
// Note is still in the same folder
// Merge the properties that have changed (in modNote) into
// the object we already have.