chore(e2e): add basic test for table of contents

This commit is contained in:
Elian Doran 2025-01-11 13:36:56 +02:00
parent 74b2643c28
commit b44f4e0f74
No known key found for this signature in database
3 changed files with 35 additions and 0 deletions

View File

@ -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);
});

View File

@ -6,12 +6,14 @@ export default class App {
readonly tabBar: Locator; readonly tabBar: Locator;
readonly noteTree: Locator; readonly noteTree: Locator;
readonly currentNoteSplit: Locator; readonly currentNoteSplit: Locator;
readonly sidebar: Locator;
constructor(page: Page) { constructor(page: Page) {
this.page = page; this.page = page;
this.tabBar = page.locator(".tab-row-widget-container"); this.tabBar = page.locator(".tab-row-widget-container");
this.noteTree = page.locator(".tree-wrapper"); this.noteTree = page.locator(".tree-wrapper");
this.currentNoteSplit = page.locator(".note-split:not(.hidden-ext)") this.currentNoteSplit = page.locator(".note-split:not(.hidden-ext)")
this.sidebar = page.locator("#right-pane");
} }
async goto() { async goto() {

Binary file not shown.