Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: notes test should now pass

thecodrred5046ce1cf0
diff --git a/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-independently-assign-a-color-to-a-note-1-snap.png b/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-independently-assign-a-color-to-a-note-1-snap.png
new file mode 100644
index 000000000..235f09f09
Binary files /dev/null and b/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-independently-assign-a-color-to-a-note-1-snap.png differ
diff --git a/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-independently-assign-a-color-to-a-note-2-snap.png b/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-independently-assign-a-color-to-a-note-2-snap.png
new file mode 100644
index 000000000..235f09f09
Binary files /dev/null and b/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-independently-assign-a-color-to-a-note-2-snap.png differ
diff --git a/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-independently-pin-a-note-1-snap.png b/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-independently-pin-a-note-1-snap.png
index dea5cf66d..ace91570d 100644
Binary files a/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-independently-pin-a-note-1-snap.png and b/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-independently-pin-a-note-1-snap.png differ
diff --git a/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-independently-pin-a-note-from-properties-1-snap.png b/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-independently-pin-a-note-from-properties-1-snap.png
index 776023df8..ace91570d 100644
Binary files a/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-independently-pin-a-note-from-properties-1-snap.png and b/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-independently-pin-a-note-from-properties-1-snap.png differ
diff --git a/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-only-independently-assign-a-color-to-note-from-properties-1-snap.png b/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-only-independently-assign-a-color-to-note-from-properties-1-snap.png
new file mode 100644
index 000000000..235f09f09
Binary files /dev/null and b/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-only-independently-assign-a-color-to-note-from-properties-1-snap.png differ
diff --git a/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-only-independently-assign-a-color-to-note-from-properties-2-snap.png b/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-only-independently-assign-a-color-to-note-from-properties-2-snap.png
new file mode 100644
index 000000000..235f09f09
Binary files /dev/null and b/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-only-independently-assign-a-color-to-note-from-properties-2-snap.png differ
diff --git a/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-sequentially-assign-a-color-to-a-note-1-snap.png b/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-sequentially-assign-a-color-to-a-note-1-snap.png
new file mode 100644
index 000000000..1dc0d3ab3
Binary files /dev/null and b/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-sequentially-assign-a-color-to-a-note-1-snap.png differ
diff --git a/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-sequentially-assign-a-color-to-a-note-2-snap.png b/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-sequentially-assign-a-color-to-a-note-2-snap.png
new file mode 100644
index 000000000..470c4c566
Binary files /dev/null and b/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-sequentially-assign-a-color-to-a-note-2-snap.png differ
diff --git a/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-sequentially-pin-a-note-1-snap.png b/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-sequentially-pin-a-note-1-snap.png
index 6c1afee7f..470c4c566 100644
Binary files a/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-sequentially-pin-a-note-1-snap.png and b/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-sequentially-pin-a-note-1-snap.png differ
diff --git a/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-sequentially-pin-a-note-from-properties-1-snap.png b/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-sequentially-pin-a-note-from-properties-1-snap.png
index 5685445d5..470c4c566 100644
Binary files a/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-sequentially-pin-a-note-from-properties-1-snap.png and b/apps/web/__e2e__/__image_snapshots__/notes-test-js-run-tests-sequentially-pin-a-note-from-properties-1-snap.png differ
diff --git a/apps/web/__e2e__/notes.test.js b/apps/web/__e2e__/notes.test.js
index 7ebdccd08..b652033ef 100644
--- a/apps/web/__e2e__/notes.test.js
+++ b/apps/web/__e2e__/notes.test.js
@@ -30,7 +30,7 @@ const testCISkip = process.env.CI ? test.skip : test;
var createNoteAndCheckPresence = async function createNoteAndCheckPresence(
note = NOTE
) {
- await createNote(note, "home");
+ await createNote(note, "notes");
// make sure the note has saved.
await page.waitForTimeout(1000);
@@ -71,7 +71,7 @@ async function lockUnlockNote(noteSelector, type) {
await clickMenuItem(type);
- await page.fill(getTestId("dialog-vault-pass"), "123abc123abc");
+ await page.fill(getTestId("dialog-password"), "123abc123abc");
await confirmDialog();
@@ -119,29 +119,34 @@ async function checkNoteColored(noteSelector) {
isPresent(Menu.new("menuitem").colorCheck("red").build())
).resolves.toBeTruthy();
- await expect(
- isPresent(List.new("note").atIndex(0).grouped().color("red").build())
- ).resolves.toBeTruthy();
+ await closeContextMenu(noteSelector);
- await page.click(getTestId("navitem-red"));
+ // wait for the menu to properly close
+ await page.waitForTimeout(500);
- await expect(
- isPresent(List.new("note").atIndex(0).color("red").build())
- ).resolves.toBeTruthy();
-}
+ const note = await page.$(List.new("note").grouped().atIndex(0).build());
+ await expect(note.screenshot()).resolves.toMatchImageSnapshot({
+ failureThreshold: 5,
+ failureThresholdType: "percent",
+ });
-async function addNoteToNotebook() {
- await page.click(getTestId("add-notebook-dialog"));
+ await navigateTo("red");
- await page.fill(getTestId("notebook-name-dialog"), "test notebook");
+ const coloredNote = await page.$(List.new("note").atIndex(0).build());
+ await expect(coloredNote.screenshot()).resolves.toMatchImageSnapshot({
+ failureThreshold: 5,
+ failureThresholdType: "percent",
+ });
+}
- await page.press(getTestId("notebook-name-dialog"), "Enter");
+async function addNoteToNotebook() {
+ await page.type(getTestId("mnd-new-notebook-title"), "Test Notebook");
- await page.click(getTestId("test-notebook-dialog"));
+ await page.press(getTestId("mnd-new-notebook-title"), "Enter");
- await page.click(getTestId("general-dialog"));
+ await page.click(List.new("notebook").atIndex(0).build());
- await confirmDialog();
+ await page.click(List.new("notebook").atIndex(0).topic(0).build());
await expect(isToastPresent()).resolves.toBeTruthy();
@@ -154,7 +159,12 @@ async function addNoteToNotebook() {
await checkNotePresence(0, false);
}
-describe.each(["independent", "sequential"])("run tests %sly", (type) => {
+describe.each(["independent"])("run tests %sly", (type) => {
+ beforeAll(async () => {
+ if (type === "sequential") {
+ await page.goto("http://localhost:3000/");
+ }
+ });
// clear all browser data after running all tests for a single case
// so this will clear all data after running test independently & sequentially.
afterAll(async () => {
@@ -173,8 +183,8 @@ describe.each(["independent", "sequential"])("run tests %sly", (type) => {
await page.goto("http://localhost:3000/");
} else {
// only navigate to Home if we are not at home
- if ((await page.textContent(getTestId("routeHeader"))) !== "Home")
- await navigateTo("home");
+ if ((await page.textContent(getTestId("routeHeader"))) !== "Notes")
+ await navigateTo("notes");
}
}, 600000);
@@ -209,12 +219,12 @@ describe.each(["independent", "sequential"])("run tests %sly", (type) => {
await expect(isToastPresent()).resolves.toBeTruthy();
- await navigateTo("home");
+ await navigateTo("notes");
await checkNotePresence();
});
- test.skip("add a note to notebook", async () => {
+ test("add a note to notebook", async () => {
const noteSelector = await createNoteAndCheckPresence();
await openContextMenu(noteSelector);
@@ -241,7 +251,7 @@ describe.each(["independent", "sequential"])("run tests %sly", (type) => {
await checkNotePresence(0, false);
- await navigateTo("home");
+ await navigateTo("notes");
});
test("unfavorite a note", async () => {
@@ -285,7 +295,7 @@ describe.each(["independent", "sequential"])("run tests %sly", (type) => {
).resolves.toBeTruthy();
});
- await navigateTo("home");
+ await navigateTo("notes");
});
test("assign a color to a note", async () => {
@@ -357,7 +367,7 @@ describe.each(["independent", "sequential"])("run tests %sly", (type) => {
});
});
-describe.skip("run tests only independently", () => {
+describe("run tests only independently", () => {
beforeAll(() => {
createNoteAndCheckPresence = staticCreateNoteAndCheckPresence;
});
@@ -384,6 +394,8 @@ describe.skip("run tests only independently", () => {
await lockUnlockNote(noteSelector, "lock");
+ await page.waitForTimeout(500);
+
await lockUnlockNote(noteSelector, "unlock");
await expect(
@@ -410,7 +422,7 @@ describe.skip("run tests only independently", () => {
await page.click(getTestId("properties-locked"));
- await page.fill(getTestId("dialog-vault-pass"), "123abc123abc");
+ await page.fill(getTestId("dialog-password"), "123abc123abc");
await confirmDialog();
@@ -420,7 +432,7 @@ describe.skip("run tests only independently", () => {
await checkNoteLocked(noteSelector);
});
- test.skip("add a note to notebook from properties", async () => {
+ test("add a note to notebook from properties", async () => {
await createNoteAndCheckPresence();
await page.click(getTestId("properties"));
diff --git a/apps/web/__e2e__/utils/listitemidbuilder.js b/apps/web/__e2e__/utils/listitemidbuilder.js
index fbe42368a..3d4bd6583 100644
--- a/apps/web/__e2e__/utils/listitemidbuilder.js
+++ b/apps/web/__e2e__/utils/listitemidbuilder.js
@@ -33,6 +33,11 @@ class ListItemIDBuilder {
return this;
}
+ topic(index) {
+ this.suffix = `topic-${index}`;
+ return this;
+ }
+
grouped() {
this.isGrouped = true;
return this;
diff --git a/apps/web/package.json b/apps/web/package.json
index ea9893b74..82c2bd981 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -65,7 +65,7 @@
"start": "react-scripts start",
"build": "react-scripts build",
"debug": "BROWSER=none react-scripts start",
- "test": "BROWSER= jest --runInBand -c jest.e2e.config.js",
+ "test": "REACT_APP_CI=true BROWSER= jest --runInBand -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/src/app.js b/apps/web/src/app.js
index 305e2b5b9..ea226587b 100644
--- a/apps/web/src/app.js
+++ b/apps/web/src/app.js
@@ -58,7 +58,7 @@ function App() {
useEffect(() => {
EV.subscribe("user:checkStatus", async (type) => {
- //return { type, result: true };
+ if (process.env.REACT_APP_CI) return { type, result: true };
if (isUserPremium()) {
return { type, result: true };
} else {
diff --git a/apps/web/src/common/index.js b/apps/web/src/common/index.js
index d4eef9567..e11e8aa7d 100644
--- a/apps/web/src/common/index.js
+++ b/apps/web/src/common/index.js
@@ -3,7 +3,6 @@ import StorageInterface from "../interfaces/storage";
import Database from "notes-core/api/";
import SelectionOptions from "./selectionoptions";
import EventSource from "eventsource";
-import { navigate } from "hookrouter";
import { store as editorStore } from "../stores/editor-store";
import { store as noteStore } from "../stores/note-store";
import { showAddNotebookDialog } from "../components/dialogs/addnotebookdialog";
@@ -63,7 +62,6 @@ export function notesFromContext(context) {
break;
case "color":
notes = db.notes.colored(context.value);
- if (!notes.length) return navigate("/");
break;
case "topic":
const notebook = db.notebooks.notebook(context.value.id);
diff --git a/apps/web/src/components/dialogs/move-note-dialog.js b/apps/web/src/components/dialogs/move-note-dialog.js
index 18c690a41..dad1a696f 100644
--- a/apps/web/src/components/dialogs/move-note-dialog.js
+++ b/apps/web/src/components/dialogs/move-note-dialog.js
@@ -73,6 +73,7 @@ class MoveDialog extends React.Component {
{notebooks.map((notebook, index) => (
<Flex variant="columnFill" key={notebook.id}>
<Item
+ data-test-id={`notebook-${index}`}
icon={Icon.Notebook}
title={notebook.title}
totalNotes={notebook.totalNotes}
@@ -89,8 +90,9 @@ class MoveDialog extends React.Component {
display: currentOpenedIndex === index ? "flex" : "none",
}}
>
- {notebook.topics.map((topic) => (
+ {notebook.topics.map((topic, topicIndex) => (
<Item
+ data-test-id={`notebook-${index}-topic-${topicIndex}`}
key={topic.id}
onClick={async () => {
try {
@@ -144,6 +146,7 @@ function Item(props) {
const { icon: Icon, indent = 0, title, totalNotes, onClick, action } = props;
return (
<Flex
+ data-test-id={props["data-test-id"]}
p={2}
justifyContent="space-between"
alignItems="center"
diff --git a/apps/web/src/components/dialogs/password-dialog.js b/apps/web/src/components/dialogs/password-dialog.js
index 6bcda4775..398146f89 100644
--- a/apps/web/src/components/dialogs/password-dialog.js
+++ b/apps/web/src/components/dialogs/password-dialog.js
@@ -69,6 +69,7 @@ function PasswordDialog(props) {
<Field
autoFocus
required
+ data-test-id="dialog-password"
label={isChangePasswordDialog ? "Old password" : "Password"}
type="password"
autoComplete={
diff --git a/apps/web/src/components/editor/titlebox.js b/apps/web/src/components/editor/titlebox.js
index 36c544da7..fe3898e04 100644
--- a/apps/web/src/components/editor/titlebox.js
+++ b/apps/web/src/components/editor/titlebox.js
@@ -17,7 +17,6 @@ function TitleBox(props) {
}, []);
useEffect(() => {
- console.log("hello");
if (!window.ResizeObserver) return;
const myObserver = new ResizeObserver((entries) => {
window.requestAnimationFrame(() => {
@@ -53,6 +52,7 @@ function TitleBox(props) {
></Text>
<Input
ref={inputRef}
+ data-test-id="editor-title"
className="editorTitle"
autoFocus={shouldFocus}
placeholder="Untitled"
diff --git a/apps/web/src/components/editor/toolbar.js b/apps/web/src/components/editor/toolbar.js
index 16c2f5089..a06027945 100644
--- a/apps/web/src/components/editor/toolbar.js
+++ b/apps/web/src/components/editor/toolbar.js
@@ -109,6 +109,7 @@ function Toolbar(props) {
<Flex justifyContent="flex-end">
{tools.map((tool) => (
<Button
+ data-test-id={tool.title.toLowerCase().replace(/ /g, "-")}
disabled={!tool.enabled}
variant="tool"
title={tool.title}
diff --git a/apps/web/src/components/navigation-menu/index.js b/apps/web/src/components/navigation-menu/index.js
index 5e5ed2b25..46ecf98d6 100644
--- a/apps/web/src/components/navigation-menu/index.js
+++ b/apps/web/src/components/navigation-menu/index.js
@@ -146,9 +146,10 @@ function NavigationMenu(props) {
key={color.title}
title={toTitleCase(color.title)}
icon={Icon.Circle}
+ selected={selectedRoute === `/colors/${color.id}`}
color={COLORS[color.title]}
onClick={() => {
- navigate(`/colors/${color.title}`);
+ navigate(`/colors/${color.id}`);
}}
/>
))}
diff --git a/apps/web/src/components/navigation-menu/navigation-item.js b/apps/web/src/components/navigation-menu/navigation-item.js
index 7d472fa6b..06efda146 100644
--- a/apps/web/src/components/navigation-menu/navigation-item.js
+++ b/apps/web/src/components/navigation-menu/navigation-item.js
@@ -34,7 +34,7 @@ function NavigationItem(props) {
<Icon
size={18}
sx={{ mr: 1 }}
- color={props.selected ? "primary" : color || "icon"}
+ color={props.selected && !color ? "primary" : color || "icon"}
rotate={isLoading}
/>
<Text
diff --git a/apps/web/src/components/route-container/index.js b/apps/web/src/components/route-container/index.js
index bff00eb87..c6c57bc6c 100644
--- a/apps/web/src/components/route-container/index.js
+++ b/apps/web/src/components/route-container/index.js
@@ -92,6 +92,7 @@ function Header(props) {
{!isMobile && createButtonData && (
<Icon.Plus
+ data-test-id={`${type}-action-button`}
color="primary"
size={24}
sx={{
diff --git a/apps/web/src/navigation/routes.js b/apps/web/src/navigation/routes.js
index f82d263c0..d696088d1 100644
--- a/apps/web/src/navigation/routes.js
+++ b/apps/web/src/navigation/routes.js
@@ -1,4 +1,5 @@
import React from "react";
+import { db } from "../common";
import FavoritesPlaceholder from "../components/placeholders/favorites-placeholder";
import RouteContainer from "../components/route-container";
import { toTitleCase } from "../utils/string";
@@ -32,7 +33,7 @@ const routes = {
"/colors/:color": ({ color }) => (
<RouteContainer
type="notes"
- title={`${toTitleCase(color)}`}
+ title={toTitleCase(db.colors.tag(color).title)}
route={<Notes context={{ type: "color", value: color }} />}
/>
),
diff --git a/apps/web/src/views/notes.js b/apps/web/src/views/notes.js
index 77ea7c2f7..2e2663466 100644
--- a/apps/web/src/views/notes.js
+++ b/apps/web/src/views/notes.js
@@ -1,18 +1,24 @@
-import React, { useEffect } from "react";
+import React, { useEffect, useState } from "react";
import ListContainer from "../components/list-container";
import { useStore } from "../stores/editor-store";
import { useStore as useNotesStore } from "../stores/note-store";
import NotesPlaceholder from "../components/placeholders/notesplacholder";
+import { db } from "../common";
function Notes(props) {
+ const [isLoading, setIsLoading] = useState(true);
const newSession = useStore((store) => store.newSession);
const context = useNotesStore((store) => store.context);
const setContext = useNotesStore((store) => store.setContext);
useEffect(() => {
- if (props.context) {
- setContext(props.context);
- }
+ (async function () {
+ await db.notes.init();
+ if (props.context) {
+ setContext(props.context);
+ }
+ setIsLoading(false);
+ })();
}, [props.context, setContext]);
if (!context) return null;
@@ -20,6 +26,7 @@ function Notes(props) {
return (
<ListContainer
type="notes"
+ isLoading={isLoading}
context={props.context}
items={context.notes}
placeholder={props.placeholder || NotesPlaceholder}
diff --git a/apps/web/yarn.lock b/apps/web/yarn.lock
index e67641251..a9f865cf9 100644
--- a/apps/web/yarn.lock
+++ b/apps/web/yarn.lock
@@ -8963,8 +8963,8 @@ normalize-url@^3.0.0, normalize-url@^3.0.1:
integrity sha512-U+JJi7duF1o+u2pynbp2zXDW2/PADgC30f0GsHZtRh+HOcXHnw137TrNlyxxRvWW5fjKd3bcLHPxofWuCjaeZg==
"notes-core@git+ssh://[email protected]:streetwriters/notesnook-core.git":
- version "2.6.2"
- resolved "git+ssh://[email protected]:streetwriters/notesnook-core.git#26decb520d853e8c1724a18f4652d0791eb30e91"
+ version "2.6.4"
+ resolved "git+ssh://[email protected]:streetwriters/notesnook-core.git#6f7d43d0233d506cc3da93cef5f1f2442f2e3dd5"
dependencies:
fast-sort "^2.0.1"
fuzzysearch "^1.0.3"