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
web: fix tests
Abdullah Attab44d2e5c9baa
diff --git a/apps/web/__e2e__/models/note-properties.model.ts b/apps/web/__e2e__/models/note-properties.model.tsindex b6cf49bc8..9e3f8e869 100644--- a/apps/web/__e2e__/models/note-properties.model.ts+++ b/apps/web/__e2e__/models/note-properties.model.ts@@ -28,6 +28,13 @@ import {fillPasswordDialog,iterateList} from "./utils";+import {+ FS,+ ZipReader,+ BlobReader,+ TextWriter,+ Uint8ArrayReader+} from "@zip.js/zip.js";abstract class BaseProperties {protected readonly page: Page;@@ -239,11 +246,19 @@ export class NoteContextMenuModel extends BaseProperties {await this.open();await this.menu.clickOnItem("export");- const content = await downloadAndReadFile(+ const zip = await downloadAndReadFile(this.noteLocator.page(),this.menu.getItem(format),- "utf-8"+ null);++ const entries = await new ZipReader(+ new Uint8ArrayReader(new Uint8Array(zip as Buffer))+ ).getEntries();+ const writer = new TextWriter();+ await entries[0].getData?.(writer);+ const content = await writer.getData();+if (format === "html") {return content.replace(/(name="created-at" content=")(.+?)"/, '$1xxx"')diff --git a/apps/web/__e2e__/notes.test.ts-snapshots/export-html-Chromium-win32.txt b/apps/web/__e2e__/notes.test.ts-snapshots/export-html-Chromium-win32.txtindex 443e18487..ed3cf07db 100644--- a/apps/web/__e2e__/notes.test.ts-snapshots/export-html-Chromium-win32.txt+++ b/apps/web/__e2e__/notes.test.ts-snapshots/export-html-Chromium-win32.txt@@ -17,12 +17,25 @@<link rel="stylesheet" href="https://app.notesnook.com/assets/editor-styles.css?d=0"><style>- img {- max-width: 100% !important;- height: auto !important;- border-radius: 5px;++ .image-container {+ display: block;}-+ .image-container.align-right {+ display: flex;+ justify-content: end;+ }+ .image-container.align-center {+ display: flex;+ justify-content: center;+ }+ .image-container.float {+ float: left;+ }+ .image-container.float.align-right {+ float: right;+ }+body {background-color: transparent !important;color: #202124;diff --git a/apps/web/__e2e__/utils/index.ts b/apps/web/__e2e__/utils/index.tsindex e40bedb2e..c1189b986 100644--- a/apps/web/__e2e__/utils/index.ts+++ b/apps/web/__e2e__/utils/index.ts@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.import fs from "fs";import dotenv from "dotenv";-import path from "path";+import path, { join } from "path";import { Locator, Page } from "@playwright/test";import {GroupByOptions,@@ -27,6 +27,7 @@ import {OrderByOptions,SortByOptions} from "../models/types";+import { tmpdir } from "os";type Note = {title: string;@@ -103,17 +104,22 @@ async function editNote(page: Page, note: Partial<Note>, noDelay = false) {async function downloadAndReadFile(page: Page,action: Locator,- encoding: BufferEncoding = "utf-8"+ encoding: BufferEncoding | null | undefined = "utf-8") {const [download] = await Promise.all([page.waitForEvent("download"),await action.click()]);- const path = await download.path();- if (!path) throw new Error("Download path not found.");+ const dir = fs.mkdtempSync(join(tmpdir(), "nntests_"));+ const filePath = join(dir, download.suggestedFilename());+ await download.saveAs(filePath);- return fs.readFileSync(path, { encoding });+ const content = fs.readFileSync(filePath, encoding);++ fs.rmSync(dir, { force: true, recursive: true });++ return content;}async function uploadFile(page: Page, action: Locator, filename: string) {diff --git a/apps/web/src/common/sqlite/wa-sqlite-kysely-driver.ts b/apps/web/src/common/sqlite/wa-sqlite-kysely-driver.tsindex 229dc04da..d6766ed65 100644--- a/apps/web/src/common/sqlite/wa-sqlite-kysely-driver.ts+++ b/apps/web/src/common/sqlite/wa-sqlite-kysely-driver.ts@@ -37,10 +37,10 @@ export class WaSqliteWorkerDriver implements Driver {private connection?: DatabaseConnection;private connectionMutex = new Mutex();private initializationMutex = new Mutex();- private readonly serviceName = `${this.config.dbName}-service`;+ private readonly serviceName;constructor(private readonly config: Config) {- console.log("new driver");+ this.serviceName = `${config.dbName}-service`;}async init(): Promise<void> {diff --git a/apps/web/src/dialogs/settings/index.tsx b/apps/web/src/dialogs/settings/index.tsxindex ee19d2720..59cda33f4 100644--- a/apps/web/src/dialogs/settings/index.tsx+++ b/apps/web/src/dialogs/settings/index.tsx@@ -53,7 +53,7 @@ import {import { ProfileSettings } from "./profile-settings";import { AuthenticationSettings } from "./auth-settings";import { useIsUserPremium } from "../../hooks/use-is-user-premium";-import { store as userstore } from "../../stores/user-store";+import { useStore as useUserStore } from "../../stores/user-store";import { SyncSettings } from "./sync-settings";import { BehaviourSettings } from "./behaviour-settings";import { DesktopIntegrationSettings } from "./desktop-integration-settings";@@ -87,19 +87,19 @@ const sectionGroups: SectionGroup[] = [key: "subscription",title: "Subscription",icon: Pro,- isHidden: () => !userstore.get().isLoggedIn+ isHidden: () => !useUserStore.getState().isLoggedIn},{key: "auth",title: "Authentication",icon: PasswordAndAuth,- isHidden: () => !userstore.get().isLoggedIn+ isHidden: () => !useUserStore.getState().isLoggedIn},{key: "sync",title: "Sync",icon: Sync,- isHidden: () => !userstore.get().isLoggedIn+ isHidden: () => !useUserStore.getState().isLoggedIn}]},@@ -231,6 +231,7 @@ type SettingsSideBarProps = { onNavigate: (settings: SettingsGroup[]) => void };function SettingsSideBar(props: SettingsSideBarProps) {const { onNavigate } = props;const [route, setRoute] = useState<SectionKeys>("profile");+ useUserStore((store) => store.isLoggedIn);return (<FlexScrollContainerdiff --git a/apps/web/src/index.html b/apps/web/src/index.htmlindex 2612c7107..1f89753cf 100644--- a/apps/web/src/index.html+++ b/apps/web/src/index.html@@ -183,7 +183,7 @@<!-- <script src="https://cdn.jsdelivr.net/npm/[email protected]/highlight.pack.min.js"></script>--><div id="root"></div>- <svg xmlns="http://www.w3.org/2000/svg">+ <svg xmlns="http://www.w3.org/2000/svg" style="display: none"><symbol id="themed-logo" viewBox="0 0 339 339"><defs><linearGradient