From 0b74585fc687efb4b460152d402a07b4a1a9191d Mon Sep 17 00:00:00 2001 From: Henry Heino Date: Tue, 19 Nov 2024 12:53:22 -0800 Subject: [PATCH] Disable welcome notes in tests --- .../integration-tests/goToAnything.spec.ts | 9 +++++---- packages/app-desktop/integration-tests/main.spec.ts | 10 +++++----- .../integration-tests/markdownEditor.spec.ts | 12 ++++++------ .../integration-tests/models/MainScreen.ts | 6 ++++++ .../app-desktop/integration-tests/noteList.spec.ts | 6 +++--- .../app-desktop/integration-tests/pluginApi.spec.ts | 2 +- .../integration-tests/richTextEditor.spec.ts | 8 ++++---- .../app-desktop/integration-tests/settings.spec.ts | 6 +++--- .../app-desktop/integration-tests/sidebar.spec.ts | 8 ++++---- .../integration-tests/simpleBackup.spec.ts | 4 ++-- .../integration-tests/util/createStartupArgs.ts | 2 +- packages/app-desktop/integration-tests/wcag.spec.ts | 4 ++-- 12 files changed, 42 insertions(+), 35 deletions(-) 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 24ff70ca864..4210002e22a 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'); 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/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');