Skip to content

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

mobile: update e2e tests for notebook

ammarahm-ed678684e24bfb
diff --git a/apps/mobile/app/components/dialog/dialog-header.tsx b/apps/mobile/app/components/dialog/dialog-header.tsx
index 788a392fc..6aee74027 100644
--- a/apps/mobile/app/components/dialog/dialog-header.tsx
+++ b/apps/mobile/app/components/dialog/dialog-header.tsx
@@ -41,7 +41,7 @@ type DialogHeaderProps = {
padding?: number;
centered?: boolean;
titlePart?: string;
- style: ViewStyle
+ style?: ViewStyle;
};
const DialogHeader = ({
diff --git a/apps/mobile/app/components/sheets/add-to/index.js b/apps/mobile/app/components/sheets/add-to/index.js
index 903ed17a0..40b352acb 100644
--- a/apps/mobile/app/components/sheets/add-to/index.js
+++ b/apps/mobile/app/components/sheets/add-to/index.js
@@ -250,24 +250,25 @@ const MoveNoteComponent = ({ note }) => {
const mergeState = {
[item.id]: state
};
- if (item.type === "topic") {
- const notebooks = db.notebooks.all;
- const notebook = notebooks.find((n) => n.id === item.notebookId);
- const intermediate = notebook.topics.some((topic) => {
- return topic.id === item.id
- ? state === "selected"
- : itemState[topic.id] === "selected";
- });
- if (intermediate) mergeState[notebook.id] = "intermediate";
- const selected = notebook.topics.every((topic) => {
- return topic.id === item.id
- ? state === "selected"
- : itemState[topic.id] === "selected";
- });
- if (selected) mergeState[notebook.id] = "selected";
+ const notebooks = db.notebooks.all;
+ const notebook =
+ item.type === "notebook"
+ ? item
+ : notebooks.find((n) => n.id === item.notebookId);
+ const intermediate = notebook.topics.some((topic) => {
+ return topic.id === item.id
+ ? state === "selected"
+ : itemState[topic.id] === "selected";
+ });
+ if (intermediate) mergeState[notebook.id] = "intermediate";
+ const selected = notebook.topics.every((topic) => {
+ return topic.id === item.id
+ ? state === "selected"
+ : itemState[topic.id] === "selected";
+ });
+ if (selected) mergeState[notebook.id] = "selected";
+ if (!selected && !intermediate) mergeState[notebook.id] = "deselected";
- if (!selected && !intermediate) mergeState[notebook.id] = "deselected";
- }
return {
...itemState,
...mergeState
diff --git a/apps/mobile/app/components/sheets/add-to/list-item.js b/apps/mobile/app/components/sheets/add-to/list-item.js
index 5ff1ff62e..32a9e7489 100644
--- a/apps/mobile/app/components/sheets/add-to/list-item.js
+++ b/apps/mobile/app/components/sheets/add-to/list-item.js
@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import React, { useState, useEffect } from "react";
+import React, { useState } from "react";
import { View } from "react-native";
import { useThemeStore } from "../../../stores/use-theme-store";
import { SIZE } from "../../../utils/size";
@@ -66,7 +66,6 @@ const _ListItem = ({
});
}
}
-
return (
<View
style={{
@@ -79,7 +78,7 @@ const _ListItem = ({
onPress={() => {
if (hasSubList) return setExpanded(!expanded);
if (enabled) return selectItem();
- onPress(item);
+ onPress?.(item);
}}
type={type}
onLongPress={() => {
@@ -128,8 +127,17 @@ const _ListItem = ({
}
selectItem();
if (enabled) return;
- onPress(item);
+ onPress?.(item);
}}
+ testID={
+ removed
+ ? "close-circle-outline"
+ : isSelected
+ ? "check-circle-outline"
+ : intermediate
+ ? "minus-circle-outline"
+ : "checkbox-blank-circle-outline"
+ }
name={
removed
? "close-circle-outline"
@@ -163,6 +171,7 @@ const _ListItem = ({
{onAddSublistItem ? (
<IconButton
name={"plus"}
+ testID="add-item-icon"
color={colors}
size={SIZE.xl}
onPress={() => {
diff --git a/apps/mobile/app/screens/notebooks/index.tsx b/apps/mobile/app/screens/notebooks/index.tsx
index 975cda22e..b01ecc14b 100644
--- a/apps/mobile/app/screens/notebooks/index.tsx
+++ b/apps/mobile/app/screens/notebooks/index.tsx
@@ -30,6 +30,8 @@ import SearchService from "../../services/search";
import SettingsService from "../../services/settings";
import useNavigationStore from "../../stores/use-navigation-store";
import { useNotebookStore } from "../../stores/use-notebook-store";
+import { Config } from "react-native-config";
+
const onPressFloatingButton = () => {
AddNotebookEvent();
};
@@ -68,7 +70,7 @@ export const Notebooks = ({
SearchService.prepareSearch = prepareSearch;
useNavigationStore.getState().setButtonAction(onPressFloatingButton);
//@ts-ignore need to update typings in core to fix this
- if (db.notebooks.all.length === 0) {
+ if (db.notebooks.all.length === 0 && !Config.isTesting) {
Walkthrough.present("notebooks");
} else {
Walkthrough.update("notebooks");
diff --git a/apps/mobile/e2e/tests/notebook.e2e.js b/apps/mobile/e2e/tests/notebook.e2e.js
index bcfedc60e..c140529ec 100644
--- a/apps/mobile/e2e/tests/notebook.e2e.js
+++ b/apps/mobile/e2e/tests/notebook.e2e.js
@@ -25,17 +25,18 @@ import {
tapByText,
createNote,
prepare,
- visibleById,
notVisibleById,
navigate,
elementByText,
- sleep
+ sleep,
+ notVisibleByText
} from "./utils";
async function createNotebook(
title = "Notebook 1",
description = true,
- topic = true
+ topic = true,
+ topicCount = 1
) {
await tapByText("Add your first notebook");
await elementById(notesnook.ids.dialogs.notebook.inputs.title).typeText(
@@ -47,10 +48,12 @@ async function createNotebook(
).typeText(`Description of ${title}`);
}
if (topic) {
- await elementById(notesnook.ids.dialogs.notebook.inputs.topic).typeText(
- "Topic"
- );
- await tapById("topic-add-button");
+ for (let i = 1; i <= topicCount; i++) {
+ await elementById(notesnook.ids.dialogs.notebook.inputs.topic).typeText(
+ i === 1 ? "Topic" : "Topic " + i
+ );
+ await tapById("topic-add-button");
+ }
}
await tapByText("Create notebook");
await sleep(500);
@@ -67,7 +70,7 @@ describe("NOTEBOOKS", () => {
it("Create a notebook with title only", async () => {
await prepare();
await navigate("Notebooks");
- await tapByText("Skip introduction");
+
await sleep(500);
await createNotebook("Notebook 1", false, false);
await sleep(500);
@@ -79,7 +82,7 @@ describe("NOTEBOOKS", () => {
it("Create a notebook title & description", async () => {
await prepare();
await navigate("Notebooks");
- await tapByText("Skip introduction");
+
await sleep(500);
await createNotebook("Notebook 1", true, false);
await sleep(500);
@@ -91,7 +94,6 @@ describe("NOTEBOOKS", () => {
it("Create a notebook with description and topics", async () => {
await prepare();
await navigate("Notebooks");
- await tapByText("Skip introduction");
await sleep(500);
await createNotebook("Notebook 1", false, false);
await sleep(500);
@@ -104,7 +106,6 @@ describe("NOTEBOOKS", () => {
await prepare();
let note = await createNote();
await navigate("Notebooks");
- await tapByText("Skip introduction");
await sleep(500);
await createNotebook("Notebook 1", true, true);
await sleep(500);
@@ -121,7 +122,6 @@ describe("NOTEBOOKS", () => {
it("Add new topic to notebook", async () => {
await prepare();
await navigate("Notebooks");
- await tapByText("Skip introduction");
await sleep(500);
await createNotebook("Notebook 1", true, false);
await sleep(500);
@@ -138,7 +138,6 @@ describe("NOTEBOOKS", () => {
it("Edit topic", async () => {
await prepare();
await navigate("Notebooks");
- await tapByText("Skip introduction");
await sleep(500);
await createNotebook("Notebook 1", true, true);
await sleep(500);
@@ -157,7 +156,6 @@ describe("NOTEBOOKS", () => {
it("Add new note to topic", async () => {
await prepare();
await navigate("Notebooks");
- await tapByText("Skip introduction");
await sleep(500);
await createNotebook("Notebook 1", true, true);
await sleep(500);
@@ -170,8 +168,6 @@ describe("NOTEBOOKS", () => {
it("Remove note from topic", async () => {
await prepare();
await navigate("Notebooks");
- await tapByText("Skip introduction");
- await sleep(500);
await createNotebook("Notebook 1", true, true);
await sleep(500);
await device.pressBack();
@@ -184,31 +180,59 @@ describe("NOTEBOOKS", () => {
await notVisibleById(note.title);
});
- it("Add/Remove note to notebook from home", async () => {
+ it.only("Add/Remove note to notebook from home", async () => {
await prepare();
await navigate("Notebooks");
- await tapByText("Skip introduction");
await sleep(500);
- await createNotebook("Notebook 1", true, true);
+ await createNotebook("Notebook 1", true, true, 3);
await sleep(500);
await device.pressBack();
await sleep(500);
await navigate("Notes");
await createNote();
+ console.log("ADD TO A SINGLE TOPIC");
await tapById(notesnook.listitem.menu);
await tapById("icon-Add to notebook");
await sleep(500);
await tapByText("Notebook 1");
await tapByText("Topic");
- await visibleById("icon-check");
- await tapByText("Topic");
- await notVisibleById("icon-check");
+ await tapByText("Save");
+ await sleep(300);
+ await visibleByText("Notebook 1 › Topic");
+ console.log("MOVE FROM ONE TOPIC TO ANOTHER");
+ await tapById(notesnook.listitem.menu);
+ await tapById("icon-Add to notebook");
+ await tapByText("Notebook 1");
+ await tapByText("Topic 2");
+ await tapByText("Save");
+ await visibleByText("Notebook 1 › Topic 2");
+ console.log("REMOVE FROM TOPIC");
+ await tapById(notesnook.listitem.menu);
+ await tapById("icon-Add to notebook");
+ await tapByText("Notebook 1");
+ await tapByText("Topic 2");
+ await tapByText("Save");
+ await sleep(300);
+ await notVisibleByText("Notebook 1 › Topic 2");
+ console.log("MOVE TO MULTIPLE TOPICS");
+ await tapById(notesnook.listitem.menu);
+ await tapById("icon-Add to notebook");
+ await tapByText("Notebook 1");
+ await elementByText("Topic").longPress();
+ await visibleByText("Reset selection");
+ await tapByText("Topic 2");
+ await tapByText("Topic 3");
+ await tapByText("Save");
+ await sleep(300);
+ await tapById(notesnook.listitem.menu);
+ await visibleByText("Topic");
+ await visibleByText("Topic 2");
+ await visibleByText("Topic 3");
});
it("Edit notebook title, description and add a topic", async () => {
await prepare();
await navigate("Notebooks");
- await tapByText("Skip introduction");
await sleep(500);
await createNotebook();
await sleep(500);
@@ -241,7 +265,7 @@ describe("NOTEBOOKS", () => {
it("Move notebook to trash", async () => {
await prepare();
await navigate("Notebooks");
- await tapByText("Skip introduction");
+
await sleep(500);
await createNotebook("Notebook 1", false, false);
await sleep(500);
@@ -261,7 +285,7 @@ describe("NOTEBOOKS", () => {
await prepare();
let note = await createNote();
await navigate("Notebooks");
- await tapByText("Skip introduction");
+
await sleep(500);
await createNotebook("Notebook 1", false, true);
await sleep(500);
@@ -284,7 +308,7 @@ describe("NOTEBOOKS", () => {
await prepare();
let note = await createNote();
await navigate("Notebooks");
- await tapByText("Skip introduction");
+
await sleep(500);
await createNotebook("Notebook 1", false, true);
await sleep(500);
@@ -306,7 +330,7 @@ describe("NOTEBOOKS", () => {
it("Pin notebook to side menu", async () => {
await prepare();
await navigate("Notebooks");
- await tapByText("Skip introduction");
+
await sleep(500);
await createNotebook("Notebook 1", false, false);
await sleep(500);
@@ -323,7 +347,7 @@ describe("NOTEBOOKS", () => {
it("Pin topic to side menu", async () => {
await prepare();
await navigate("Notebooks");
- await tapByText("Skip introduction");
+
await sleep(500);
await createNotebook("Notebook 1");
await sleep(500);