mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
chore(e2e): add test for dragging to new window
This commit is contained in:
parent
13d3429424
commit
ec4cc0fc33
@ -1,15 +1,16 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
import App from "../support/app";
|
||||
|
||||
const NOTE_TITLE = "Trilium Integration Test DB";
|
||||
|
||||
test("Can drag tabs around", async ({ page }) => {
|
||||
const app = new App(page);
|
||||
await app.goto();
|
||||
|
||||
// [1]: Trilium Integration Test DB note
|
||||
const noteTitle = "Trilium Integration Test DB";
|
||||
await app.closeAllTabs();
|
||||
await app.clickNoteOnNoteTreeByTitle(noteTitle);
|
||||
await expect(app.getActiveTab()).toContainText(noteTitle);
|
||||
await app.clickNoteOnNoteTreeByTitle(NOTE_TITLE);
|
||||
await expect(app.getActiveTab()).toContainText(NOTE_TITLE);
|
||||
|
||||
// [1] [2] [3]
|
||||
await app.addNewTab();
|
||||
@ -21,9 +22,38 @@ test("Can drag tabs around", async ({ page }) => {
|
||||
await tab.dragTo(app.getTab(2), { targetPosition: { x: 50, y: 0 }});
|
||||
|
||||
tab = app.getTab(2);
|
||||
await expect(tab).toContainText(noteTitle);
|
||||
await expect(tab).toContainText(NOTE_TITLE);
|
||||
|
||||
// Drag the tab to the left
|
||||
await tab.dragTo(app.getTab(0), { targetPosition: { x: 50, y: 0 }});
|
||||
await expect(app.getTab(0)).toContainText(noteTitle);
|
||||
await expect(app.getTab(0)).toContainText(NOTE_TITLE);
|
||||
});
|
||||
|
||||
test("Can drag tab to new window", async ({ page }) => {
|
||||
const app = new App(page);
|
||||
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 {
|
||||
fail("Unable to determine tab position");
|
||||
}
|
||||
|
||||
// Wait for the popup to show
|
||||
const popup = await popupPromise;
|
||||
const popupApp = new App(popup);
|
||||
await expect(popupApp.getActiveTab()).toHaveText(NOTE_TITLE);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user