mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	chore(e2e): port old test for checking mobile language
This commit is contained in:
		
							parent
							
								
									c641ce26d1
								
							
						
					
					
						commit
						54c5ce9257
					
				@ -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();
 | 
			
		||||
 | 
			
		||||
@ -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 show
 | 
			
		||||
    const popup = await popupPromise;
 | 
			
		||||
    const popupApp = new App(popup);
 | 
			
		||||
    const popupApp = new App(popup, context);
 | 
			
		||||
    await expect(popupApp.getActiveTab()).toHaveText(NOTE_TITLE);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
@ -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");
 | 
			
		||||
 | 
			
		||||
@ -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");
 | 
			
		||||
 | 
			
		||||
@ -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) {
 | 
			
		||||
 | 
			
		||||
@ -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");
 | 
			
		||||
});
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user