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

141 lines
4.1 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-03 03:35:01 +05:00
navigate,
tapById,
visibleByText,
createNote,
prepare,
visibleById,
notVisibleById,
2022-08-09 16:15:34 +05:00
sleep,
exitEditor,
2024-04-18 09:49:22 +05:00
tapByText,
elementByText,
elementById
} from "./utils";
2022-04-01 00:53:37 +05:00
describe("NOTE TESTS", () => {
it("Create a note in editor", async () => {
2022-04-01 00:53:37 +05:00
await prepare();
await createNote();
});
it("Open and close a note", async () => {
2022-04-01 00:53:37 +05:00
await prepare();
await createNote();
2024-04-18 09:49:22 +05:00
await tapById(notesnook.ids.note.get(0));
2022-08-09 16:15:34 +05:00
await exitEditor();
2022-04-01 00:53:37 +05:00
});
2024-04-18 09:49:22 +05:00
it.only("Notes properties should show", async () => {
2022-04-01 00:53:37 +05:00
await prepare();
let note = await createNote();
await tapById(notesnook.listitem.menu);
2024-04-18 09:49:22 +05:00
await waitFor(elementByText("Created at:")).toBeVisible().withTimeout(500);
2022-04-01 00:53:37 +05:00
});
it("Favorite and unfavorite a note", async () => {
2022-04-01 00:53:37 +05:00
await prepare();
let note = await createNote();
await tapById(notesnook.listitem.menu);
await tapById("icon-favorite");
await visibleById("icon-star");
await navigate("Favorites");
2022-04-01 00:53:37 +05:00
await visibleByText(note.body);
await sleep(500);
2022-04-01 00:53:37 +05:00
await tapById(notesnook.listitem.menu);
await tapById("icon-favorite");
2022-04-01 00:53:37 +05:00
await expect(element(by.text(note.body))).not.toBeVisible();
await navigate("Notes");
2022-04-01 00:53:37 +05:00
});
it("Pin a note to top", async () => {
2022-04-01 00:53:37 +05:00
await prepare();
await createNote();
await tapById(notesnook.listitem.menu);
await tapById("icon-pin");
await visibleByText("Pinned");
await visibleById("icon-pinned");
2022-04-01 00:53:37 +05:00
await tapById(notesnook.listitem.menu);
await tapById("icon-pin");
expect(element(by.id("icon-pinned"))).not.toBeVisible();
2022-04-01 00:53:37 +05:00
});
it("Pin a note in notifications", async () => {
2022-04-01 00:53:37 +05:00
await prepare();
await createNote();
await tapById(notesnook.listitem.menu);
await tapById("icon-pin-to-notifications");
await visibleByText("Unpin from notifications");
await sleep(500);
await tapById("icon-pin-to-notifications");
2022-04-01 00:53:37 +05:00
await sleep(500);
await visibleByText("Pin to notifications");
2022-04-01 00:53:37 +05:00
});
2023-09-01 16:22:18 +05:00
it("Copy note", async () => {
await prepare();
await createNote();
await tapById(notesnook.listitem.menu);
2024-04-18 09:49:22 +05:00
await sleep(1000);
await waitFor(elementById("icon-copy")).toBeVisible().withTimeout(500);
2023-11-27 16:33:09 +05:00
await tapById("icon-copy");
2022-04-01 00:53:37 +05:00
});
it("Assign colors to a note", async () => {
2022-04-03 03:35:01 +05:00
await prepare();
let note = await createNote();
await tapById(notesnook.listitem.menu);
2024-04-18 09:49:22 +05:00
await sleep(1000);
await tapByText("Add color");
await sleep(500);
await elementById("color-title-input").typeText("Test color");
await tapByText("Add color");
await sleep(3000);
await visibleById("icon-check");
2024-04-18 09:49:22 +05:00
await tapById("icon-color-#efefef");
await notVisibleById("icon-check");
2024-04-18 09:49:22 +05:00
await tapById("icon-color-#efefef");
2022-04-03 03:35:01 +05:00
await device.pressBack();
2024-04-18 09:49:22 +05:00
await navigate("Test color");
2022-04-03 03:35:01 +05:00
await visibleByText(note.body);
});
it("Delete & restore a note", async () => {
2022-04-01 00:53:37 +05:00
await prepare();
await createNote();
await tapById(notesnook.listitem.menu);
2024-04-18 09:49:22 +05:00
await sleep(500);
2023-04-18 01:54:51 +05:00
await tapById("icon-trash");
await navigate("Trash");
2023-04-18 01:54:51 +05:00
await sleep(500);
await tapById(notesnook.listitem.menu);
2024-04-18 09:49:22 +05:00
await sleep(500);
await tapByText("Restore note");
await device.pressBack();
2024-04-18 09:49:22 +05:00
await sleep(500);
await visibleByText(
"Test note description that is very long and should not fit in text."
);
2022-04-01 00:53:37 +05:00
});
});