2022-04-14 14:42:48 +02:00
|
|
|
import { Selector, t } from "testcafe";
|
|
|
|
|
|
|
|
export default class Page {
|
|
|
|
constructor() {
|
|
|
|
this.view = Selector("div.p-view-select");
|
|
|
|
this.camera = Selector("div.p-camera-select");
|
|
|
|
this.countries = Selector("div.p-countries-select");
|
|
|
|
this.time = Selector("div.p-time-select");
|
|
|
|
this.search1 = Selector("div.input-search input");
|
|
|
|
this.toolbarDescription = Selector(".v-card__text").nth(0);
|
2022-05-31 20:38:17 +02:00
|
|
|
this.toolbarTitle = Selector("#p-navigation div.v-toolbar__title");
|
|
|
|
this.toolbarSecondTitle = Selector("main.v-content div.v-toolbar__title");
|
2022-08-30 10:31:25 +02:00
|
|
|
this.openMobileToolbar = Selector("button.mobile-menu-trigger");
|
2022-04-14 14:42:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async checkToolbarActionAvailability(action, visible) {
|
2022-06-01 12:09:15 +02:00
|
|
|
if (
|
|
|
|
(t.browser.platform === "mobile") &
|
|
|
|
(action !== "edit") &
|
|
|
|
(action !== "share") &
|
|
|
|
(action !== "add") &
|
|
|
|
(action !== "show-all") &
|
|
|
|
(action !== "show-important")
|
|
|
|
) {
|
2022-05-31 20:38:17 +02:00
|
|
|
if (await this.openMobileToolbar.exists) {
|
|
|
|
await t.click(this.openMobileToolbar);
|
|
|
|
}
|
2022-08-30 15:58:47 +02:00
|
|
|
await this.checkMobileMenuActionAvailability(action, visible);
|
|
|
|
await t.click(Selector("#photoprism"), { offsetX: 1, offsetY: 1 });
|
2022-05-31 20:38:17 +02:00
|
|
|
} else if (visible) {
|
2022-04-19 18:00:37 +02:00
|
|
|
await t.expect(Selector("nav.v-toolbar button.action-" + action).visible).ok();
|
2022-04-14 14:42:48 +02:00
|
|
|
} else {
|
2022-04-19 18:00:37 +02:00
|
|
|
await t.expect(Selector("nav.v-toolbar button.action-" + action).visible).notOk();
|
2022-04-14 14:42:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-30 10:31:25 +02:00
|
|
|
async checkMobileMenuActionAvailability(action, visible) {
|
|
|
|
if (
|
|
|
|
(action !== "login") &
|
|
|
|
(action !== "logout") &
|
|
|
|
(action !== "reload") &
|
|
|
|
(action !== "logs") &
|
|
|
|
(action !== "upload") &
|
|
|
|
(action !== "settings")
|
|
|
|
) {
|
|
|
|
if (visible) {
|
|
|
|
await t.expect(Selector("#mobile-menu div.nav-" + action).visible).ok();
|
|
|
|
} else {
|
|
|
|
await t.expect(Selector("#mobile-menu div.nav-" + action).visible).notOk();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (visible) {
|
|
|
|
await t.expect(Selector("#mobile-menu a.nav-" + action).visible).ok();
|
|
|
|
} else {
|
|
|
|
await t.expect(Selector("#mobile-menu a.nav-" + action).visible).notOk();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async triggerMobileMenuAction(action) {
|
|
|
|
if (
|
|
|
|
(action !== "login") &
|
|
|
|
(action !== "logout") &
|
|
|
|
(action !== "reload") &
|
|
|
|
(action !== "logs") &
|
|
|
|
(action !== "upload") &
|
|
|
|
(action !== "settings")
|
|
|
|
) {
|
|
|
|
await t.click(Selector("#mobile-menu div.nav-" + action + " a"));
|
|
|
|
} else {
|
|
|
|
await t.click(Selector("#mobile-menu a.nav-" + action));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:42:48 +02:00
|
|
|
async triggerToolbarAction(action) {
|
2022-06-01 12:09:15 +02:00
|
|
|
if (
|
|
|
|
(t.browser.platform === "mobile") &
|
|
|
|
(action !== "edit") &
|
|
|
|
(action !== "share") &
|
|
|
|
(action !== "add") &
|
|
|
|
(action !== "show-all") &
|
|
|
|
(action !== "show-important")
|
|
|
|
) {
|
2022-05-31 20:38:17 +02:00
|
|
|
if (await this.openMobileToolbar.exists) {
|
|
|
|
await t.click(this.openMobileToolbar);
|
|
|
|
}
|
|
|
|
if (await this.openMobileToolbar.exists) {
|
|
|
|
await t.click(this.openMobileToolbar);
|
|
|
|
}
|
|
|
|
await t.click(Selector("button.nav-menu-" + action));
|
|
|
|
} else {
|
|
|
|
await t.click(Selector("nav.v-toolbar button.action-" + action));
|
|
|
|
}
|
2022-04-14 14:42:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async toggleFilterBar() {
|
|
|
|
await t.click(Selector("nav.page-toolbar button.action-expand-search"));
|
|
|
|
}
|
|
|
|
|
|
|
|
async search(term) {
|
|
|
|
await t.typeText(this.search1, term, { replace: true }).pressKey("enter");
|
|
|
|
}
|
|
|
|
|
|
|
|
async setFilter(filter, option) {
|
|
|
|
let filterSelector = "";
|
|
|
|
|
|
|
|
switch (filter) {
|
|
|
|
case "view":
|
|
|
|
filterSelector = "div.p-view-select";
|
|
|
|
break;
|
|
|
|
case "camera":
|
|
|
|
filterSelector = "div.p-camera-select";
|
|
|
|
break;
|
|
|
|
case "time":
|
|
|
|
filterSelector = "div.p-time-select";
|
|
|
|
break;
|
|
|
|
case "countries":
|
|
|
|
filterSelector = "div.p-countries-select";
|
|
|
|
break;
|
|
|
|
case "category":
|
2023-01-05 16:58:18 +01:00
|
|
|
filterSelector = "div.p-category-select";
|
2022-04-14 14:42:48 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
throw "unknown filter";
|
|
|
|
}
|
|
|
|
if (!(await Selector(filterSelector).visible)) {
|
|
|
|
await t.click(Selector(".p-expand-search"));
|
|
|
|
}
|
2022-11-03 17:29:45 +01:00
|
|
|
await t.click(filterSelector);
|
2022-04-14 14:42:48 +02:00
|
|
|
|
|
|
|
if (option) {
|
2022-11-03 17:29:45 +01:00
|
|
|
await t.click(Selector('div[role="listitem"]').withText(option));
|
2022-04-14 14:42:48 +02:00
|
|
|
} else {
|
2022-11-03 17:29:45 +01:00
|
|
|
await t.click(Selector('div[role="listitem"]').nth(1));
|
2022-04-14 14:42:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|