Skip to content

Build your personal knowledge base with Trilium Notes

test(desktop): port the e2e to the current setup wizard and layout

Elian Dorane481b1552974
diff --git a/apps/desktop/e2e/example.spec.ts b/apps/desktop/e2e/example.spec.ts
index 41ca6f0db9..58e53538cf 100644
--- a/apps/desktop/e2e/example.spec.ts
+++ b/apps/desktop/e2e/example.spec.ts
@@ -1,4 +1,4 @@
-import { test, expect, _electron as electron, type ElectronApplication, request } from '@playwright/test';
+import { test, expect, _electron as electron, type ElectronApplication } from '@playwright/test';
import { join } from 'path';
import App from './support';
@@ -35,13 +35,12 @@ test.afterAll(async () => {
test('First setup', async () => {
// Get the main window
const setupWindow = await app.firstWindow();
- await expect(setupWindow).toHaveTitle("Setup");
- await expect(setupWindow.locator('h1')).toHaveText("Trilium Notes setup");
- await setupWindow.locator(`input[type="radio"]`).first().click();
+ await setupWindow.getByRole("button", { name: "Continue" }).click();
+ await setupWindow.getByText("New knowledge base").click();
// Wait for the finish.
const newWindowPromise = app.waitForEvent('window');
- await setupWindow.locator(`button[type="submit"]`, { hasText: "Next" }).click();
+ await setupWindow.getByText("With demo content").click();
const mainWindow = await newWindowPromise;
await expect(mainWindow).toHaveTitle("Trilium Notes");
@@ -50,17 +49,5 @@ test('First setup', async () => {
await support.selectNoteInNoteTree("Trilium Demo");
await support.setNoteShared(true);
- const sharedInfoWidget = support.currentNoteSplit.locator(".shared-info-widget");
- await expect(sharedInfoWidget).toBeVisible();
-
- const sharedInfoLink = sharedInfoWidget.locator("a.shared-link");
- const linkUrl = await sharedInfoLink.getAttribute("href");
- expect(linkUrl).toBeDefined();
-
- // Verify the shared link is valid
- const requestContext = await request.newContext();
- const response = await requestContext.get(linkUrl!);
- await expect(response).toBeOK();
-
- await mainWindow.waitForTimeout(5000);
+ await expect(support.currentNoteSplit.locator(".share-badge").first()).toBeVisible();
});
diff --git a/apps/desktop/e2e/support.ts b/apps/desktop/e2e/support.ts
index 88e69f1a36..7894ce183d 100644
--- a/apps/desktop/e2e/support.ts
+++ b/apps/desktop/e2e/support.ts
@@ -5,7 +5,6 @@ export default class App {
readonly noteTree: Locator;
readonly currentNoteSplit: Locator;
readonly currentNoteSplitTitle: Locator;
- readonly currentNoteSplitRibbon: Locator;
readonly currentNoteSplitContent: Locator;
page: Page;
@@ -13,8 +12,7 @@ export default class App {
this.page = page;
this.noteTree = page.locator(".tree-wrapper");
this.currentNoteSplit = page.locator(".note-split:not(.hidden-ext)");
- this.currentNoteSplitTitle = this.currentNoteSplit.locator(".note-title");
- this.currentNoteSplitRibbon = this.currentNoteSplit.locator(".ribbon-container");
+ this.currentNoteSplitTitle = this.currentNoteSplit.locator(".title-row .note-title");
this.currentNoteSplitContent = this.currentNoteSplit.locator(".note-detail-printable.visible");
}
@@ -24,30 +22,19 @@ export default class App {
await expect(this.currentNoteSplitTitle).toHaveValue(noteTitle);
}
- async goToRibbonTab(tabName: string) {
- await this.currentNoteSplitRibbon.locator(`.ribbon-tab-title`, { hasText: tabName }).click();
- }
-
async setNoteShared(shared: boolean) {
- await this.goToRibbonTab("Basic Properties");
-
- // Ensure the initial state.
- const switchButton = this.currentNoteSplitRibbon.locator(`.shared-switch-container .switch-button`);
- if (shared) {
- await expect(switchButton.locator("input")).not.toBeChecked();
- } else {
- await expect(switchButton.locator("input")).toBeChecked();
- }
-
- // Click the switch to change the state.
- await switchButton.click();
-
- // Verify the state after clicking.
- if (shared) {
- await expect(switchButton.locator("input")).toBeChecked();
- } else {
- await expect(switchButton.locator("input")).not.toBeChecked();
- }
+ await this.currentNoteSplit.locator(".note-actions button").first().click();
+ const menu = this.page.locator(".tn-dropdown-portal.note-actions .dropdown-menu").first();
+ await expect(menu).toBeVisible();
+
+ const sharedItem = menu.locator(".dropdown-item").filter({ has: this.page.locator(".bx-share-alt") });
+ const toggle = sharedItem.locator("input");
+ await expect(toggle).toBeChecked({ checked: !shared });
+
+ await sharedItem.click();
+ await expect(toggle).toBeChecked({ checked: shared });
+
+ await this.page.keyboard.press("Escape");
}
}