Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Your Markdown workspace for real projects, docs, and personal knowledge bases, b

Official website: [notebranch.app](https://notebranch.app)

**Version**: 2.9.1
**Version**: 2.9.2
**License**: MIT

## Built for daily note workflows
Expand Down
63 changes: 63 additions & 0 deletions app/desktop/integration-tests/git/find-in-file.integration.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { expect, test } from "@playwright/test";
import type { ElectronApplication, Page } from "@playwright/test";
import {
appendToCurrentEditor,
cleanupUserDataDir,
closeAppIfOpen,
connectGitRepo,
createIsolatedUserDataDir,
createMarkdownFile,
launchIntegrationApp,
} from "../helpers/gitIntegration";

const getModKey = () => (process.platform === "darwin" ? "Meta" : "Control");

test("(git) in-file find uses one working search bar", async ({
request: _request,
}, testInfo) => {
const userDataDir = await createIsolatedUserDataDir(testInfo);
let app: ElectronApplication | null = null;
try {
const launched = await launchAndSetup(userDataDir);
app = launched.app;
const page = launched.page;

const editor = page.locator(".cm-content").first();
await expect(editor).toBeVisible();
await editor.click();

await page.keyboard.press(`${getModKey()}+F`);
await expect(page.getByTestId("find-replace-bar")).toBeVisible();
await expect(page.locator(".cm-search")).toHaveCount(0);

await page.keyboard.press(`${getModKey()}+F`);
await expect(page.getByTestId("find-replace-bar")).toHaveCount(1);
await expect(page.locator(".cm-search")).toHaveCount(0);

const queryInput = page.getByTestId("find-replace-query-input");
await expect(queryInput).toBeVisible();
await queryInput.fill("beta");
await queryInput.press("Enter");

await expect(queryInput).toBeFocused();
await expect(page.getByText("1/2", { exact: true })).toBeVisible();

await queryInput.press("Enter");
await expect(queryInput).toBeFocused();
await expect(page.getByText("2/2", { exact: true })).toBeVisible();
} finally {
await closeAppIfOpen(app);
await cleanupUserDataDir(userDataDir);
}
});

const launchAndSetup = async (
userDataDir: string,
): Promise<{ app: ElectronApplication; page: Page }> => {
const launched = await launchIntegrationApp(userDataDir);
const page = launched.page;
await connectGitRepo(page);
await createMarkdownFile(page, "find-chaos.txt");
await appendToCurrentEditor(page, "\nalpha beta alpha beta alpha\n");
return launched;
};
31 changes: 29 additions & 2 deletions app/desktop/integration-tests/helpers/gitIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,34 @@ export const closeAppIfOpen = async (
if (!app) {
return;
}
await app.close();

const forceExit = async () => {
try {
await app.evaluate(({ app: electronApp }) => {
electronApp.exit(0);
});
} catch {
// Best-effort fallback during teardown.
}
};

try {
const windows = app.windows();
await Promise.all(
windows.map(async (window) => {
if (!window.isClosed()) {
await window.close({ runBeforeUnload: false });
}
}),
);
await app.close();
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
if (!message.includes("Page.handleJavaScriptDialog")) {
throw error;
}
await forceExit();
}
};

export const connectGitRepo = async (
Expand Down Expand Up @@ -452,7 +479,7 @@ export const apiCreateFile = async (
): Promise<void> => {
const response = await page.evaluate(
async ({ parentPath: p, name: n }) => {
return await window.NoteBranchApi.files.create(p, n);
return await window.NoteBranchApi.files.createFile(p, n);
},
{ parentPath, name },
);
Expand Down
2 changes: 1 addition & 1 deletion app/desktop/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "NoteBranch",
"version": "2.9.1",
"version": "2.9.2",
"packageManager": "pnpm@10.28.0",
"description": "A Git-backed Markdown note-taking desktop application",
"homepage": "https://github.com/scabir/notebranch",
Expand Down
Loading
Loading