mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-01 19:49:54 +02:00
web: move topic tests from notebook test suite
This commit is contained in:
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import { test, expect } from "@playwright/test";
|
||||
import { AppModel } from "./models/app.model";
|
||||
import { Item, Notebook } from "./models/types";
|
||||
import { Notebook } from "./models/types";
|
||||
import {
|
||||
groupByOptions,
|
||||
NOTE,
|
||||
@@ -70,26 +70,6 @@ test("edit a notebook", async ({ page }) => {
|
||||
expect(await editedNotebook?.getDescription()).toBe(item.description);
|
||||
});
|
||||
|
||||
test("edit topics individually", async ({ page }) => {
|
||||
const app = new AppModel(page);
|
||||
await app.goto();
|
||||
const notebooks = await app.goToNotebooks();
|
||||
const notebook = await notebooks.createNotebook(NOTEBOOK);
|
||||
const topics = await notebook?.openNotebook();
|
||||
|
||||
const editedTopics: Item[] = [];
|
||||
for (const title of NOTEBOOK.topics) {
|
||||
const topic = await topics?.findItem({ title });
|
||||
const editedTopic: Item = { title: `${title} (edited)` };
|
||||
await topic?.editItem(editedTopic);
|
||||
editedTopics.push(editedTopic);
|
||||
}
|
||||
|
||||
for (const topic of editedTopics) {
|
||||
expect(await topics?.findItem(topic)).toBeDefined();
|
||||
}
|
||||
});
|
||||
|
||||
test("delete a notebook", async ({ page }) => {
|
||||
const app = new AppModel(page);
|
||||
await app.goto();
|
||||
@@ -104,20 +84,6 @@ test("delete a notebook", async ({ page }) => {
|
||||
expect(await trash.findItem(NOTEBOOK.title)).toBeDefined();
|
||||
});
|
||||
|
||||
test("delete a topic", async ({ page }) => {
|
||||
const app = new AppModel(page);
|
||||
await app.goto();
|
||||
const notebooks = await app.goToNotebooks();
|
||||
const notebook = await notebooks.createNotebook(NOTEBOOK);
|
||||
const topics = await notebook?.openNotebook();
|
||||
const topic = await topics?.findItem({ title: NOTEBOOK.topics[0] });
|
||||
|
||||
await topic?.delete();
|
||||
|
||||
expect(await app.toasts.waitForToast("1 topic deleted")).toBe(true);
|
||||
expect(await topics?.findItem({ title: NOTEBOOK.topics[0] })).toBeUndefined();
|
||||
});
|
||||
|
||||
test("restore a notebook", async ({ page }) => {
|
||||
const app = new AppModel(page);
|
||||
await app.goto();
|
||||
@@ -199,37 +165,6 @@ test("remove shortcut of a notebook", async ({ page }) => {
|
||||
expect(allShortcuts.includes(NOTEBOOK.title)).toBeFalsy();
|
||||
});
|
||||
|
||||
test("create shortcut of a topic", async ({ page }) => {
|
||||
const app = new AppModel(page);
|
||||
await app.goto();
|
||||
const notebooks = await app.goToNotebooks();
|
||||
const notebook = await notebooks.createNotebook(NOTEBOOK);
|
||||
const topics = await notebook?.openNotebook();
|
||||
const topic = await topics?.findItem({ title: NOTEBOOK.topics[0] });
|
||||
|
||||
await topic?.createShortcut();
|
||||
|
||||
expect(await topic?.isShortcut()).toBe(true);
|
||||
const allShortcuts = await app.navigation.getShortcuts();
|
||||
expect(allShortcuts.includes(NOTEBOOK.topics[0])).toBeTruthy();
|
||||
});
|
||||
|
||||
test("remove shortcut of a topic", async ({ page }) => {
|
||||
const app = new AppModel(page);
|
||||
await app.goto();
|
||||
const notebooks = await app.goToNotebooks();
|
||||
const notebook = await notebooks.createNotebook(NOTEBOOK);
|
||||
const topics = await notebook?.openNotebook();
|
||||
const topic = await topics?.findItem({ title: NOTEBOOK.topics[0] });
|
||||
await topic?.createShortcut();
|
||||
|
||||
await topic?.removeShortcut();
|
||||
|
||||
expect(await topic?.isShortcut()).toBe(false);
|
||||
const allShortcuts = await app.navigation.getShortcuts();
|
||||
expect(allShortcuts.includes(NOTEBOOK.topics[0])).toBeFalsy();
|
||||
});
|
||||
|
||||
test(`sort notebooks`, async ({ page }, info) => {
|
||||
info.setTimeout(60 * 1000);
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import { test, expect } from "@playwright/test";
|
||||
import { AppModel } from "./models/app.model";
|
||||
import { Item } from "./models/types";
|
||||
import {
|
||||
groupByOptions,
|
||||
NOTEBOOK,
|
||||
@@ -26,6 +27,71 @@ import {
|
||||
orderByOptions
|
||||
} from "./utils";
|
||||
|
||||
test("create shortcut of a topic", async ({ page }) => {
|
||||
const app = new AppModel(page);
|
||||
await app.goto();
|
||||
const notebooks = await app.goToNotebooks();
|
||||
const notebook = await notebooks.createNotebook(NOTEBOOK);
|
||||
const topics = await notebook?.openNotebook();
|
||||
const topic = await topics?.findItem({ title: NOTEBOOK.topics[0] });
|
||||
|
||||
await topic?.createShortcut();
|
||||
|
||||
expect(await topic?.isShortcut()).toBe(true);
|
||||
const allShortcuts = await app.navigation.getShortcuts();
|
||||
expect(allShortcuts.includes(NOTEBOOK.topics[0])).toBeTruthy();
|
||||
});
|
||||
|
||||
test("remove shortcut of a topic", async ({ page }) => {
|
||||
const app = new AppModel(page);
|
||||
await app.goto();
|
||||
const notebooks = await app.goToNotebooks();
|
||||
const notebook = await notebooks.createNotebook(NOTEBOOK);
|
||||
const topics = await notebook?.openNotebook();
|
||||
const topic = await topics?.findItem({ title: NOTEBOOK.topics[0] });
|
||||
await topic?.createShortcut();
|
||||
|
||||
await topic?.removeShortcut();
|
||||
|
||||
expect(await topic?.isShortcut()).toBe(false);
|
||||
const allShortcuts = await app.navigation.getShortcuts();
|
||||
expect(allShortcuts.includes(NOTEBOOK.topics[0])).toBeFalsy();
|
||||
});
|
||||
|
||||
test("delete a topic", async ({ page }) => {
|
||||
const app = new AppModel(page);
|
||||
await app.goto();
|
||||
const notebooks = await app.goToNotebooks();
|
||||
const notebook = await notebooks.createNotebook(NOTEBOOK);
|
||||
const topics = await notebook?.openNotebook();
|
||||
const topic = await topics?.findItem({ title: NOTEBOOK.topics[0] });
|
||||
|
||||
await topic?.delete();
|
||||
|
||||
expect(await app.toasts.waitForToast("1 topic deleted")).toBe(true);
|
||||
expect(await topics?.findItem({ title: NOTEBOOK.topics[0] })).toBeUndefined();
|
||||
});
|
||||
|
||||
test("edit topics individually", async ({ page }) => {
|
||||
const app = new AppModel(page);
|
||||
await app.goto();
|
||||
const notebooks = await app.goToNotebooks();
|
||||
const notebook = await notebooks.createNotebook(NOTEBOOK);
|
||||
const topics = await notebook?.openNotebook();
|
||||
|
||||
const editedTopics: Item[] = [];
|
||||
for (const title of NOTEBOOK.topics) {
|
||||
const topic = await topics?.findItem({ title });
|
||||
const editedTopic: Item = { title: `${title} (edited)` };
|
||||
await topic?.editItem(editedTopic);
|
||||
editedTopics.push(editedTopic);
|
||||
}
|
||||
|
||||
for (const topic of editedTopics) {
|
||||
expect(await topics?.findItem(topic)).toBeDefined();
|
||||
}
|
||||
});
|
||||
|
||||
test(`sort topics`, async ({ page }, info) => {
|
||||
info.setTimeout(60 * 1000);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user