Skip to content

Build your personal knowledge base with Trilium Notes

e2e(server): flakiness in tab_bar

Elian Doran6b57ee565481
diff --git a/apps/server-e2e/src/layout/tab_bar.spec.ts b/apps/server-e2e/src/layout/tab_bar.spec.ts
index 90e17afef5..7910649668 100644
--- a/apps/server-e2e/src/layout/tab_bar.spec.ts
+++ b/apps/server-e2e/src/layout/tab_bar.spec.ts
@@ -1,4 +1,5 @@
-import { test, expect } from "@playwright/test";
+import { expect,test } from "@playwright/test";
+
import App from "../support/app";
const NOTE_TITLE = "Trilium Integration Test DB";
@@ -65,21 +66,21 @@ test("Tabs are restored in right order", async ({ page, context }) => {
// Open three tabs.
await app.closeAllTabs();
await app.goToNoteInNewTab("Code notes");
+ await expect(app.getActiveTab()).toContainText("Code notes");
await app.addNewTab();
await app.goToNoteInNewTab("Text notes");
+ await expect(app.getActiveTab()).toContainText("Text notes");
await app.addNewTab();
await app.goToNoteInNewTab("Mermaid");
+ await expect(app.getActiveTab()).toContainText("Mermaid");
// Select the mid one.
await app.getTab(1).click();
await expect(app.noteTreeActiveNote).toContainText("Text notes");
- await expect(app.getTab(0)).toContainText("Code notes");
- await expect(app.getTab(1)).toContainText("Text notes");
- await expect(app.getTab(2)).toContainText("Mermaid");
// Refresh the page and check the order.
await app.goto( { preserveTabs: true });
- await expect(app.getTab(0)).toContainText("Code notes", { timeout: 15_000 });
+ await expect(app.getTab(0)).toContainText("Code notes");
await expect(app.getTab(1)).toContainText("Text notes");
await expect(app.getTab(2)).toContainText("Mermaid");
@@ -128,8 +129,8 @@ test("New tab displays workspaces", async ({ page, context }) => {
const workspaceNotesEl = app.currentNoteSplitContent.locator(".workspace-notes");
await expect(workspaceNotesEl).toBeVisible();
- expect(workspaceNotesEl).toContainText("Personal");
- expect(workspaceNotesEl).toContainText("Work");
+ await expect(workspaceNotesEl).toContainText("Personal");
+ await expect(workspaceNotesEl).toContainText("Work");
await expect(workspaceNotesEl.locator(".bx.bxs-user")).toBeVisible();
await expect(workspaceNotesEl.locator(".bx.bx-briefcase-alt")).toBeVisible();
diff --git a/apps/server-e2e/src/support/app.ts b/apps/server-e2e/src/support/app.ts
index 9185a19189..86cbb855a0 100644
--- a/apps/server-e2e/src/support/app.ts
+++ b/apps/server-e2e/src/support/app.ts
@@ -68,13 +68,15 @@ export default class App {
async goToNoteInNewTab(noteTitle: string) {
const autocomplete = this.currentNoteSplit.locator(".note-autocomplete");
+ await expect(autocomplete).toBeVisible();
await autocomplete.fill(noteTitle);
const resultsSelector = this.currentNoteSplit.locator(".note-detail-empty-results");
await expect(resultsSelector).toContainText(noteTitle);
- await resultsSelector.locator(".aa-suggestion", { hasText: noteTitle })
- .nth(1) // Select the second one, as the first one is "Create a new note"
- .click();
+ const suggestionSelector = resultsSelector.locator(".aa-suggestion")
+ .nth(1); // Select the second one (best candidate), as the first one is "Create a new note"
+ await expect(suggestionSelector).toContainText(noteTitle);
+ suggestionSelector.click();
}
async goToSettings() {