web: fix all other failing tests

This commit is contained in:
Abdullah Atta
2023-01-14 11:21:21 +05:00
committed by Abdullah Atta
parent a74b910478
commit f254fc5c58
5 changed files with 14 additions and 6 deletions

View File

@@ -36,7 +36,14 @@ export class ItemModel extends BaseItemModel {
return new NotesViewModel(this.page, "notes");
}
async delete(deleteContainedNotes = false) {
async delete() {
await this.contextMenu.open(this.locator);
await this.contextMenu.clickOnItem("delete");
await this.waitFor("detached");
}
async deleteWithNotes(deleteContainedNotes = false) {
await this.contextMenu.open(this.locator);
await this.contextMenu.clickOnItem("delete");

View File

@@ -21,7 +21,6 @@ import { Locator, Page } from "@playwright/test";
import { getTestId } from "../utils";
import { BaseViewModel } from "./base-view.model";
import { ItemModel } from "./item.model";
import { SearchViewModel } from "./search-view-model";
import { Item } from "./types";
import { fillItemDialog } from "./utils";

View File

@@ -29,7 +29,9 @@ export class NotebooksViewModel extends BaseViewModel {
constructor(page: Page) {
super(page, "notebooks");
this.createButton = this.list.locator(getTestId("notebooks-action-button"));
this.createButton = page
.locator(getTestId("notebooks-action-button"))
.first();
}
async createNotebook(notebook: Notebook) {

View File

@@ -34,7 +34,7 @@ export class NotesViewModel extends BaseViewModel {
constructor(page: Page, pageId: "home" | "notes") {
super(page, pageId);
this.createButton = this.list.locator(getTestId("notes-action-button"));
this.createButton = page.locator(getTestId("notes-action-button"));
this.editor = new EditorModel(page);
}

View File

@@ -67,7 +67,7 @@ test("delete a topic", async ({ page }) => {
const topics = await notebook?.openNotebook();
const topic = await topics?.findItem({ title: NOTEBOOK.topics[0] });
await topic?.delete();
await topic?.deleteWithNotes();
expect(await app.toasts.waitForToast("1 topic deleted")).toBe(true);
expect(await topics?.findItem({ title: NOTEBOOK.topics[0] })).toBeUndefined();
@@ -109,7 +109,7 @@ test("delete all notes within a topic", async ({ page }) => {
}
await app.goBack();
await topic?.delete(true);
await topic?.deleteWithNotes(true);
notes = await app.goToNotes();
expect(await notes.isEmpty()).toBe(true);