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
test: add test for note unlocking and editing
thecodrr96f61df68691
diff --git a/apps/web/__e2e__/notes.test.js b/apps/web/__e2e__/notes.test.jsindex ec631f83e..93dec90bd 100644--- a/apps/web/__e2e__/notes.test.js+++ b/apps/web/__e2e__/notes.test.js@@ -4,7 +4,14 @@/*** TODO: We are still not checking if toast appears on delete/restore or not.*/ const { test, expect } = require("@playwright/test");-const { getTestId, createNote, NOTE, downloadFile } = require("./utils");+const {+ getTestId,+ createNote,+ NOTE,+ downloadFile,+ PASSWORD,+ editNote,+} = require("./utils");const {navigateTo,clickMenuItem,@@ -66,13 +73,25 @@ async function lockUnlockNote(noteSelector, type) {await clickMenuItem(type);- await page.fill(getTestId("dialog-password"), "123abc123abc");+ await page.fill(getTestId("dialog-password"), PASSWORD);await confirmDialog();await expect(isToastPresent()).resolves.toBeTruthy();}+async function openLockedNote(noteSelector) {+ await page.click(noteSelector);++ await expect(page.textContent(getTestId("unlock-note-title"))).resolves.toBe(+ NOTE.title+ );++ await page.fill(getTestId("unlock-note-password"), PASSWORD);++ await page.click(getTestId("unlock-note-submit"));+}+async function checkNotePinned(noteSelector, pause) {await openContextMenu(noteSelector);@@ -392,7 +411,7 @@ test.describe("run tests independently", () => {await page.click(getTestId("properties-locked"));- await page.fill(getTestId("dialog-password"), "123abc123abc");+ await page.fill(getTestId("dialog-password"), PASSWORD);await confirmDialog();@@ -438,4 +457,28 @@ test.describe("run tests independently", () => {test(`export note as txt`, async () => await exportNote("txt"));test(`export note as md`, async () => await exportNote("md"));test(`export note as html`, async () => await exportNote("html"));++ test("unlock a note for editing", async () => {+ const content = "Edits 1 2 3 ";++ const noteSelector = await createNoteAndCheckPresence();++ await lockUnlockNote(noteSelector, "lock");++ await checkNoteLocked(noteSelector);++ await openLockedNote(noteSelector);++ await editNote(null, content);++ await page.waitForTimeout(1000);++ await openLockedNote(noteSelector);++ await page.waitForSelector(".mce-content-body");++ await expect(page.textContent(".mce-content-body")).resolves.toContain(+ `${content}${NOTE.content}`+ );+ });});diff --git a/apps/web/__e2e__/utils/index.js b/apps/web/__e2e__/utils/index.jsindex 0e9085816..f22ae159e 100644--- a/apps/web/__e2e__/utils/index.js+++ b/apps/web/__e2e__/utils/index.js@@ -12,6 +12,8 @@ const NOTE = {content: "This is " + "Test 1".repeat(10),};+const PASSWORD = "123abc123abc";+function getTestId(id) {return `[data-test-id="${id}"]`;}@@ -19,15 +21,19 @@ function getTestId(id) {async function createNote(note, actionButtonId) {await page.click(getTestId(actionButtonId + "-action-button"));+ await editNote(note.title, note.content);+}++async function editNote(title, content) {await page.waitForSelector(".mce-content-body");- await page.fill(getTestId("editor-title"), note.title);+ if (title) await page.fill(getTestId("editor-title"), title);await page.waitForTimeout(100);await page.focus(".mce-content-body");- await page.type(".mce-content-body", note.content);+ await page.type(".mce-content-body", content);}async function downloadFile(downloadActionSelector, encoding) {@@ -45,7 +51,9 @@ async function downloadFile(downloadActionSelector, encoding) {module.exports = {NOTE,NOTEBOOK,+ PASSWORD,getTestId,createNote,+ editNote,downloadFile,};diff --git a/apps/web/src/components/unlock/index.js b/apps/web/src/components/unlock/index.jsindex c67fff515..1adc52ec6 100644--- a/apps/web/src/components/unlock/index.js+++ b/apps/web/src/components/unlock/index.js@@ -59,8 +59,13 @@ function Unlock(props) {mx={2}><Flex justifyContent="center" alignItems="center">- <Text variant="heading" ml={2} fontSize={48}>- {note?.title}+ <Text+ data-test-id="unlock-note-title"+ variant="heading"+ ml={2}+ fontSize={48}+ >+ {note?.title || "Open note"}</Text></Flex><Text variant="body" color="gray" textAlign="center">@@ -68,6 +73,7 @@ function Unlock(props) {</Text><Fieldid="vaultPassword"+ data-test-id="unlock-note-password"inputRef={passwordRef}autoFocussx={{ mt: 2, width: ["95%", "95%", "50%"] }}@@ -98,6 +104,7 @@ function Unlock(props) {<Buttonmt={3}variant="primary"+ data-test-id="unlock-note-submit"disabled={isUnlocking}onClick={async () => {await submit();