diff --git a/e2e/note_types/text.spec.ts b/e2e/note_types/text.spec.ts new file mode 100644 index 000000000..ec9c24e98 --- /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.ts index 92cbe55e9..4f36dfb7b 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.db index da7b5158b..a80f36d83 100644 Binary files a/integration-tests/db/document.db and b/integration-tests/db/document.db differ