diff --git a/packages/app-desktop/app.ts b/packages/app-desktop/app.ts index 265f110edf2..6a91b112669 100644 --- a/packages/app-desktop/app.ts +++ b/packages/app-desktop/app.ts @@ -713,6 +713,9 @@ class Application extends BaseApplication { SearchEngine.instance().scheduleSyncTables(); }); + // Used by tests + ipcRenderer.send('startup-finished'); + // setTimeout(() => { // void populateDatabase(reg.db(), { // clearDatabase: true, diff --git a/packages/app-desktop/integration-tests/goToAnything.spec.ts b/packages/app-desktop/integration-tests/goToAnything.spec.ts index c8d4210953c..129594df771 100644 --- a/packages/app-desktop/integration-tests/goToAnything.spec.ts +++ b/packages/app-desktop/integration-tests/goToAnything.spec.ts @@ -5,7 +5,8 @@ import { Locator } from '@playwright/test'; test.describe('goToAnything', () => { test('clicking outside of go to anything should close it', async ({ electronApp, mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); + await mainScreen.createNewNote('Test'); await mainScreen.noteEditor.waitFor(); const goToAnything = mainScreen.goToAnything; await goToAnything.open(electronApp); @@ -19,7 +20,7 @@ test.describe('goToAnything', () => { }); test('pressing escape in go to anything should close it ', async ({ electronApp, mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); const goToAnything = mainScreen.goToAnything; // Pressing Escape to close the dialog should work even if opened multiple times in a row. @@ -33,7 +34,7 @@ test.describe('goToAnything', () => { }); test('closing go to anything should restore the original keyboard focus', async ({ electronApp, mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); await mainScreen.createNewNote(''); const initialFocusLocators: [Locator, boolean][] = [ @@ -65,7 +66,7 @@ test.describe('goToAnything', () => { }); test('should be possible to show the set tags dialog from goToAnything', async ({ electronApp, mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); await mainScreen.createNewNote('Test note'); const goToAnything = mainScreen.goToAnything; diff --git a/packages/app-desktop/integration-tests/main.spec.ts b/packages/app-desktop/integration-tests/main.spec.ts index 4b6f1690b94..02fbc9730f9 100644 --- a/packages/app-desktop/integration-tests/main.spec.ts +++ b/packages/app-desktop/integration-tests/main.spec.ts @@ -15,12 +15,12 @@ test.describe('main', () => { // A window should open with the correct title expect(await mainWindow.title()).toMatch(/^Joplin/); - const mainPage = new MainScreen(mainWindow); + const mainPage = await new MainScreen(mainWindow).setup(); await mainPage.waitFor(); }); test('should be able to create and edit a new note', async ({ mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); const editor = await mainScreen.createNewNote('Test note'); // Note list should contain the new note @@ -41,7 +41,7 @@ test.describe('main', () => { }); test('mermaid and KaTeX should render', async ({ mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); const editor = await mainScreen.createNewNote('🚧 Test 🚧'); const testCommitId = 'bf59b2'; @@ -97,7 +97,7 @@ test.describe('main', () => { }); test('should correctly resize large images', async ({ electronApp, mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); await mainScreen.createNewNote('Image resize test (part 1)'); const editor = mainScreen.noteEditor; @@ -138,7 +138,7 @@ test.describe('main', () => { for (const target of ['', '_blank']) { test(`clicking on an external link with target=${JSON.stringify(target)} should try to launch a browser`, async ({ electronApp, mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); await mainScreen.waitFor(); // Mock openExternal diff --git a/packages/app-desktop/integration-tests/markdownEditor.spec.ts b/packages/app-desktop/integration-tests/markdownEditor.spec.ts index d4dc0ebc936..96b8317928b 100644 --- a/packages/app-desktop/integration-tests/markdownEditor.spec.ts +++ b/packages/app-desktop/integration-tests/markdownEditor.spec.ts @@ -8,7 +8,7 @@ import activateMainMenuItem from './util/activateMainMenuItem'; test.describe('markdownEditor', () => { test('preview pane should render images in HTML notes', async ({ mainWindow, electronApp }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); await mainScreen.waitFor(); await mainScreen.importHtmlDirectory(electronApp, join(__dirname, 'resources', 'html-import')); @@ -36,7 +36,7 @@ test.describe('markdownEditor', () => { }); test('preview pane should render PDFs', async ({ mainWindow, electronApp }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); await mainScreen.createNewNote('PDF attachments'); const editor = mainScreen.noteEditor; @@ -81,7 +81,7 @@ test.describe('markdownEditor', () => { }); test('preview pane should render video attachments', async ({ mainWindow, electronApp }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); await mainScreen.createNewNote('Media attachments'); const editor = mainScreen.noteEditor; @@ -105,7 +105,7 @@ test.describe('markdownEditor', () => { }); test('arrow keys should navigate the toolbar', async ({ mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); await mainScreen.waitFor(); await mainScreen.createNewNote('Note 1'); @@ -142,7 +142,7 @@ test.describe('markdownEditor', () => { }); test('should sync local search between the viewer and editor', async ({ mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); await mainScreen.waitFor(); const noteEditor = mainScreen.noteEditor; @@ -198,7 +198,7 @@ test.describe('markdownEditor', () => { }); test('should move focus when the visible editor panes change', async ({ mainWindow, electronApp }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); await mainScreen.waitFor(); const noteEditor = mainScreen.noteEditor; diff --git a/packages/app-desktop/integration-tests/models/MainScreen.ts b/packages/app-desktop/integration-tests/models/MainScreen.ts index 057173cec48..56f86a10e9a 100644 --- a/packages/app-desktop/integration-tests/models/MainScreen.ts +++ b/packages/app-desktop/integration-tests/models/MainScreen.ts @@ -24,6 +24,12 @@ export default class MainScreen { this.goToAnything = new GoToAnything(page, this); } + public async setup() { + await this.waitFor(); + await this.sidebar.createNewFolder('Test'); + return this; + } + public async waitFor() { await this.newNoteButton.waitFor(); await this.noteList.waitFor(); diff --git a/packages/app-desktop/integration-tests/noteList.spec.ts b/packages/app-desktop/integration-tests/noteList.spec.ts index 3eef4c4eb86..2affee7e286 100644 --- a/packages/app-desktop/integration-tests/noteList.spec.ts +++ b/packages/app-desktop/integration-tests/noteList.spec.ts @@ -4,7 +4,7 @@ import setMessageBoxResponse from './util/setMessageBoxResponse'; test.describe('noteList', () => { test('should be possible to edit notes in a different notebook when searching', async ({ mainWindow, electronApp }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); const sidebar = mainScreen.sidebar; const folderAHeader = await sidebar.createNewFolder('Folder A'); @@ -39,7 +39,7 @@ test.describe('noteList', () => { }); test('shift-delete should ask to permanently delete notes, but only when the note list is focused', async ({ electronApp, mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); const sidebar = mainScreen.sidebar; const folderBHeader = await sidebar.createNewFolder('Folder B'); @@ -76,7 +76,7 @@ test.describe('noteList', () => { }); test('arrow keys should navigate the note list', async ({ electronApp, mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); const sidebar = mainScreen.sidebar; await sidebar.createNewFolder('Folder'); @@ -89,6 +89,7 @@ test.describe('noteList', () => { const noteList = mainScreen.noteList; await noteList.sortByTitle(electronApp); await noteList.focusContent(electronApp); + // The most recently-created note should be visible const note4Item = noteList.getNoteItemByTitle('note_4'); const note3Item = noteList.getNoteItemByTitle('note_3'); diff --git a/packages/app-desktop/integration-tests/pluginApi.spec.ts b/packages/app-desktop/integration-tests/pluginApi.spec.ts index 049d0dd7af7..472d016340e 100644 --- a/packages/app-desktop/integration-tests/pluginApi.spec.ts +++ b/packages/app-desktop/integration-tests/pluginApi.spec.ts @@ -5,7 +5,7 @@ import MainScreen from './models/MainScreen'; test.describe('pluginApi', () => { test('the editor.setText command should update the current note (use RTE: false)', async ({ startAppWithPlugins }) => { const { app, mainWindow } = await startAppWithPlugins(['resources/test-plugins/execCommand.js']); - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); await mainScreen.createNewNote('First note'); const editor = mainScreen.noteEditor; diff --git a/packages/app-desktop/integration-tests/richTextEditor.spec.ts b/packages/app-desktop/integration-tests/richTextEditor.spec.ts index 60c60f9f601..8333dcdb3e1 100644 --- a/packages/app-desktop/integration-tests/richTextEditor.spec.ts +++ b/packages/app-desktop/integration-tests/richTextEditor.spec.ts @@ -6,7 +6,7 @@ import { basename, join } from 'path'; test.describe('richTextEditor', () => { test('HTML links should be preserved when editing a note', async ({ electronApp, mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); await mainScreen.createNewNote('Testing!'); const editor = mainScreen.noteEditor; @@ -50,7 +50,7 @@ test.describe('richTextEditor', () => { }); test('should watch resources for changes when opened with ctrl+click', async ({ electronApp, mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); await mainScreen.createNewNote('Testing!'); const editor = mainScreen.noteEditor; @@ -83,7 +83,7 @@ test.describe('richTextEditor', () => { }); test('pressing Tab should indent', async ({ mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); await mainScreen.createNewNote('Testing tabs!'); const editor = mainScreen.noteEditor; @@ -121,7 +121,7 @@ test.describe('richTextEditor', () => { }); test('should be possible to navigate between the note title and rich text editor with enter/down/up keys', async ({ mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); await mainScreen.createNewNote('Testing keyboard navigation!'); const editor = mainScreen.noteEditor; diff --git a/packages/app-desktop/integration-tests/settings.spec.ts b/packages/app-desktop/integration-tests/settings.spec.ts index c5974f8885e..d90a592c2dd 100644 --- a/packages/app-desktop/integration-tests/settings.spec.ts +++ b/packages/app-desktop/integration-tests/settings.spec.ts @@ -4,7 +4,7 @@ import SettingsScreen from './models/SettingsScreen'; test.describe('settings', () => { test('should be possible to remove sort order buttons in settings', async ({ electronApp, mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); await mainScreen.waitFor(); // Sort order buttons should be visible by default @@ -35,7 +35,7 @@ test.describe('settings', () => { }); test('clicking the sync wizard button in settings should open a dialog', async ({ electronApp, mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); await mainScreen.waitFor(); await mainScreen.openSettings(electronApp); @@ -52,7 +52,7 @@ test.describe('settings', () => { }); test('should be possible to navigate settings screen tabs with the arrow keys', async ({ electronApp, mainWindow, startupPluginsLoaded }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); await startupPluginsLoaded; await mainScreen.waitFor(); diff --git a/packages/app-desktop/integration-tests/sidebar.spec.ts b/packages/app-desktop/integration-tests/sidebar.spec.ts index 5835abb69f6..3b3be000e5b 100644 --- a/packages/app-desktop/integration-tests/sidebar.spec.ts +++ b/packages/app-desktop/integration-tests/sidebar.spec.ts @@ -3,7 +3,7 @@ import MainScreen from './models/MainScreen'; test.describe('sidebar', () => { test('should be able to create new folders', async ({ mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); const sidebar = mainScreen.sidebar; for (let i = 0; i < 3; i++) { @@ -17,7 +17,7 @@ test.describe('sidebar', () => { }); test('should allow changing the focused folder with the arrow keys', async ({ electronApp, mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); const sidebar = mainScreen.sidebar; const folderAHeader = await sidebar.createNewFolder('Folder A'); @@ -45,7 +45,7 @@ test.describe('sidebar', () => { }); test('should allow changing the parent of a folder by drag-and-drop', async ({ electronApp, mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); const sidebar = mainScreen.sidebar; const parentFolderHeader = await sidebar.createNewFolder('Parent folder'); @@ -77,7 +77,7 @@ test.describe('sidebar', () => { }); test('all notes section should list all notes', async ({ electronApp, mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); const sidebar = mainScreen.sidebar; const testFolderA = await sidebar.createNewFolder('Folder A'); diff --git a/packages/app-desktop/integration-tests/simpleBackup.spec.ts b/packages/app-desktop/integration-tests/simpleBackup.spec.ts index f01e281bb74..41addfe4c07 100644 --- a/packages/app-desktop/integration-tests/simpleBackup.spec.ts +++ b/packages/app-desktop/integration-tests/simpleBackup.spec.ts @@ -7,7 +7,7 @@ test.describe('simpleBackup', () => { test('should have a section in settings', async ({ electronApp, startupPluginsLoaded, mainWindow }) => { await startupPluginsLoaded; - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); await mainScreen.waitFor(); // Open settings (check both labels so that this works on MacOS) @@ -24,7 +24,7 @@ test.describe('simpleBackup', () => { test('should be possible to create a backup', async ({ electronApp, startupPluginsLoaded, mainWindow }) => { await startupPluginsLoaded; - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); await mainScreen.waitFor(); // Backups should work diff --git a/packages/app-desktop/integration-tests/util/createStartupArgs.ts b/packages/app-desktop/integration-tests/util/createStartupArgs.ts index f2397054dbb..b79d467d406 100644 --- a/packages/app-desktop/integration-tests/util/createStartupArgs.ts +++ b/packages/app-desktop/integration-tests/util/createStartupArgs.ts @@ -2,7 +2,7 @@ const createStartupArgs = (profileDirectory: string) => { // We need to run with --env dev to disable the single instance check. return [ - 'main.js', '--env', 'dev', '--profile', profileDirectory, + 'main.js', '--env', 'dev', '--no-welcome', '--profile', profileDirectory, ]; }; diff --git a/packages/app-desktop/integration-tests/util/test.ts b/packages/app-desktop/integration-tests/util/test.ts index f9bac31a039..9e922d69f20 100644 --- a/packages/app-desktop/integration-tests/util/test.ts +++ b/packages/app-desktop/integration-tests/util/test.ts @@ -32,12 +32,20 @@ const getAndResizeMainWindow = async (electronApp: ElectronApplication) => { return mainWindow; }; -const waitForStartupPlugins = async (electronApp: ElectronApplication) => { - return electronApp.evaluate(({ ipcMain }) => { +const waitForMainMessage = (electronApp: ElectronApplication, messageId: string) => { + return electronApp.evaluate(({ ipcMain }, messageId) => { return new Promise(resolve => { - ipcMain.once('startup-plugins-loaded', () => resolve()); + ipcMain.once(messageId, () => resolve()); }); - }); + }, messageId); +}; + +const waitForAppLoaded = async (electronApp: ElectronApplication) => { + await waitForMainMessage(electronApp, 'startup-finished'); +}; + +const waitForStartupPlugins = async (electronApp: ElectronApplication) => { + await waitForMainMessage(electronApp, 'startup-plugins-loaded'); }; const testDir = dirname(__dirname); @@ -62,7 +70,9 @@ export const test = base.extend({ electronApp: async ({ profileDirectory }, use) => { const startupArgs = createStartupArgs(profileDirectory); const electronApp = await electron.launch({ args: startupArgs }); + const startupPromise = waitForAppLoaded(electronApp); await setDarkMode(electronApp, false); + await startupPromise; await use(electronApp); @@ -85,8 +95,10 @@ export const test = base.extend({ pluginPaths.map(path => resolve(testDir, path)).join(','), ], }); + const startupPromise = waitForAppLoaded(electronApp); const mainWindowPromise = getAndResizeMainWindow(electronApp); await waitForStartupPlugins(electronApp); + await startupPromise; return { app: electronApp, diff --git a/packages/app-desktop/integration-tests/wcag.spec.ts b/packages/app-desktop/integration-tests/wcag.spec.ts index 26fbd7ba41a..940e5b4ae00 100644 --- a/packages/app-desktop/integration-tests/wcag.spec.ts +++ b/packages/app-desktop/integration-tests/wcag.spec.ts @@ -32,7 +32,7 @@ const expectNoViolations = async (page: Page) => { test.describe('wcag', () => { for (const tabName of ['General', 'Plugins']) { test(`should not detect significant issues in the settings screen ${tabName} tab`, async ({ electronApp, mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); await mainScreen.waitFor(); await mainScreen.openSettings(electronApp); @@ -50,7 +50,7 @@ test.describe('wcag', () => { } test('should not detect significant issues in the main screen with an open note', async ({ mainWindow }) => { - const mainScreen = new MainScreen(mainWindow); + const mainScreen = await new MainScreen(mainWindow).setup(); await mainScreen.waitFor(); await mainScreen.createNewNote('Test'); diff --git a/packages/tools/cspell/dictionary4.txt b/packages/tools/cspell/dictionary4.txt index f0fc38eea64..eb09ab72009 100644 --- a/packages/tools/cspell/dictionary4.txt +++ b/packages/tools/cspell/dictionary4.txt @@ -143,5 +143,6 @@ Rocketbook datamatrix nosniff CNIL +setsize Comprar -seguidores \ No newline at end of file +seguidores