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): add basic test for table of contents
Elian Doranb44f4e0f7474
diff --git a/e2e/note_types/text.spec.ts b/e2e/note_types/text.spec.tsnew file mode 100644index 0000000000..ec9c24e981--- /dev/null+++ b/e2e/note_types/text.spec.ts@@ -0,0 +1,33 @@+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);+ await app.goto();+ await app.closeAllTabs();+ await app.goToNoteInNewTab("Table of contents");++ await expect(app.sidebar).toContainText("Table of Contents");+ const rootList = app.sidebar.locator(".toc-widget > span > ol");++ // Heading 1.1+ // Heading 1.1+ // Heading 1.2+ // Heading 2+ // Heading 2.1+ // Heading 2.2+ // Heading 2.2.1+ // Heading 2.2.1.1+ // Heading 2.2.11.1++ await expect(rootList.locator("> li")).toHaveCount(2);+ await expect(rootList.locator("> li").first()).toHaveText("Heading 1");+ await expect(rootList.locator("> ol").first().locator("> li").first()).toHaveText("Heading 1.1");+ await expect(rootList.locator("> ol").first().locator("> li").nth(1)).toHaveText("Heading 1.2");++ await expect(rootList.locator("> ol")).toHaveCount(2);+ await expect(rootList.locator("> ol").nth(1).locator("> li")).toHaveCount(2);+ await expect(rootList.locator("> ol").nth(1).locator("> ol")).toHaveCount(1);+ await expect(rootList.locator("> ol").nth(1).locator("> ol > ol")).toHaveCount(1);+ await expect(rootList.locator("> ol").nth(1).locator("> ol > ol > ol")).toHaveCount(1);+});diff --git a/e2e/support/app.ts b/e2e/support/app.tsindex 92cbe55e9a..4f36dfb7b7 100644--- a/e2e/support/app.ts+++ b/e2e/support/app.ts@@ -6,12 +6,14 @@ export default class App {readonly tabBar: Locator;readonly noteTree: Locator;readonly currentNoteSplit: Locator;+ readonly sidebar: Locator;constructor(page: Page) {this.page = page;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() {diff --git a/integration-tests/db/document.db b/integration-tests/db/document.dbindex da7b5158b3..a80f36d839 100644Binary files a/integration-tests/db/document.db and b/integration-tests/db/document.db differ