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
tests: use zx for running tests
thecodrr7d265db89466
diff --git a/apps/web/.env-cmdrc.js b/apps/web/.env-cmdrc.jsindex 688269709..7e610ecd7 100644--- a/apps/web/.env-cmdrc.js+++ b/apps/web/.env-cmdrc.js@@ -16,6 +16,7 @@ module.exports = {DEBUG: "pw:api",},silent: {+ REACT_APP_TEST: true,DISABLE_ESLINT_PLUGIN: "true",FAST_REFRESH: "false",BROWSER: "none",diff --git a/apps/web/__e2e__/notes.test.js b/apps/web/__e2e__/notes.test.jsindex aefa1c2f4..12abac03f 100644--- a/apps/web/__e2e__/notes.test.js+++ b/apps/web/__e2e__/notes.test.js@@ -130,8 +130,16 @@ async function addNoteToNotebook() {await page.click(List.new("notebook").atIndex(0).build());+ await page.click(getTestId("mnd-new-topic"));++ await page.type(getTestId("mnd-new-topic-title"), "Topic 1");++ await page.press(getTestId("mnd-new-topic-title"), "Enter");+await page.click(List.new("notebook").atIndex(0).topic(0).build());+ await page.click(getTestId("dialog-no"));+await expect(isToastPresent()).resolves.toBeTruthy();await navigateTo("notebooks");@@ -175,15 +183,15 @@ test.describe("run tests independently", () => {await checkNotePresence();});- // test.skip("add a note to notebook", async () => {- // const noteSelector = await createNoteAndCheckPresence();+ test("add a note to notebook", async () => {+ const noteSelector = await createNoteAndCheckPresence();- // await openContextMenu(noteSelector);+ await openContextMenu(noteSelector);- // await clickMenuItem("addtonotebook(s)");+ await clickMenuItem("addtonotebook(s)");- // await addNoteToNotebook();- // });+ await addNoteToNotebook();+ });test("favorite a note", async () => {const noteSelector = await createNoteAndCheckPresence();@@ -367,15 +375,15 @@ test.describe("run tests independently", () => {await checkNoteLocked(noteSelector);});- // test.skip("add a note to notebook from properties", async () => {- // await createNoteAndCheckPresence();+ test("add a note to notebook from properties", async () => {+ await createNoteAndCheckPresence();- // await page.click(getTestId("properties"));+ await page.click(getTestId("properties"));- // await page.click(getTestId("properties-add-to-nb"));+ await page.click(getTestId("properties-add-to-nb"));- // await addNoteToNotebook();- // });+ await addNoteToNotebook();+ });test("assign a color to note from properties", async () => {const noteSelector = await createNoteAndCheckPresence();diff --git a/apps/web/package.json b/apps/web/package.jsonindex 911825ab4..a8de9dfe9 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -52,8 +52,8 @@"@types/node-fetch": "^2.5.10","@types/quill": "^2.0.5","babel-eslint": "^10.1.0",- "concurrently": "^6.2.0","chalk": "^4.1.0",+ "concurrently": "^6.2.0","env-cmd": "^10.1.0","eslint": "^7.20.0","eslint-config-react-app": "^6.0.0",@@ -67,7 +67,8 @@"progress-bar-webpack-plugin": "^2.1.0","source-map-explorer": "^2.5.2","typescript": "^4.1.5",- "webpack-bundle-analyzer": "^4.4.0"+ "webpack-bundle-analyzer": "^4.4.0",+ "zx": "^2.0.0"},"scripts": {"start": "env-cmd -e all,dev,web react-scripts start",@@ -75,7 +76,7 @@"build:desktop": "env-cmd -e all,desktop react-scripts build","deploy": "./scripts/deploy.sh","debug": "env-cmd -e all,dev,web,silent react-scripts start",- "test": "node ./scripts/run-tests.js",+ "test": "yarn zx ./scripts/run-tests.mjs","test:debug": "env-cmd -e dev,debug,silent jest -c jest.e2e.config.js","eject": "react-scripts eject","update": "npm i @streetwriters/editor@latest @streetwriters/notesnook-core@latest @streetwriters/theme@latest",diff --git a/apps/web/scripts/run-tests.js b/apps/web/scripts/run-tests.jsdeleted file mode 100644index e3744cef0..000000000--- a/apps/web/scripts/run-tests.js+++ /dev/null@@ -1,38 +0,0 @@-const { spawn } = require("child_process");--const PORT = 3000;-function startServer() {- return new Promise((resolve) => {- const process = spawn("yarn", ["debug", "-p", PORT], {- detached: true,- stdio: "pipe",- });- process.stdout.on("data", (data) => {- const message = data.toString();- if (message.includes("create a production build, use yarn build."))- resolve(process);- });- });-}--function startTestRunner() {- return new Promise((resolve) => {- const process = spawn("yarn", ["playwright", "test"], {- detached: true,- stdio: "inherit",- });- process.on("close", () => resolve(process));- });-}--(async function () {- console.log("Starting server at port", PORT, "...");- const server = await startServer();-- console.log("Starting tests...");- const testRunner = await startTestRunner();-- console.log("All done.");- process.kill(-server.pid);- process.exit(testRunner.exitCode);-})();diff --git a/apps/web/scripts/run-tests.mjs b/apps/web/scripts/run-tests.mjsnew file mode 100644index 000000000..729589379--- /dev/null+++ b/apps/web/scripts/run-tests.mjs@@ -0,0 +1,15 @@+const { p, u, f } = argv;++const args = [];+if (u) args.push("-u");+if (f) args.push(f);++const res = $`yarn debug -p ${p || 3000}`;+res.stdout.on("data", async (data) => {+ const message = data.toString();+ if (message.includes("create a production build, use yarn build.")) {+ console.log("Running on", res.child.pid, process.pid, process.ppid);+ const testRes = await $`yarn playwright test ${args.join(" ")}`;+ process.exit(testRes.exitCode);+ }+});diff --git a/apps/web/src/common/index.js b/apps/web/src/common/index.jsindex d47c4f109..c8f25cd5e 100644--- a/apps/web/src/common/index.js+++ b/apps/web/src/common/index.js@@ -13,6 +13,7 @@ import { store as userstore } from "../stores/user-store";import { hashNavigate, getCurrentHash } from "../navigation";import { db } from "./db";import { sanitizeFilename } from "../utils/filename";+import { isTesting } from "../utils/platform";export const COLORS = {red: "#f44336",@@ -59,7 +60,7 @@ export const CREATE_BUTTON_MAP = {export async function introduceFeatures() {const hash = getCurrentHash().replace("#", "");- if (!!hash) return;+ if (!!hash || isTesting()) return;const features = ["monographs"];for (let feature of features) {if (!Config.get(`feature:${feature}`)) {diff --git a/apps/web/src/components/dialogs/move-note-dialog.js b/apps/web/src/components/dialogs/move-note-dialog.jsindex a9bfd4a50..d86685831 100644--- a/apps/web/src/components/dialogs/move-note-dialog.js+++ b/apps/web/src/components/dialogs/move-note-dialog.js@@ -130,6 +130,7 @@ class MoveDialog extends React.Component {action={currentOpenedIndex === index && (<Icon.Plus+ data-test-id="mnd-new-topic"size={20}onClick={(e) => {e.stopPropagation();diff --git a/apps/web/src/utils/platform.js b/apps/web/src/utils/platform.jsindex 4c6fda77d..4cea6391d 100644--- a/apps/web/src/utils/platform.js+++ b/apps/web/src/utils/platform.js@@ -24,3 +24,7 @@ export function getPlatform() {export function isDesktop() {return "api" in window;}++export function isTesting() {+ return !!process.env.REACT_APP_TEST;+}diff --git a/apps/web/test-results/notebooks-pin-a-notebook-Firefox/pinned-notebook-actual.png b/apps/web/test-results/notebooks-pin-a-notebook-Firefox/pinned-notebook-actual.pngdeleted file mode 100644index fe0326c93..000000000Binary files a/apps/web/test-results/notebooks-pin-a-notebook-Firefox/pinned-notebook-actual.png and /dev/null differdiff --git a/apps/web/test-results/notebooks-pin-a-notebook-Firefox/pinned-notebook-diff.png b/apps/web/test-results/notebooks-pin-a-notebook-Firefox/pinned-notebook-diff.pngdeleted file mode 100644index 2ba9c976d..000000000Binary files a/apps/web/test-results/notebooks-pin-a-notebook-Firefox/pinned-notebook-diff.png and /dev/null differdiff --git a/apps/web/test-results/notebooks-pin-a-notebook-Firefox/pinned-notebook-expected.png b/apps/web/test-results/notebooks-pin-a-notebook-Firefox/pinned-notebook-expected.pngdeleted file mode 100644index 43560607d..000000000Binary files a/apps/web/test-results/notebooks-pin-a-notebook-Firefox/pinned-notebook-expected.png and /dev/null differdiff --git a/apps/web/test-results/notebooks-pin-a-notebook-Firefox/test-failed-1.png b/apps/web/test-results/notebooks-pin-a-notebook-Firefox/test-failed-1.pngdeleted file mode 100644index 06c43129c..000000000Binary files a/apps/web/test-results/notebooks-pin-a-notebook-Firefox/test-failed-1.png and /dev/null differdiff --git a/apps/web/test-results/notebooks-pin-a-notebook-WebKit/pinned-notebook-actual.png b/apps/web/test-results/notebooks-pin-a-notebook-WebKit/pinned-notebook-actual.pngdeleted file mode 100644index b6e23fcf7..000000000Binary files a/apps/web/test-results/notebooks-pin-a-notebook-WebKit/pinned-notebook-actual.png and /dev/null differdiff --git a/apps/web/test-results/notebooks-pin-a-notebook-WebKit/pinned-notebook-diff.png b/apps/web/test-results/notebooks-pin-a-notebook-WebKit/pinned-notebook-diff.pngdeleted file mode 100644index aed4a25be..000000000Binary files a/apps/web/test-results/notebooks-pin-a-notebook-WebKit/pinned-notebook-diff.png and /dev/null differdiff --git a/apps/web/test-results/notebooks-pin-a-notebook-WebKit/pinned-notebook-expected.png b/apps/web/test-results/notebooks-pin-a-notebook-WebKit/pinned-notebook-expected.pngdeleted file mode 100644index a6d149c8f..000000000Binary files a/apps/web/test-results/notebooks-pin-a-notebook-WebKit/pinned-notebook-expected.png and /dev/null differdiff --git a/apps/web/test-results/notebooks-pin-a-notebook-WebKit/test-failed-1.png b/apps/web/test-results/notebooks-pin-a-notebook-WebKit/test-failed-1.pngdeleted file mode 100644index 71532c348..000000000Binary files a/apps/web/test-results/notebooks-pin-a-notebook-WebKit/test-failed-1.png and /dev/null differdiff --git a/apps/web/yarn.lock b/apps/web/yarn.lockindex f986ddbd2..47c1d0e94 100644--- a/apps/web/yarn.lock+++ b/apps/web/yarn.lock@@ -2271,6 +2271,13 @@resolved "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz"integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==+"@types/fs-extra@^9.0.11":+ version "9.0.12"+ resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-9.0.12.tgz#9b8f27973df8a7a3920e8461517ebf8a7d4fdfaf"+ integrity sha512-I+bsBr67CurCGnSenZZ7v94gd3tc3+Aj2taxMT4yu4ABLuOgOjeFxX3dokG24ztSRg5tnT00sL8BszO7gSMoIw==+ dependencies:+ "@types/node" "*"+"@types/glob@^7.1.1":version "7.1.3"resolved "https://registry.npmjs.org/@types/glob/-/glob-7.1.3.tgz"@@ -2333,6 +2340,11 @@resolved "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz"integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==+"@types/minimist@^1.2.1":+ version "1.2.2"+ resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.2.tgz#ee771e2ba4b3dc5b372935d549fd9617bf345b8c"+ integrity sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==+"@types/node-fetch@^2.5.10":version "2.5.10"resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.5.10.tgz#9b4d4a0425562f9fcea70b12cb3fcdd946ca8132"@@ -2346,6 +2358,11 @@resolved "https://registry.npmjs.org/@types/node/-/node-14.14.27.tgz"integrity sha512-Ecfmo4YDQPwuqTCl1yBxLV5ihKfRlkBmzUEDcfIRvDxOTGQEeikr317Ln7Gcv0tjA8dVgKI3rniqW2G1OyKDng==+"@types/node@^16.0":+ version "16.0.0"+ resolved "https://registry.yarnpkg.com/@types/node/-/node-16.0.0.tgz#067a6c49dc7a5c2412a505628e26902ae967bf6f"+ integrity sha512-TmCW5HoZ2o2/z2EYi109jLqIaPIi9y/lc2LmDCWzuCi35bcaQ+OtUh6nwBiFK7SOu25FAU5+YKdqFZUwtqGSdg==+"@types/normalize-package-data@^2.4.0":version "2.4.0"resolved "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz"@@ -3831,6 +3848,14 @@ chalk@^4.0.0, chalk@^4.1.0:ansi-styles "^4.1.0"supports-color "^7.1.0"+chalk@^4.1.1:+ version "4.1.1"+ resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.1.tgz#c80b3fab28bf6371e6863325eee67e618b77e6ad"+ integrity sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==+ dependencies:+ ansi-styles "^4.1.0"+ supports-color "^7.1.0"+char-regex@^1.0.2:version "1.0.2"resolved "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz"@@ -6008,6 +6033,15 @@ from2@^2.1.0:inherits "^2.0.1"readable-stream "^2.0.0"+fs-extra@^10.0.0:+ version "10.0.0"+ resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.0.0.tgz#9ff61b655dde53fb34a82df84bb214ce802e17c1"+ integrity sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==+ dependencies:+ graceful-fs "^4.2.0"+ jsonfile "^6.0.1"+ universalify "^2.0.0"+fs-extra@^7.0.0:version "7.0.1"resolved "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz"@@ -13152,3 +13186,18 @@ zustand@^3.3.1:version "3.3.1"resolved "https://registry.npmjs.org/zustand/-/zustand-3.3.1.tgz"integrity sha512-o0rgrBsi29nCkPHdhtkAHisCIlmRUoXOV+1AmDMeCgkGG0i5edFSpGU0KiZYBvFmBYycnck4Z07JsLYDjSET9g==++zx@^2.0.0:+ version "2.0.0"+ resolved "https://registry.yarnpkg.com/zx/-/zx-2.0.0.tgz#08b11222a26fd160e234552fd54bb486ec6e81b9"+ integrity sha512-OF8YvqseMMmtDaASqO+8+0/tJZvykLK0hX9YBAaRO9l7Hc+YjNKjpgJTjrmncgEURoyDr9Ln4r/qBtEuDNZstg==+ dependencies:+ "@types/fs-extra" "^9.0.11"+ "@types/minimist" "^1.2.1"+ "@types/node" "^16.0"+ "@types/node-fetch" "^2.5.10"+ chalk "^4.1.1"+ fs-extra "^10.0.0"+ minimist "^1.2.5"+ node-fetch "^2.6.1"+ which "^2.0.2"