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
chore(e2e): port old test for checking mobile language
Elian Doran54c5ce925781
diff --git a/e2e/i18n.spec.ts b/e2e/i18n.spec.tsindex 1ca65edf83..b4c9a08424 100644--- a/e2e/i18n.spec.ts+++ b/e2e/i18n.spec.ts@@ -1,16 +1,24 @@import { test, expect, Page } from "@playwright/test";import App from "./support/app";-test("Displays translation on desktop", async ({ page }) => {- const app = new App(page);+test("Displays translation on desktop", async ({ page, context }) => {+ const app = new App(page, context);await app.goto();await expect(page.locator("#left-pane .quick-search input")).toHaveAttribute("placeholder", "Quick search");});-test("Displays translations in Settings", async ({ page }) => {- const app = new App(page);+test("Displays translation on mobile", async ({ page, context }) => {+ const app = new App(page, context);+ await app.goto({ isMobile: true });++ await expect(page.locator("#mobile-sidebar-wrapper .quick-search input"))+ .toHaveAttribute("placeholder", "Quick search");+});++test("Displays translations in Settings", async ({ page, context }) => {+ const app = new App(page, context);await app.goto();await app.closeAllTabs();await app.goToSettings();@@ -20,8 +28,8 @@ test("Displays translations in Settings", async ({ page }) => {await expect(app.currentNoteSplit).toContainText("Language");});-test("User can change language from settings", async ({ page }) => {- const app = new App(page);+test("User can change language from settings", async ({ page, context }) => {+ const app = new App(page, context);await app.goto();await app.closeAllTabs();diff --git a/e2e/layout/tab_bar.spec.ts b/e2e/layout/tab_bar.spec.tsindex 4d214b8dc0..99391c115d 100644--- a/e2e/layout/tab_bar.spec.ts+++ b/e2e/layout/tab_bar.spec.ts@@ -3,8 +3,8 @@ import App from "../support/app";const NOTE_TITLE = "Trilium Integration Test DB";-test("Can drag tabs around", async ({ page }) => {- const app = new App(page);+test("Can drag tabs around", async ({ page, context }) => {+ const app = new App(page, context);await app.goto();// [1]: Trilium Integration Test DB note@@ -29,8 +29,8 @@ test("Can drag tabs around", async ({ page }) => {await expect(app.getTab(0)).toContainText(NOTE_TITLE);});-test("Can drag tab to new window", async ({ page }) => {- const app = new App(page);+test("Can drag tab to new window", async ({ page, context }) => {+ const app = new App(page, context);await app.goto();await app.closeAllTabs();@@ -54,6 +54,6 @@ test("Can drag tab to new window", async ({ page }) => {// Wait for the popup to showconst popup = await popupPromise;- const popupApp = new App(popup);+ const popupApp = new App(popup, context);await expect(popupApp.getActiveTab()).toHaveText(NOTE_TITLE);});diff --git a/e2e/note_types/code.spec.ts b/e2e/note_types/code.spec.tsindex 4f63588ee3..6473b68499 100644--- a/e2e/note_types/code.spec.ts+++ b/e2e/note_types/code.spec.ts@@ -1,8 +1,8 @@import { test, expect, Page } from "@playwright/test";import App from "../support/app";-test("Displays lint warnings for backend script", async ({ page }) => {- const app = new App(page);+test("Displays lint warnings for backend script", async ({ page, context }) => {+ const app = new App(page, context);await app.goto();await app.closeAllTabs();await app.goToNoteInNewTab("Backend script with lint warnings");@@ -21,8 +21,8 @@ test("Displays lint warnings for backend script", async ({ page }) => {await expectTooltip(page, "'world' is defined but never used.");});-test("Displays lint errors for backend script", async ({ page }) => {- const app = new App(page);+test("Displays lint errors for backend script", async ({ page, context }) => {+ const app = new App(page, context);await app.goto();await app.closeAllTabs();await app.goToNoteInNewTab("Backend script with lint errors");diff --git a/e2e/note_types/text.spec.ts b/e2e/note_types/text.spec.tsindex 2a8880f180..d7b8787241 100644--- a/e2e/note_types/text.spec.ts+++ b/e2e/note_types/text.spec.ts@@ -1,8 +1,8 @@import { test, expect, Page } from "@playwright/test";import App from "../support/app";-test("Table of contents is displayed", async ({ page }) => {- const app = new App(page);+test("Table of contents is displayed", async ({ page, context }) => {+ const app = new App(page, context);await app.goto();await app.closeAllTabs();await app.goToNoteInNewTab("Table of contents");@@ -36,8 +36,8 @@ test("Table of contents is displayed", async ({ page }) => {await expect(rootList.locator("> ol").nth(1).locator("> ol > ol > ol")).toHaveCount(1);});-test("Highlights list is displayed", async ({ page }) => {- const app = new App(page);+test("Highlights list is displayed", async ({ page, context }) => {+ const app = new App(page, context);await app.goto();await app.closeAllTabs();await app.goToNoteInNewTab("Highlights list");diff --git a/e2e/support/app.ts b/e2e/support/app.tsindex 40546acaec..08d1ebb772 100644--- a/e2e/support/app.ts+++ b/e2e/support/app.ts@@ -1,27 +1,44 @@-import { Locator, Page, expect } from "@playwright/test";+import { expect, Locator, Page } from "@playwright/test";+import type { BrowserContext } from "@playwright/test";++interface GotoOpts {+ isMobile?: boolean;+}export default class App {readonly page: Page;+ readonly context: BrowserContext;readonly tabBar: Locator;readonly noteTree: Locator;readonly currentNoteSplit: Locator;readonly sidebar: Locator;- constructor(page: Page) {+ constructor(page: Page, context: BrowserContext) {this.page = page;+ this.context = context;+this.tabBar = page.locator(".tab-row-widget-container");this.noteTree = page.locator(".tree-wrapper");this.currentNoteSplit = page.locator(".note-split:not(.hidden-ext)")this.sidebar = page.locator("#right-pane");}- async goto() {+ async goto(opts: GotoOpts = {}) {+ await this.context.addCookies([+ {+ url: "http://127.0.0.1:8082",+ name: "trilium-device",+ value: opts.isMobile ? "mobile" : "desktop"+ }+ ]);+await this.page.goto("/", { waitUntil: "networkidle" });// Wait for the page to load.await expect(this.page.locator(".tree")).toContainText("Trilium Integration Test");+ await this.closeAllTabs();}async goToNoteInNewTab(noteTitle: string) {diff --git a/integration-tests/i18n.spec.ts b/integration-tests/i18n.spec.tsdeleted file mode 100644index 4cf7e31c28..0000000000--- a/integration-tests/i18n.spec.ts+++ /dev/null@@ -1,13 +0,0 @@-import test, { expect } from "@playwright/test";--test("Restores language on start-up on mobile", async ({ page, context }) => {- await context.addCookies([- {- url: "http://localhost:8082",- name: "trilium-device",- value: "mobile"- }- ]);- await page.goto("http://localhost:8082");- await expect(page.locator("#launcher-pane div").first()).toContainText("Open New Window");-});