/
BookPage.ts
54 lines (45 loc) · 1.95 KB
/
BookPage.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { AbstractPage } from "./AbstractPage";
interface FiltersProps {
author?: string | undefined;
title?: string | undefined;
condition?: string | undefined;
}
export class BookPage extends AbstractPage {
public async gotoList() {
await this.registerMock();
await this.page.goto("/admin");
await this.login();
await this.page.waitForURL(/\/admin#\/admin/);
await this.page.locator(".RaSidebar-fixed").getByText("Books").click();
return this.page;
}
public async getDefaultBook() {
return this.page.locator(".datagrid-body tr").filter({ hasText: "Hyperion" });
}
public async filter(filters: FiltersProps) {
if (filters.author) {
await this.page.getByLabel("Add filter").click();
await this.page.getByRole("menu").getByText("Author").waitFor({ state: "visible" });
await this.page.getByRole("menu").getByText("Author").click();
await this.page.getByRole("textbox", { name: "Author" }).fill(filters.author);
await this.page.waitForResponse(/\/books/);
}
if (filters.title) {
await this.page.getByLabel("Add filter").click();
await this.page.getByRole("menu").getByText("Title").waitFor({ state: "visible" });
await this.page.getByRole("menu").getByText("Title").click();
await this.page.getByRole("textbox", { name: "Title" }).fill(filters.title);
await this.page.waitForResponse(/\/books/);
}
if (filters.condition) {
await this.page.getByLabel("Add filter").click();
await this.page.getByRole("menu").getByText("Condition").waitFor({ state: "visible" });
await this.page.getByRole("menu").getByText("Condition").click();
await this.page.getByLabel("Condition").click();
await this.page.getByRole("listbox").getByText(filters.condition).waitFor({ state: "visible" });
await this.page.getByRole("listbox").getByText(filters.condition).click();
await this.page.waitForResponse(/\/books/);
}
return this.page;
}
}