feat(e2e): test going to share root

This commit is contained in:
Elian Doran 2025-01-17 23:13:55 +02:00
parent f96ab6da57
commit 6ea8a31a22
No known key found for this signature in database
3 changed files with 23 additions and 6 deletions

10
e2e/shared_notes.spec.ts Normal file
View File

@ -0,0 +1,10 @@
import { test, expect, Page } from "@playwright/test";
import App from "./support/app";
test("Goes to share root", async ({ page, context }) => {
const app = new App(page, context);
await app.goto({ url: "/share" });
const noteTitle = "Shared notes";
await expect(page).toHaveTitle(noteTitle);
await expect(page.locator("h1")).toHaveText(noteTitle);
});

View File

@ -2,6 +2,7 @@ import { expect, Locator, Page } from "@playwright/test";
import type { BrowserContext } from "@playwright/test"; import type { BrowserContext } from "@playwright/test";
interface GotoOpts { interface GotoOpts {
url?: string;
isMobile?: boolean; isMobile?: boolean;
} }
@ -28,22 +29,28 @@ export default class App {
this.sidebar = page.locator("#right-pane"); this.sidebar = page.locator("#right-pane");
} }
async goto(opts: GotoOpts = {}) { async goto({ url, isMobile }: GotoOpts = {}) {
await this.context.addCookies([ await this.context.addCookies([
{ {
url: BASE_URL, url: BASE_URL,
name: "trilium-device", name: "trilium-device",
value: opts.isMobile ? "mobile" : "desktop" value: isMobile ? "mobile" : "desktop"
} }
]); ]);
await this.page.goto("/", { waitUntil: "networkidle" }); if (!url) {
url = "/";
}
await this.page.goto(url, { waitUntil: "networkidle" });
// Wait for the page to load. // Wait for the page to load.
if (url === "/") {
await expect(this.page.locator(".tree")) await expect(this.page.locator(".tree"))
.toContainText("Trilium Integration Test"); .toContainText("Trilium Integration Test");
await this.closeAllTabs(); await this.closeAllTabs();
} }
}
async goToNoteInNewTab(noteTitle: string) { async goToNoteInNewTab(noteTitle: string) {
const autocomplete = this.currentNoteSplit.locator(".note-autocomplete"); const autocomplete = this.currentNoteSplit.locator(".note-autocomplete");

Binary file not shown.