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

227 lines
6.7 KiB
TypeScript
Raw Permalink Normal View History

2024-11-11 18:44:28 +05:00
/*
This file is part of the Notesnook project (https://notesnook.com/)
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/>.
*/
import { notesnook } from "../test.ids";
import { TestBuilder } from "./utils";
2024-11-11 18:44:28 +05:00
describe("NOTEBOOKS", () => {
it("Create a notebook with title only", async () => {
await TestBuilder.create()
.prepare()
.openSideMenu()
.waitAndTapById("tab-notebooks")
.waitAndTapById("sidebar-add-button")
.createNotebook("Notebook 1", false)
.wait(500)
.isVisibleByText("Notebook 1")
.run();
2024-11-11 18:44:28 +05:00
});
it("Create a notebook with title & description", async () => {
await TestBuilder.create()
.prepare()
.openSideMenu()
.waitAndTapById("tab-notebooks")
.waitAndTapById("sidebar-add-button")
.createNotebook("Notebook 1", true)
.wait(500)
.isVisibleByText("Notebook 1")
.run();
2024-11-11 18:44:28 +05:00
});
it("Add a sub notebook to a notebook", async () => {
await TestBuilder.create()
.prepare()
.openSideMenu()
.waitAndTapById("tab-notebooks")
.waitAndTapById("sidebar-add-button")
.createNotebook("Notebook 1", true)
.wait(500)
.longPressByText("Notebook 1")
.wait(500)
.waitAndTapByText("Add notebook")
.createNotebook("Sub notebook", true)
.wait(500)
.waitAndTapById("expand-notebook-0")
.isVisibleByText("Sub notebook")
.longPressByText("Sub notebook")
.wait(500)
.waitAndTapByText("Move to trash")
.waitAndTapByText("Delete")
.isNotVisibleByText("Sub notebook")
.run();
2024-11-11 18:44:28 +05:00
});
it("Edit notebook", async () => {
await TestBuilder.create()
.prepare()
.openSideMenu()
.waitAndTapById("tab-notebooks")
.waitAndTapById("sidebar-add-button")
.createNotebook("Notebook 1", true)
.wait(500)
.longPressByText("Notebook 1")
.wait(500)
.waitAndTapByText("Edit notebook")
.typeTextById(notesnook.ids.dialogs.notebook.inputs.title, " (edited)")
.waitAndTapByText("Save")
.isVisibleByText("Notebook 1 (edited)")
.run();
2024-11-11 18:44:28 +05:00
});
it("Edit a sub notebook", async () => {
await TestBuilder.create()
.prepare()
.openSideMenu()
.waitAndTapById("tab-notebooks")
.waitAndTapById("sidebar-add-button")
.createNotebook("Notebook 1", true)
.wait(500)
.longPressByText("Notebook 1")
.wait(500)
.waitAndTapByText("Add notebook")
.createNotebook("Sub notebook", true)
.wait(500)
.waitAndTapById("expand-notebook-0")
.longPressByText("Sub notebook")
.wait(500)
.waitAndTapByText("Edit notebook")
.typeTextById(notesnook.ids.dialogs.notebook.inputs.title, " (edited)")
.waitAndTapByText("Save")
.isVisibleByText("Sub notebook (edited)")
.run();
2024-11-11 18:44:28 +05:00
});
it("Add a note to notebook", async () => {
await TestBuilder.create()
.prepare()
.openSideMenu()
.waitAndTapById("tab-notebooks")
.waitAndTapById("sidebar-add-button")
.createNotebook("Notebook 1", true)
.wait(500)
.waitAndTapByText("Notebook 1")
.createNote()
.run();
2024-11-11 18:44:28 +05:00
});
it.only("Remove note from notebook", async () => {
await TestBuilder.create()
.prepare()
.openSideMenu()
.waitAndTapById("tab-notebooks")
.waitAndTapById("sidebar-add-button")
.createNotebook("Notebook 1", true)
.wait(500)
.waitAndTapByText("Notebook 1")
.wait(500)
.createNote()
.saveResult()
.processResult(async (note) => {
await TestBuilder.create()
.longPressByText(note.body)
.wait(500)
.waitAndTapById("select-minus")
.isNotVisibleById(note.title)
.run();
})
.run();
2024-11-11 18:44:28 +05:00
});
it("Add/Remove note to notebook from home", async () => {
await TestBuilder.create()
.prepare()
.openSideMenu()
.waitAndTapById("tab-notebooks")
.waitAndTapById("sidebar-add-button")
.createNotebook("Notebook 1", true)
.wait(500)
.waitAndTapById("tab-home")
.waitAndTapByText("Notes")
.createNote()
.waitAndTapById(notesnook.listitem.menu)
.wait(500)
.waitAndTapById("icon-notebooks")
.waitAndTapByText("Notebook 1")
.waitAndTapById("floating-save-button")
.isVisibleByText("Notebook 1")
.run();
2024-11-11 18:44:28 +05:00
});
it("Edit notebook title and description", async () => {
await TestBuilder.create()
.prepare()
.openSideMenu()
.waitAndTapById("tab-notebooks")
.waitAndTapById("sidebar-add-button")
.createNotebook()
.wait(500)
.isVisibleByText("Notebook 1")
.longPressByText("Notebook 1")
.wait(500)
.waitAndTapByText("Edit notebook")
.typeTextById(notesnook.ids.dialogs.notebook.inputs.title, " (Edited)")
.clearTextById(notesnook.ids.dialogs.notebook.inputs.description)
.typeTextById(
notesnook.ids.dialogs.notebook.inputs.description,
"Description of Notebook 1 (Edited)"
)
.waitAndTapByText("Save")
.isVisibleByText("Notebook 1 (Edited)")
.run();
2024-11-11 18:44:28 +05:00
});
2025-02-14 11:08:14 +05:00
it("Move notebook to trash", async () => {
await TestBuilder.create()
.prepare()
.openSideMenu()
.waitAndTapById("tab-notebooks")
.waitAndTapById("sidebar-add-button")
.createNotebook("Notebook 1", false)
.wait(500)
.isVisibleByText("Notebook 1")
.longPressByText("Notebook 1")
.wait(500)
.waitAndTapByText("Move to trash")
.waitAndTapByText("Delete")
.waitAndTapById("tab-home")
.waitAndTapByText("Trash")
.isVisibleByText("Notebook 1")
.run();
2024-11-11 18:44:28 +05:00
});
2025-02-14 11:08:14 +05:00
it("Pin notebook to side menu", async () => {
await TestBuilder.create()
.prepare()
.openSideMenu()
.waitAndTapById("tab-notebooks")
.waitAndTapById("sidebar-add-button")
.createNotebook("Notebook 1", false)
.wait(500)
.isVisibleByText("Notebook 1")
.longPressByText("Notebook 1")
.wait(500)
.waitAndTapById("icon-add-shortcut")
.wait(500)
.waitAndTapById("tab-home")
.isVisibleByText("Notebook 1")
.run();
2024-11-11 18:44:28 +05:00
});
});