Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
e2e: fix broken tests after modal
Elian Doran478724d56234
diff --git a/packages/trilium-e2e/src/i18n.spec.ts b/packages/trilium-e2e/src/i18n.spec.tsindex d2c10f908b..c7b59d825d 100644--- a/packages/trilium-e2e/src/i18n.spec.ts+++ b/packages/trilium-e2e/src/i18n.spec.ts@@ -26,10 +26,10 @@ test("Displays translations in Settings", async ({ page, context }) => {await app.goto();await app.closeAllTabs();await app.goToSettings();- await app.noteTree.getByText("Language & Region").click();+ await app.goToSettingsPage("_optionsLocalization");- await expect(app.currentNoteSplit).toContainText("Localization");- await expect(app.currentNoteSplit).toContainText("Language");+ await expect(app.optionsDialogContent).toContainText("Localization");+ await expect(app.optionsDialogContent).toContainText("Language");});test("User can change language from settings", async ({ page, context }) => {@@ -38,23 +38,33 @@ test("User can change language from settings", async ({ page, context }) => {await app.closeAllTabs();await app.goToSettings();- await app.noteTree.getByText("Language & Region").click();+ await app.goToSettingsPage("_optionsLocalization");++ const languageCombobox = app.dropdown(app.optionsDialogContent.locator(".options-section .dropdown").first());+ const restartButton = app.optionsDialogContent.locator("button[name=restart-app-button]");// Check that the default value (English) is set.- await expect(app.currentNoteSplit).toContainText("First day of the week");- const languageCombobox = app.dropdown(app.currentNoteSplit.locator(".options-section .dropdown").first());+ await expect(app.optionsDialogContent).toContainText("First day of the week");await expect(languageCombobox).toContainText("English (United States)");- // Select Chinese and ensure the translation is set.+ // Select Chinese and ensure the translation is set. The restart reloads the frontend, which+ // closes the settings dialog, so it needs to be reopened.await languageCombobox.selectOptionByText("简体中文");- await app.currentNoteSplit.locator("button[name=restart-app-button]").click();+ await restartButton.click();+ await expect(app.optionsDialog).toBeHidden({ timeout: 15000 });- await expect(app.currentNoteSplit).toContainText("一周的第一天", { timeout: 15000 });+ await app.goToSettings();+ await app.goToSettingsPage("_optionsLocalization");+ await expect(app.optionsDialogContent).toContainText("一周的第一天", { timeout: 15000 });await expect(languageCombobox).toContainText("简体中文");// Select English again.await languageCombobox.selectOptionByText("English (United States)");- await app.currentNoteSplit.locator("button[name=restart-app-button]").click();- await expect(app.currentNoteSplit).toContainText("Language", { timeout: 15000 });+ await restartButton.click();+ await expect(app.optionsDialog).toBeHidden({ timeout: 15000 });++ await app.goToSettings();+ await app.goToSettingsPage("_optionsLocalization");+ await expect(app.optionsDialogContent).toContainText("Language", { timeout: 15000 });await expect(languageCombobox).toContainText("English (United States)");});diff --git a/packages/trilium-e2e/src/layout/tree.spec.ts b/packages/trilium-e2e/src/layout/tree.spec.tsindex ba244a9d3f..9daaddacd7 100644--- a/packages/trilium-e2e/src/layout/tree.spec.ts+++ b/packages/trilium-e2e/src/layout/tree.spec.ts@@ -9,13 +9,15 @@ test("Hoist note remains expanded when opening Options and clicking child note",await app.goto();await app.closeAllTabs();+ // Settings open in a dialog; maximizing it moves them to a tab hoisted on the Options subtree.await app.goToSettings();+ await app.optionsDialog.locator(".custom-title-bar-button.bx-expand-alt").click();- // Activate it when opening Options- await expect(app.noteTreeActiveNote).toContainText(OPTIONS_TITLE);+ await expect(app.noteTreeHoistedNote).toContainText(OPTIONS_TITLE);+ await expect(app.noteTreeActiveNote).toContainText("Appearance");// Clicking a hoist’s child note does not collapse the hoist note- await app.clickNoteOnNoteTreeByTitle("Appearance");+ await app.clickNoteOnNoteTreeByTitle("Shortcuts");const node = app.page.locator(".fancytree-node.fancytree-submatch:has(.bx-cog)");await expect(node).toHaveClass(/fancytree-expanded/);});diff --git a/packages/trilium-e2e/src/support/app.ts b/packages/trilium-e2e/src/support/app.tsindex c3446edbe5..79d6531adb 100644--- a/packages/trilium-e2e/src/support/app.ts+++ b/packages/trilium-e2e/src/support/app.ts@@ -32,6 +32,8 @@ export default class App {readonly currentNoteSplitTitle: Locator;readonly currentNoteSplitContent: Locator;readonly sidebar: Locator;+ readonly optionsDialog: Locator;+ readonly optionsDialogContent: Locator;private isMobile: boolean = false;constructor(page: Page, context: BrowserContext) {@@ -47,6 +49,8 @@ export default class App {this.currentNoteSplitTitle = this.currentNoteSplit.locator(".note-title").first();this.currentNoteSplitContent = this.currentNoteSplit.locator(".note-detail-printable.visible");this.sidebar = page.locator("#right-pane");+ this.optionsDialog = page.locator(".modal.options-dialog");+ this.optionsDialogContent = this.optionsDialog.locator(".modal-body");}get noteTree(): Locator {@@ -114,8 +118,18 @@ export default class App {await suggestionSelector.click();}+ /** Opens the settings dialog via the launcher cog and waits for it to appear. */async goToSettings() {await this.page.locator(".launcher-button.bx-cog").click();+ await expect(this.optionsDialog).toBeVisible();+ }++ /**+ * Navigates to the given settings page via the options dialog's sidebar. Pages are matched by+ * their note ID (e.g. `_optionsLocalization`) so navigation is independent of the UI language.+ */+ async goToSettingsPage(optionsNoteId: string) {+ await this.optionsDialog.locator(`.settings-navigation-item[href$="${optionsNoteId}"]`).click();}async getTab(tabIndex: number) {