A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
desktop: fix tests
Abdullah Attadc958098ea30
diff --git a/apps/desktop/__tests__/auto-updates.test.ts b/apps/desktop/__tests__/auto-updates.test.tsindex 5b57599f7..50d7cc10a 100644--- a/apps/desktop/__tests__/auto-updates.test.ts+++ b/apps/desktop/__tests__/auto-updates.test.ts@@ -17,10 +17,9 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { test } from "@nn/test";+import { test, expect } from "@nn/test";import { gt, lt } from "semver";import { AppModel } from "../../web/__e2e__/models/app.model.js";-import { expect } from "playwright/test";test.extend({ options: { version: "3.0.0" } })("update starts downloading if version is outdated",diff --git a/apps/desktop/__tests__/electron-test/base-test.ts b/apps/desktop/__tests__/electron-test/base-test.tsindex 29e00406f..facf4334f 100644--- a/apps/desktop/__tests__/electron-test/base-test.ts+++ b/apps/desktop/__tests__/electron-test/base-test.ts@@ -17,8 +17,7 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { mergeTests } from "@playwright/test";-import { test } from "@playwright/test";+import { mergeTests, test } from "@playwright/test";import type { CommonFixtures, CommonWorkerFixtures } from "./common-fixtures";import { commonFixtures } from "./common-fixtures";import { platformTest } from "./platform-fixtures";diff --git a/apps/desktop/__tests__/electron-test/index.ts b/apps/desktop/__tests__/electron-test/index.tsindex c080fea17..5859eeef9 100644--- a/apps/desktop/__tests__/electron-test/index.ts+++ b/apps/desktop/__tests__/electron-test/index.ts@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.import { AppContext, buildAndLaunchApp, TestOptions } from "./utils";import path from "path";import { version } from "../../package.json";-import type { Browser, ElectronApplication, Page } from "@playwright/test";+import type { ElectronApplication, Page } from "@playwright/test";import type { TraceViewerFixtures } from "./trace-viewer-fixtures";import { traceViewerFixtures } from "./trace-viewer-fixtures";import { PageTestFixtures, PageWorkerFixtures } from "./page-test-api";diff --git a/apps/desktop/__tests__/electron-test/test-mode.ts b/apps/desktop/__tests__/electron-test/test-mode.tsindex e1ed86bd6..cc3380d2b 100644--- a/apps/desktop/__tests__/electron-test/test-mode.ts+++ b/apps/desktop/__tests__/electron-test/test-mode.ts@@ -1,42 +1,35 @@-/*-This file is part of the Notesnook project (https://notesnook.com/)--Copyright (C) 2023 Streetwriters (Private) Limited--This program is free software: you can redistribute it and/or modify-it under the terms of the GNU General Public License as published by-the Free Software Foundation, either version 3 of the License, or-(at your option) any later version.--This program is distributed in the hope that it will be useful,-but WITHOUT ANY WARRANTY; without even the implied warranty of-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-GNU General Public License for more details.--You should have received a copy of the GNU General Public License-along with this program. If not, see <http://www.gnu.org/licenses/>.-*/-/* eslint-disable @typescript-eslint/ban-ts-comment */--// @ts-ignore-import { start } from "playwright-core/lib/outofprocess";-// @ts-ignore-import type { Playwright } from "playwright-core/lib/client/playwright";--export type TestModeName =- | "default"- | "driver"- | "service"- | "service2"- | "wsl";+/* eslint-disable header/header */+/**+ * Copyright (c) Microsoft Corporation.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++// eslint-disable-next-line @typescript-eslint/ban-ts-comment+/// @ts-ignore+import { oop, client } from "playwright-core/lib/coreBundle";++export type TestModeName = "default" | "driver";++const { start } = oop;interface TestMode {- setup(): Promise<Playwright>;+ setup(): Promise<client.Playwright>;teardown(): Promise<void>;}export class DriverTestMode implements TestMode {- private _impl: { playwright: Playwright; stop: () => Promise<void> };+ private _impl: { playwright: client.Playwright; stop: () => Promise<void> };async setup() {this._impl = await start({diff --git a/apps/desktop/__tests__/electron-test/utils.ts b/apps/desktop/__tests__/electron-test/utils.tsindex 94f15949b..e4d3544e0 100644--- a/apps/desktop/__tests__/electron-test/utils.ts+++ b/apps/desktop/__tests__/electron-test/utils.ts@@ -20,7 +20,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.import { execSync } from "child_process";import { cp } from "fs/promises";import path, { join, resolve } from "path";-import { _electron as electron, ElectronApplication, Page } from "playwright";+import {+ _electron as electron,+ ElectronApplication,+ Page+} from "@playwright/test";import { existsSync } from "fs";import { mkdir, writeFile } from "node:fs/promises";@@ -30,7 +34,7 @@ const root = path.resolve(__dirname, "..", "..");const SOURCE_DIR = resolve(root, "output", productName);export interface AppContext {- app: import("playwright").ElectronApplication;+ app: ElectronApplication;userDataDir: string;outputDir: string;relaunch: () => Promise<void>;diff --git a/apps/desktop/package-lock.json b/apps/desktop/package-lock.jsonindex 07a47ec9e..51d5ce093 100644--- a/apps/desktop/package-lock.json+++ b/apps/desktop/package-lock.json@@ -26,7 +26,7 @@"zod": "3.24.3"},"devDependencies": {- "@playwright/test": "^1.58.2",+ "@playwright/test": "1.61.1","@streetwriters/kysely": "^0.27.4","@types/node": "22.15.3","@types/yargs": "^17.0.33",@@ -37,7 +37,7 @@"fkill": "^10.0.3","node-abi": "^4.5.0","node-gyp-build": "^4.8.4",- "playwright": "1.58.2",+ "playwright-core": "1.61.1","prebuildify": "^6.0.1","slugify": "1.6.6","tree-kill": "^1.2.2",@@ -7312,11 +7312,13 @@}},"node_modules/@playwright/test": {- "version": "1.59.1",+ "version": "1.61.1",+ "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.61.1.tgz",+ "integrity": "sha512-8nKv6+0RJSL9FE4jYOEGXnPeM/Hg12qZpmqzZjRh3qM0Y7c3z1mrOTfFLids72RDQYVh9WpLEfR5WdpNX4fkig==","dev": true,"license": "Apache-2.0","dependencies": {- "playwright": "1.59.1"+ "playwright": "1.61.1"},"bin": {"playwright": "cli.js"@@ -7326,11 +7328,13 @@}},"node_modules/@playwright/test/node_modules/playwright": {- "version": "1.59.1",+ "version": "1.61.1",+ "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.61.1.tgz",+ "integrity": "sha512-DWnY5o3YbLWK4GovuAVwpqL+1VwGNdUGrRr++8j8PtQQzvAVZUIMjKQ90fY689sEJZJBbZVw1rXaOKSTitkzPQ==","dev": true,"license": "Apache-2.0","dependencies": {- "playwright-core": "1.59.1"+ "playwright-core": "1.61.1"},"bin": {"playwright": "cli.js"@@ -7342,17 +7346,6 @@"fsevents": "2.3.2"}},- "node_modules/@playwright/test/node_modules/playwright-core": {- "version": "1.59.1",- "dev": true,- "license": "Apache-2.0",- "bin": {- "playwright-core": "cli.js"- },- "engines": {- "node": ">=18"- }- },"node_modules/@rollup/rollup-darwin-arm64": {"version": "4.52.4","cpu": [@@ -10883,25 +10876,10 @@"node": ">=4.0.0"}},- "node_modules/playwright": {- "version": "1.58.2",- "dev": true,- "license": "Apache-2.0",- "dependencies": {- "playwright-core": "1.58.2"- },- "bin": {- "playwright": "cli.js"- },- "engines": {- "node": ">=18"- },- "optionalDependencies": {- "fsevents": "2.3.2"- }- },"node_modules/playwright-core": {- "version": "1.58.2",+ "version": "1.61.1",+ "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.61.1.tgz",+ "integrity": "sha512-h7Qlt6m4REp25qvIdvbDtVmD4LqVXfpRxhORv9L0jzETM05p4fuPJ3dKyuSXQxDSbXnmS79HAgi9589lGSpLkg==","dev": true,"license": "Apache-2.0","bin": {diff --git a/apps/desktop/package.json b/apps/desktop/package.jsonindex 0081846eb..d53bddbc6 100644--- a/apps/desktop/package.json+++ b/apps/desktop/package.json@@ -54,7 +54,7 @@"zod": "3.24.3"},"devDependencies": {- "@playwright/test": "^1.58.2",+ "@playwright/test": "1.61.1","@streetwriters/kysely": "^0.27.4","@types/node": "22.15.3","@types/yargs": "^17.0.33",@@ -65,7 +65,7 @@"fkill": "^10.0.3","node-abi": "^4.5.0","node-gyp-build": "^4.8.4",- "playwright": "1.58.2",+ "playwright-core": "1.61.1","prebuildify": "^6.0.1","slugify": "1.6.6","tree-kill": "^1.2.2",@@ -86,7 +86,7 @@"bundle": "esbuild electron=./src/main.ts ./src/preload.ts --external:electron --external:fsevents --external:better-sqlite3-multiple-ciphers --external:sodium-native --bundle --outdir=./build --platform=node --tsconfig=tsconfig.json --define:MAC_APP_STORE=false --define:RELEASE=true","bundle:mas": "esbuild electron=./src/main.ts ./src/preload.ts --minify --external:electron --external:fsevents --bundle --outdir=./build --platform=node --tsconfig=tsconfig.json --define:MAC_APP_STORE=true --define:RELEASE=true","postinstall": "patch-package",- "test": "playwright test --tsconfig tsconfig.json"+ "test": "playwright test --tsconfig __tests__/tsconfig.json"},"author": {"name": "Streetwriters (Private) Limited",diff --git a/apps/desktop/patches/@playwright+test++playwright-core+1.61.1.patch b/apps/desktop/patches/@playwright+test++playwright-core+1.61.1.patchnew file mode 100644index 000000000..de736690f--- /dev/null+++ b/apps/desktop/patches/@playwright+test++playwright-core+1.61.1.patch@@ -0,0 +1,24 @@+diff --git a/node_modules/@playwright/test/node_modules/playwright-core/lib/coreBundle.js b/node_modules/@playwright/test/node_modules/playwright-core/lib/coreBundle.js+index 7d8468f..ab252ef 100644+--- a/node_modules/@playwright/test/node_modules/playwright-core/lib/coreBundle.js++++ b/node_modules/@playwright/test/node_modules/playwright-core/lib/coreBundle.js+@@ -16010,6 +16010,7 @@ var init_validator = __esm({+ args: tOptional(tArray(tString)),+ chromiumSandbox: tOptional(tBoolean),+ cwd: tOptional(tString),++ baseURL: tOptional(tString),+ env: tOptional(tArray(tType("NameValue"))),+ timeout: tFloat,+ acceptDownloads: tOptional(tEnum(["accept", "deny", "internal-browser-default"])),+diff --git a/node_modules/@playwright/test/node_modules/playwright-core/types/types.d.ts b/node_modules/@playwright/test/node_modules/playwright-core/types/types.d.ts+index 0bff9d3..d195697 100644+--- a/node_modules/@playwright/test/node_modules/playwright-core/types/types.d.ts++++ b/node_modules/@playwright/test/node_modules/playwright-core/types/types.d.ts+@@ -21813,6 +21813,7 @@ export interface Electron {+ * Additional arguments to pass to the application when launching. You typically pass the main script name here.+ */+ args?: Array<string>;++ baseURL?: string;++ /**+ * If specified, artifacts (traces, videos, downloads, HAR files, etc.) are saved into this directory. The directorydiff --git a/apps/desktop/patches/playwright-core+1.58.2.patch b/apps/desktop/patches/playwright-core+1.58.2.patchdeleted file mode 100644index 5622d9426..000000000--- a/apps/desktop/patches/playwright-core+1.58.2.patch+++ /dev/null@@ -1,24 +0,0 @@-diff --git a/node_modules/playwright-core/lib/protocol/validator.js b/node_modules/playwright-core/lib/protocol/validator.js-index b36c979..9e8ca15 100644---- a/node_modules/playwright-core/lib/protocol/validator.js-+++ b/node_modules/playwright-core/lib/protocol/validator.js-@@ -2536,6 +2536,7 @@ import_validatorPrimitives.scheme.ElectronLaunchParams = (0, import_validatorPri- executablePath: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString),- args: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tArray)(import_validatorPrimitives.tString)),- cwd: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString),-+ baseURL: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString),- env: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tArray)((0, import_validatorPrimitives.tType)("NameValue"))),- timeout: import_validatorPrimitives.tFloat,- acceptDownloads: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tEnum)(["accept", "deny", "internal-browser-default"])),-diff --git a/node_modules/playwright-core/types/types.d.ts b/node_modules/playwright-core/types/types.d.ts-index f6e6165..4efd4d4 100644---- a/node_modules/playwright-core/types/types.d.ts-+++ b/node_modules/playwright-core/types/types.d.ts-@@ -19233,6 +19233,7 @@ export interface Electron {- * Additional arguments to pass to the application when launching. You typically pass the main script name here.- */- args?: Array<string>;-+ baseURL?: string;-- /**- * Toggles bypassing page's Content-Security-Policy. Defaults to `false`.