Files
notesnook/apps/mobile/e2e/tests/notebook.e2e.js

367 lines
11 KiB
JavaScript
Raw Permalink Normal View History

/*
This file is part of the Notesnook project (https://notesnook.com/)
2023-01-16 13:44:52 +05:00
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2022-08-30 16:13:11 +05:00
import { notesnook } from "../test.ids";
import {
2022-04-01 00:53:37 +05:00
tapById,
elementById,
visibleByText,
tapByText,
createNote,
prepare,
notVisibleById,
navigate,
elementByText,
2023-02-13 12:11:08 +05:00
sleep,
2023-03-17 16:18:57 +05:00
notVisibleByText,
visibleById
} from "./utils";
2022-04-01 00:53:37 +05:00
async function createNotebook(
title = "Notebook 1",
description = true,
2023-02-13 12:11:08 +05:00
topic = true,
topicCount = 1
) {
await tapByText("Add your first notebook");
await elementById(notesnook.ids.dialogs.notebook.inputs.title).typeText(
title
);
2022-04-01 00:53:37 +05:00
if (description) {
await elementById(
notesnook.ids.dialogs.notebook.inputs.description
).typeText(`Description of ${title}`);
2022-04-01 00:53:37 +05:00
}
if (topic) {
2023-02-13 12:11:08 +05:00
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");
}
2022-04-01 00:53:37 +05:00
}
2023-04-18 01:54:51 +05:00
await tapByText("Save");
2022-04-01 00:53:37 +05:00
await sleep(500);
}
// async function addTopic(title = "Topic") {
// await tapById(notesnook.buttons.add);
// await elementById("input-title").typeText(title);
// await tapByText("Add");
// await sleep(500);
// }
2022-04-01 00:53:37 +05:00
describe("NOTEBOOKS", () => {
it("Create a notebook with title only", async () => {
2022-04-01 00:53:37 +05:00
await prepare();
await navigate("Notebooks");
2023-02-13 12:11:08 +05:00
2022-04-01 00:53:37 +05:00
await sleep(500);
await createNotebook("Notebook 1", false, false);
2022-08-09 18:13:12 +05:00
await sleep(500);
await device.pressBack();
2022-04-01 00:53:37 +05:00
await sleep(500);
await visibleByText("Notebook 1");
2022-04-01 00:53:37 +05:00
});
it("Create a notebook title & description", async () => {
2022-04-01 00:53:37 +05:00
await prepare();
await navigate("Notebooks");
2023-02-13 12:11:08 +05:00
2022-04-01 00:53:37 +05:00
await sleep(500);
await createNotebook("Notebook 1", true, false);
2022-08-09 18:13:12 +05:00
await sleep(500);
await device.pressBack();
2022-04-01 00:53:37 +05:00
await sleep(500);
await visibleByText("Notebook 1");
2022-04-01 00:53:37 +05:00
});
it("Create a notebook with description and topics", async () => {
2022-04-01 00:53:37 +05:00
await prepare();
await navigate("Notebooks");
2022-04-01 00:53:37 +05:00
await sleep(500);
await createNotebook("Notebook 1", false, false);
2022-08-09 18:13:12 +05:00
await sleep(500);
await device.pressBack();
2022-04-01 00:53:37 +05:00
await sleep(500);
await visibleByText("Notebook 1");
2022-04-01 00:53:37 +05:00
});
it("Create a notebook, add topic, move notes", async () => {
2022-04-01 00:53:37 +05:00
await prepare();
let note = await createNote();
await navigate("Notebooks");
2022-04-01 00:53:37 +05:00
await sleep(500);
await createNotebook("Notebook 1", true, true);
2022-08-09 18:13:12 +05:00
await sleep(500);
await tapByText("Topic");
2022-04-01 00:53:37 +05:00
await sleep(500);
await tapById("listitem.select");
await tapByText("Move selected notes");
2022-04-01 00:53:37 +05:00
await sleep(500);
await tapByText("Topic");
2022-04-01 00:53:37 +05:00
await sleep(500);
await visibleByText(note.body);
});
2023-04-18 01:54:51 +05:00
it.only("Add new topic to notebook", async () => {
2022-04-01 00:53:37 +05:00
await prepare();
await navigate("Notebooks");
2022-04-01 00:53:37 +05:00
await sleep(500);
await createNotebook("Notebook 1", true, false);
2022-08-09 18:13:12 +05:00
await sleep(500);
await device.pressBack();
2022-04-01 00:53:37 +05:00
await sleep(500);
await tapByText("Notebook 1");
2023-03-17 16:18:57 +05:00
await tapById("add-topic-button");
await elementById("input-title").typeText("Topic");
await tapByText("Add");
2022-04-01 00:53:37 +05:00
await sleep(500);
2023-04-18 01:54:51 +05:00
await tapByText("Topic");
2022-04-01 00:53:37 +05:00
});
it("Edit topic", async () => {
2022-04-01 00:53:37 +05:00
await prepare();
await navigate("Notebooks");
2022-04-01 00:53:37 +05:00
await sleep(500);
await createNotebook("Notebook 1", true, true);
2022-08-09 18:13:12 +05:00
await sleep(500);
await device.pressBack();
2022-04-01 00:53:37 +05:00
await sleep(500);
await tapByText("Notebook 1");
2022-04-01 00:53:37 +05:00
await sleep(300);
await tapById(notesnook.ids.notebook.menu);
await tapByText("Edit topic");
await elementById("input-title").typeText(" (edited)");
await tapByText("Save");
2022-04-01 00:53:37 +05:00
});
it("Add new note to topic", async () => {
2022-04-01 00:53:37 +05:00
await prepare();
await navigate("Notebooks");
2022-04-01 00:53:37 +05:00
await sleep(500);
await createNotebook("Notebook 1", true, true);
2022-08-09 18:13:12 +05:00
await sleep(500);
await device.pressBack();
2022-04-01 00:53:37 +05:00
await sleep(500);
await tapByText("Topic");
2022-04-01 00:53:37 +05:00
await createNote();
});
it("Remove note from topic", async () => {
2022-04-01 00:53:37 +05:00
await prepare();
await navigate("Notebooks");
await createNotebook("Notebook 1", true, true);
2022-08-09 18:13:12 +05:00
await sleep(500);
await device.pressBack();
2022-04-01 00:53:37 +05:00
await sleep(500);
await tapByText("Topic");
2022-04-01 00:53:37 +05:00
let note = await createNote();
await elementByText(note.body).longPress();
await tapById("select-minus");
2022-04-01 00:53:37 +05:00
await notVisibleById(note.title);
});
2023-03-17 16:18:57 +05:00
it("Add/Remove note to notebook from home", async () => {
2022-04-03 01:48:44 +05:00
await prepare();
await navigate("Notebooks");
2022-04-03 01:48:44 +05:00
await sleep(500);
2023-02-13 12:11:08 +05:00
await createNotebook("Notebook 1", true, true, 3);
2022-08-09 18:13:12 +05:00
await sleep(500);
await device.pressBack();
2022-04-03 01:48:44 +05:00
await sleep(500);
await navigate("Notes");
await createNote();
2023-02-13 12:11:08 +05:00
console.log("ADD TO A SINGLE TOPIC");
2022-04-03 01:48:44 +05:00
await tapById(notesnook.listitem.menu);
2023-03-17 16:18:57 +05:00
await tapById("icon-notebooks");
2022-04-03 01:48:44 +05:00
await sleep(500);
await tapByText("Notebook 1");
await tapByText("Topic");
2023-02-13 12:11:08 +05:00
await tapByText("Save");
await sleep(300);
2023-03-17 16:18:57 +05:00
await visibleByText("Topic");
2023-02-13 12:11:08 +05:00
console.log("MOVE FROM ONE TOPIC TO ANOTHER");
await tapById(notesnook.listitem.menu);
2023-03-17 16:18:57 +05:00
await tapById("icon-notebooks");
2023-02-13 12:11:08 +05:00
await tapByText("Notebook 1");
await tapByText("Topic 2");
await tapByText("Save");
2023-03-17 16:18:57 +05:00
await visibleByText("Topic 2");
2023-02-13 12:11:08 +05:00
console.log("REMOVE FROM TOPIC");
await tapById(notesnook.listitem.menu);
2023-03-17 16:18:57 +05:00
await tapById("icon-notebooks");
2023-02-13 12:11:08 +05:00
await tapByText("Notebook 1");
await tapByText("Topic 2");
await tapByText("Save");
await sleep(300);
2023-03-17 16:18:57 +05:00
await notVisibleByText("Topic 2");
2023-02-13 12:11:08 +05:00
console.log("MOVE TO MULTIPLE TOPICS");
await tapById(notesnook.listitem.menu);
2023-03-17 16:18:57 +05:00
await tapById("icon-notebooks");
2023-02-13 12:11:08 +05:00
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");
2022-04-03 01:48:44 +05:00
});
it("Edit notebook title, description and add a topic", async () => {
2022-04-03 01:48:44 +05:00
await prepare();
await navigate("Notebooks");
2022-04-03 01:48:44 +05:00
await sleep(500);
await createNotebook();
2022-08-09 18:13:12 +05:00
await sleep(500);
await device.pressBack();
2022-04-03 01:48:44 +05:00
await sleep(500);
await visibleByText("Notebook 1");
2022-04-03 01:48:44 +05:00
await tapById(notesnook.ids.notebook.menu);
await tapByText("Edit notebook");
2022-04-03 01:48:44 +05:00
await sleep(500);
await elementById(notesnook.ids.dialogs.notebook.inputs.title).typeText(
" (Edited)"
);
await elementById(
notesnook.ids.dialogs.notebook.inputs.description
).clearText();
await elementById(
notesnook.ids.dialogs.notebook.inputs.description
).typeText("Description of Notebook 1 (Edited)");
await elementById(notesnook.ids.dialogs.notebook.inputs.topic).typeText(
"Topic 2"
2022-04-03 01:48:44 +05:00
);
await tapById("topic-add-button");
2023-04-18 01:54:51 +05:00
await tapByText("Save");
2022-04-03 01:48:44 +05:00
await sleep(500);
await visibleByText("Notebook 1 (Edited)");
await visibleByText("Description of Notebook 1 (Edited)");
await visibleByText("Topic 2");
2022-04-03 01:48:44 +05:00
});
it("Move notebook to trash", async () => {
2022-04-03 01:48:44 +05:00
await prepare();
await navigate("Notebooks");
2023-02-13 12:11:08 +05:00
2022-04-03 01:48:44 +05:00
await sleep(500);
await createNotebook("Notebook 1", false, false);
2022-08-09 18:13:12 +05:00
await sleep(500);
await device.pressBack();
2022-04-03 01:48:44 +05:00
await sleep(500);
await visibleByText("Notebook 1");
2022-04-03 01:48:44 +05:00
await tapById(notesnook.ids.notebook.menu);
await tapByText("Move to trash");
2023-01-14 11:42:24 +05:00
await sleep(2000);
2023-04-18 01:54:51 +05:00
await tapByText("Delete");
2022-04-03 01:48:44 +05:00
await sleep(4000);
await navigate("Trash");
await visibleByText("Notebook 1");
2022-04-03 01:48:44 +05:00
});
2022-04-03 03:35:01 +05:00
2023-01-14 11:42:24 +05:00
it("Move notebook to trash with notes", async () => {
await prepare();
let note = await createNote();
await navigate("Notebooks");
2023-02-13 12:11:08 +05:00
2023-01-14 11:42:24 +05:00
await sleep(500);
await createNotebook("Notebook 1", false, true);
await sleep(500);
await tapByText("Topic");
await tapById("listitem.select");
await tapByText("Move selected notes");
await sleep(500);
await visibleByText("Notebook 1");
await tapById(notesnook.ids.notebook.menu);
await tapByText("Move to trash");
await sleep(2000);
2023-04-18 01:54:51 +05:00
await tapByText("Move all notes in this notebook to trash");
await sleep(500);
await tapByText("Delete");
2023-01-14 11:42:24 +05:00
await sleep(4000);
await navigate("Trash");
await visibleByText("Notebook 1");
await visibleByText(note.body);
});
it("Move Topic to trash with notes", async () => {
await prepare();
let note = await createNote();
await navigate("Notebooks");
2023-02-13 12:11:08 +05:00
2023-01-14 11:42:24 +05:00
await sleep(500);
await createNotebook("Notebook 1", false, true);
await sleep(500);
await tapByText("Topic");
await tapById("listitem.select");
await tapByText("Move selected notes");
await sleep(500);
await tapByText("Notebook 1");
await tapById(notesnook.ids.notebook.menu);
await tapByText("Delete topic");
await sleep(2000);
2023-04-18 01:54:51 +05:00
await tapByText("Move all notes in this topic to trash");
await sleep(500);
await tapByText("Delete");
2023-01-14 11:42:24 +05:00
await device.pressBack();
await sleep(4000);
await navigate("Trash");
await visibleByText(note.body);
});
it("Pin notebook to side menu", async () => {
2022-04-03 03:35:01 +05:00
await prepare();
await navigate("Notebooks");
2023-02-13 12:11:08 +05:00
2022-04-03 03:35:01 +05:00
await sleep(500);
await createNotebook("Notebook 1", false, false);
2022-08-09 18:13:12 +05:00
await sleep(500);
await device.pressBack();
2022-04-03 03:35:01 +05:00
await sleep(500);
await visibleByText("Notebook 1");
2022-04-03 03:35:01 +05:00
await tapById(notesnook.ids.notebook.menu);
await tapByText("Add Shortcut");
2022-04-03 03:35:01 +05:00
let menu = elementById(notesnook.ids.default.header.buttons.left);
await menu.tap();
await visibleByText("Notebook 1");
2022-04-03 03:35:01 +05:00
});
it("Pin topic to side menu", async () => {
2022-04-03 03:35:01 +05:00
await prepare();
await navigate("Notebooks");
2023-02-13 12:11:08 +05:00
2022-04-03 03:35:01 +05:00
await sleep(500);
await createNotebook("Notebook 1");
2022-08-09 18:13:12 +05:00
await sleep(500);
await device.pressBack();
2022-04-03 03:35:01 +05:00
await sleep(500);
await tapByText("Notebook 1");
2022-04-03 03:35:01 +05:00
await tapById(notesnook.ids.notebook.menu);
await tapByText("Add Shortcut");
2022-04-03 03:35:01 +05:00
let menu = elementById(notesnook.ids.default.header.buttons.left);
await menu.tap();
await menu.tap();
await visibleByText("Topic");
2022-04-03 03:35:01 +05:00
});
2022-04-01 00:53:37 +05:00
});