Files
notesnook/apps/mobile/e2e/tests/note.e2e.ts
Ammar Ahmed 9aef8194f9 mobile: refactor e2e tests
Uses a builder pattern for writing tests to reduce code and simplify writing tests
2025-10-06 12:11:02 +05:00

134 lines
3.6 KiB
TypeScript

import { notesnook } from "../test.ids";
import { TestBuilder } from "./utils";
describe("NOTE TESTS", () => {
it("Create a note in editor", async () => {
await TestBuilder.create().prepare().createNote().run();
});
it("Open and close a note", async () => {
await TestBuilder.create()
.prepare()
.createNote()
.waitAndTapById(notesnook.ids.note.get(0))
.exitEditor()
.run();
});
it("Notes properties should show", async () => {
await TestBuilder.create()
.prepare()
.createNote()
.waitAndTapById(notesnook.listitem.menu)
.wait(500)
.isVisibleByText("Created at")
.run();
});
it("Favorite and unfavorite a note", async () => {
await TestBuilder.create()
.prepare()
.createNote()
.saveResult()
.waitAndTapById(notesnook.listitem.menu)
.wait(500)
.waitAndTapById("icon-favorite")
.pressBack()
.isVisibleById("icon-star")
.navigate("Favorites")
.processResult(async (note) => {
await TestBuilder.create()
.isVisibleByText(note.body)
.waitAndTapById(notesnook.listitem.menu)
.wait(500)
.waitAndTapById("icon-favorite")
.pressBack()
.isNotVisibleByText(note.body)
.navigate("Notes")
.run();
})
.run();
});
it("Pin a note to top", async () => {
await TestBuilder.create()
.prepare()
.createNote()
.waitAndTapById(notesnook.listitem.menu)
.wait(500)
.waitAndTapById("icon-pin")
.pressBack()
.isVisibleByText("PINNED")
.isVisibleById("icon-pinned")
.waitAndTapById(notesnook.listitem.menu)
.wait(500)
.waitAndTapById("icon-pin")
.pressBack()
.isNotVisibleByText("icon-pinned")
.run();
});
it.skip("Pin a note in notifications", async () => {
await TestBuilder.create()
.prepare()
.createNote()
.waitAndTapById(notesnook.listitem.menu)
.waitAndTapById("icon-pin-to-notifications")
.isVisibleByText("Unpin from notifications")
.waitAndTapById("icon-pin-to-notifications")
.isVisibleByText("Pin to notifications")
.run();
});
it("Copy note", async () => {
await TestBuilder.create()
.prepare()
.createNote()
.waitAndTapById(notesnook.listitem.menu)
.wait(500)
.isVisibleById("icon-copy")
.waitAndTapById("icon-copy")
.run();
});
it("Assign colors to a note", async () => {
await TestBuilder.create()
.prepare()
.createNote()
.saveResult()
.waitAndTapById(notesnook.listitem.menu)
.wait(500)
.waitAndTapByText("Add color")
.typeTextById("color-title-input", "Test color")
.waitAndTapByText("Add color")
.isVisibleById("icon-check")
.waitAndTapById("icon-color-#efefef")
.isNotVisibleById("icon-check")
.waitAndTapById("icon-color-#efefef")
.pressBack()
.navigate("Test color")
.processResult(async (note) => {
await TestBuilder.create().isVisibleByText(note.body).run();
})
.run();
});
it("Delete & restore a note", async () => {
await TestBuilder.create()
.prepare()
.createNote()
.waitAndTapById(notesnook.listitem.menu)
.wait(500)
.waitAndTapById("icon-trash")
.navigate("Trash")
.waitAndTapById(notesnook.listitem.menu)
.wait(500)
.waitAndTapByText("Restore")
.pressBack()
.isVisibleByText(
"Test note description that is very long and should not fit in text."
)
.run();
});
});