Skip to content

Build your personal knowledge base with Trilium Notes

e2e(server): fix regressions after mobile tab switcher

Elian Doran4129b3a96e76
diff --git a/apps/server-e2e/src/layout/tab_bar.spec.ts b/apps/server-e2e/src/layout/tab_bar.spec.ts
index 7910649668..c408114a0d 100644
--- a/apps/server-e2e/src/layout/tab_bar.spec.ts
+++ b/apps/server-e2e/src/layout/tab_bar.spec.ts
@@ -17,17 +17,17 @@ test("Can drag tabs around", async ({ page, context }) => {
await app.addNewTab();
await app.addNewTab();
- let tab = app.getTab(0);
+ let tab = await app.getTab(0);
// Drag the first tab at the end
- await tab.dragTo(app.getTab(2), { targetPosition: { x: 50, y: 0 } });
+ await tab.dragTo(await app.getTab(2), { targetPosition: { x: 50, y: 0 } });
- tab = app.getTab(2);
+ tab = await app.getTab(2);
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(NOTE_TITLE);
+ await tab.dragTo(await app.getTab(0), { targetPosition: { x: 50, y: 0 } });
+ await expect(await app.getTab(0)).toContainText(NOTE_TITLE);
});
test("Can drag tab to new window", async ({ page, context }) => {
@@ -36,7 +36,7 @@ test("Can drag tab to new window", async ({ page, context }) => {
await app.closeAllTabs();
await app.clickNoteOnNoteTreeByTitle(NOTE_TITLE);
- const tab = app.getTab(0);
+ const tab = await app.getTab(0);
await expect(tab).toContainText(NOTE_TITLE);
const popupPromise = page.waitForEvent("popup");
@@ -75,14 +75,14 @@ test("Tabs are restored in right order", async ({ page, context }) => {
await expect(app.getActiveTab()).toContainText("Mermaid");
// Select the mid one.
- await app.getTab(1).click();
+ await (await app.getTab(1)).click();
await expect(app.noteTreeActiveNote).toContainText("Text notes");
// 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");
+ await expect(await app.getTab(0)).toContainText("Code notes");
+ await expect(await app.getTab(1)).toContainText("Text notes");
+ await expect(await app.getTab(2)).toContainText("Mermaid");
// Check the note tree has the right active node.
await expect(app.noteTreeActiveNote).toContainText("Text notes");
@@ -118,7 +118,7 @@ test("Search works when dismissing a tab", async ({ page, context }) => {
await app.addNewTab();
await app.goToNoteInNewTab("Sample mindmap");
- await app.getTab(0).click();
+ await (await app.getTab(0)).click();
await app.openAndClickNoteActionMenu("Search in note");
await expect(app.findAndReplaceWidget.first()).toBeVisible();
});
diff --git a/apps/server-e2e/src/support/app.ts b/apps/server-e2e/src/support/app.ts
index da229607b8..3922019192 100644
--- a/apps/server-e2e/src/support/app.ts
+++ b/apps/server-e2e/src/support/app.ts
@@ -26,6 +26,7 @@ export default class App {
readonly currentNoteSplitTitle: Locator;
readonly currentNoteSplitContent: Locator;
readonly sidebar: Locator;
+ private isMobile: boolean = false;
constructor(page: Page, context: BrowserContext) {
this.page = page;
@@ -43,6 +44,8 @@ export default class App {
}
async goto({ url, isMobile, preserveTabs }: GotoOpts = {}) {
+ this.isMobile = !!isMobile;
+
await this.context.addCookies([
{
url: BASE_URL,
@@ -83,7 +86,12 @@ export default class App {
await this.page.locator(".launcher-button.bx-cog").click();
}
- getTab(tabIndex: number) {
+ async getTab(tabIndex: number) {
+ if (this.isMobile) {
+ await this.launcherBar.locator(".mobile-tab-switcher").click();
+ return this.page.locator(".modal.tab-bar-modal .tab-card").nth(tabIndex);
+ }
+
return this.tabBar.locator(".note-tab-wrapper").nth(tabIndex);
}
@@ -97,7 +105,8 @@ export default class App {
async closeAllTabs() {
await this.triggerCommand("closeAllTabs");
// Page in Playwright is not updated somehow, need to click on the tab to make sure it's rendered
- await this.getTab(0).click();
+ const tab = await this.getTab(0);
+ await tab.click();
}
/**