mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	chore(e2e): add basic test for table of contents
This commit is contained in:
		
							parent
							
								
									74b2643c28
								
							
						
					
					
						commit
						b44f4e0f74
					
				
							
								
								
									
										33
									
								
								e2e/note_types/text.spec.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								e2e/note_types/text.spec.ts
									
									
									
									
									
										Normal 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);
 | 
			
		||||
});
 | 
			
		||||
@ -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() {
 | 
			
		||||
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user