| 
									
										
										
										
											2025-01-11 00:13:46 +02:00
										 |  |  | import { test, expect } from "@playwright/test"; | 
					
						
							|  |  |  | import App from "../support/app"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-11 00:45:02 +02:00
										 |  |  | const NOTE_TITLE = "Trilium Integration Test DB"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-12 18:05:24 +02:00
										 |  |  | test("Can drag tabs around", async ({ page, context }) => { | 
					
						
							|  |  |  |     const app = new App(page, context); | 
					
						
							| 
									
										
										
										
											2025-01-11 00:13:46 +02:00
										 |  |  |     await app.goto(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // [1]: Trilium Integration Test DB note
 | 
					
						
							|  |  |  |     await app.closeAllTabs(); | 
					
						
							| 
									
										
										
										
											2025-01-11 00:45:02 +02:00
										 |  |  |     await app.clickNoteOnNoteTreeByTitle(NOTE_TITLE); | 
					
						
							|  |  |  |     await expect(app.getActiveTab()).toContainText(NOTE_TITLE); | 
					
						
							| 
									
										
										
										
											2025-01-11 00:13:46 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // [1] [2] [3]
 | 
					
						
							|  |  |  |     await app.addNewTab(); | 
					
						
							|  |  |  |     await app.addNewTab(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     let tab = app.getTab(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Drag the first tab at the end
 | 
					
						
							| 
									
										
										
										
											2025-03-02 20:47:57 +01:00
										 |  |  |     await tab.dragTo(app.getTab(2), { targetPosition: { x: 50, y: 0 } }); | 
					
						
							| 
									
										
										
										
											2025-01-11 00:13:46 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     tab = app.getTab(2); | 
					
						
							| 
									
										
										
										
											2025-01-11 00:45:02 +02:00
										 |  |  |     await expect(tab).toContainText(NOTE_TITLE); | 
					
						
							| 
									
										
										
										
											2025-01-11 00:13:46 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Drag the tab to the left
 | 
					
						
							| 
									
										
										
										
											2025-03-02 20:47:57 +01:00
										 |  |  |     await tab.dragTo(app.getTab(0), { targetPosition: { x: 50, y: 0 } }); | 
					
						
							| 
									
										
										
										
											2025-01-11 00:45:02 +02:00
										 |  |  |     await expect(app.getTab(0)).toContainText(NOTE_TITLE); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-12 18:05:24 +02:00
										 |  |  | test("Can drag tab to new window", async ({ page, context }) => { | 
					
						
							|  |  |  |     const app = new App(page, context); | 
					
						
							| 
									
										
										
										
											2025-01-11 00:45:02 +02:00
										 |  |  |     await app.goto(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await app.closeAllTabs(); | 
					
						
							|  |  |  |     await app.clickNoteOnNoteTreeByTitle(NOTE_TITLE); | 
					
						
							|  |  |  |     const tab = app.getTab(0); | 
					
						
							|  |  |  |     await expect(tab).toContainText(NOTE_TITLE); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const popupPromise = page.waitForEvent("popup"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const tabPos = await tab.boundingBox(); | 
					
						
							|  |  |  |     if (tabPos) { | 
					
						
							|  |  |  |         const x = tabPos.x + tabPos.width / 2; | 
					
						
							|  |  |  |         const y = tabPos.y + tabPos.height / 2; | 
					
						
							|  |  |  |         await page.mouse.move(x, y); | 
					
						
							|  |  |  |         await page.mouse.down(); | 
					
						
							|  |  |  |         await page.mouse.move(x, y + tabPos.height + 100, { steps: 5 }); | 
					
						
							|  |  |  |         await page.mouse.up(); | 
					
						
							|  |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2025-01-12 17:17:07 +02:00
										 |  |  |         test.fail(true, "Unable to determine tab position"); | 
					
						
							| 
									
										
										
										
											2025-01-11 00:45:02 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Wait for the popup to show
 | 
					
						
							|  |  |  |     const popup = await popupPromise; | 
					
						
							| 
									
										
										
										
											2025-01-12 18:05:24 +02:00
										 |  |  |     const popupApp = new App(popup, context); | 
					
						
							| 
									
										
										
										
											2025-01-11 00:45:02 +02:00
										 |  |  |     await expect(popupApp.getActiveTab()).toHaveText(NOTE_TITLE); | 
					
						
							| 
									
										
										
										
											2025-01-11 00:13:46 +02:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2025-04-02 20:08:18 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | test("Tabs are restored in right order", async ({ page, context }) => { | 
					
						
							|  |  |  |     const app = new App(page, context); | 
					
						
							|  |  |  |     await app.goto(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Open three tabs.
 | 
					
						
							|  |  |  |     await app.closeAllTabs(); | 
					
						
							|  |  |  |     await app.goToNoteInNewTab("Code notes"); | 
					
						
							|  |  |  |     await app.addNewTab(); | 
					
						
							|  |  |  |     await app.goToNoteInNewTab("Text notes"); | 
					
						
							|  |  |  |     await app.addNewTab(); | 
					
						
							|  |  |  |     await app.goToNoteInNewTab("Mermaid"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Select the mid one.
 | 
					
						
							|  |  |  |     await app.getTab(1).click(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Refresh the page and check the order.
 | 
					
						
							|  |  |  |     await app.goto( { preserveTabs: true }); | 
					
						
							|  |  |  |     await expect(app.getTab(0)).toContainText("Code notes"); | 
					
						
							|  |  |  |     await expect(app.getTab(1)).toContainText("Text notes"); | 
					
						
							|  |  |  |     await expect(app.getTab(2)).toContainText("Mermaid"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Check the note tree has the right active node.
 | 
					
						
							|  |  |  |     await expect(app.noteTreeActiveNote).toContainText("Text notes"); | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2025-04-02 21:13:41 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | test("Empty tabs are cleared out", async ({ page, context }) => { | 
					
						
							|  |  |  |     const app = new App(page, context); | 
					
						
							|  |  |  |     await app.goto(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Open three tabs.
 | 
					
						
							|  |  |  |     await app.closeAllTabs(); | 
					
						
							|  |  |  |     await app.addNewTab(); | 
					
						
							|  |  |  |     await app.goToNoteInNewTab("Code notes"); | 
					
						
							|  |  |  |     await app.addNewTab(); | 
					
						
							|  |  |  |     await app.addNewTab(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Refresh the page and check the order.
 | 
					
						
							|  |  |  |     await app.goto({ preserveTabs: true }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Expect no empty tabs.
 | 
					
						
							|  |  |  |     expect(await app.tabBar.locator(".note-tab-wrapper").count()).toBe(1); | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2025-04-04 17:57:54 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | test("Search works when dismissing a tab", async ({ page, context }) => { | 
					
						
							|  |  |  |     const app = new App(page, context); | 
					
						
							|  |  |  |     await app.goto(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await app.goToNoteInNewTab("Table of contents"); | 
					
						
							|  |  |  |     await app.openAndClickNoteActionMenu("Search in note"); | 
					
						
							|  |  |  |     await expect(app.findAndReplaceWidget).toBeVisible(); | 
					
						
							|  |  |  |     app.findAndReplaceWidget.locator(".find-widget-close-button").click(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await app.addNewTab(); | 
					
						
							|  |  |  |     await app.goToNoteInNewTab("Sample mindmap"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await app.getTab(0).click(); | 
					
						
							|  |  |  |     await app.openAndClickNoteActionMenu("Search in note"); | 
					
						
							|  |  |  |     await expect(app.findAndReplaceWidget).toBeVisible(); | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2025-04-08 12:46:58 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | test("New tab displays workspaces", async ({ page, context }) => { | 
					
						
							|  |  |  |     const app = new App(page, context); | 
					
						
							|  |  |  |     await app.goto(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const workspaceNotesEl = app.currentNoteSplitContent.locator(".workspace-notes"); | 
					
						
							|  |  |  |     await expect(workspaceNotesEl).toBeVisible(); | 
					
						
							|  |  |  |     expect(workspaceNotesEl).toContainText("Personal"); | 
					
						
							|  |  |  |     expect(workspaceNotesEl).toContainText("Work"); | 
					
						
							|  |  |  |     await expect(workspaceNotesEl.locator(".bx.bxs-user")).toBeVisible(); | 
					
						
							|  |  |  |     await expect(workspaceNotesEl.locator(".bx.bx-briefcase-alt")).toBeVisible(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await app.closeAllTabs(); | 
					
						
							|  |  |  | }); |