2019-06-30 05:38:39 +02:00
|
|
|
import {Selector, t} from 'testcafe';
|
2019-05-20 18:51:59 +02:00
|
|
|
|
|
|
|
export default class Page {
|
|
|
|
constructor() {
|
2019-06-25 14:55:46 +02:00
|
|
|
this.view = Selector('div.p-view-select', {timeout: 15000});
|
|
|
|
this.camera = Selector('div.p-camera-select', {timeout: 15000});
|
|
|
|
this.countries = Selector('div.p-countries-select', {timeout: 15000});
|
|
|
|
this.time = Selector('div.p-time-select', {timeout: 15000});
|
2020-07-07 10:51:55 +02:00
|
|
|
this.search1 = Selector('div.input-search input', {timeout: 15000});
|
2019-05-20 18:51:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async setFilter(filter, option) {
|
2019-06-30 05:38:39 +02:00
|
|
|
let filterSelector = "";
|
2019-06-09 04:37:02 +02:00
|
|
|
|
2019-05-20 18:51:59 +02:00
|
|
|
switch (filter) {
|
|
|
|
case 'view':
|
2019-06-30 05:38:39 +02:00
|
|
|
filterSelector = 'div.p-view-select';
|
2019-05-20 18:51:59 +02:00
|
|
|
break;
|
|
|
|
case 'camera':
|
2019-06-30 05:38:39 +02:00
|
|
|
filterSelector = 'div.p-camera-select';
|
2019-05-20 18:51:59 +02:00
|
|
|
break;
|
|
|
|
case 'time':
|
2019-06-30 05:38:39 +02:00
|
|
|
filterSelector = 'div.p-time-select';
|
2019-05-20 18:51:59 +02:00
|
|
|
break;
|
|
|
|
case 'countries':
|
2019-06-30 05:38:39 +02:00
|
|
|
filterSelector = 'div.p-countries-select';
|
2019-05-20 18:51:59 +02:00
|
|
|
break;
|
|
|
|
default:
|
2019-06-30 05:38:39 +02:00
|
|
|
throw "unknown filter";
|
2019-05-20 18:51:59 +02:00
|
|
|
}
|
2019-06-30 05:38:39 +02:00
|
|
|
|
2019-05-20 18:51:59 +02:00
|
|
|
await t
|
2019-06-30 05:38:39 +02:00
|
|
|
.click(filterSelector, {timeout: 15000});
|
|
|
|
|
|
|
|
if (option) {
|
|
|
|
await t
|
2020-06-04 18:25:29 +02:00
|
|
|
.click(Selector('div[role="listitem"]').withText(option), {timeout: 15000})
|
2019-06-30 05:38:39 +02:00
|
|
|
} else {
|
|
|
|
await t
|
2020-06-04 18:25:29 +02:00
|
|
|
.click(Selector('div[role="listitem"]').nth(1), {timeout: 15000})
|
2019-06-30 05:38:39 +02:00
|
|
|
}
|
2019-05-20 18:51:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async search(term) {
|
|
|
|
await t
|
2020-06-02 13:07:18 +02:00
|
|
|
.typeText(this.search1, term, { replace: true })
|
2019-05-20 18:51:59 +02:00
|
|
|
.pressKey('enter')
|
|
|
|
}
|
|
|
|
|
|
|
|
async openNav() {
|
2020-07-06 10:57:20 +02:00
|
|
|
if (await Selector('button.nav-show').exists) {
|
2020-07-03 14:48:43 +02:00
|
|
|
await t.click(Selector('button.nav-show'));
|
|
|
|
} else if (await Selector('div.nav-expand').exists) {
|
|
|
|
await t.click(Selector('div.nav-expand i'));
|
2019-05-20 18:51:59 +02:00
|
|
|
}
|
|
|
|
}
|
2019-07-02 18:16:11 +02:00
|
|
|
|
2020-06-01 17:04:47 +02:00
|
|
|
async selectFromUID(uid) {
|
2020-05-28 10:01:11 +02:00
|
|
|
await t
|
|
|
|
.hover(Selector('div').withAttribute('data-uid', uid))
|
|
|
|
.click(Selector('.t-select.t-off'));
|
|
|
|
}
|
|
|
|
|
2020-06-01 17:04:47 +02:00
|
|
|
async unselectFromUID(uid) {
|
2020-05-28 18:00:54 +02:00
|
|
|
await t
|
|
|
|
.hover(Selector('div').withAttribute('data-uid', uid))
|
|
|
|
.click(Selector('.t-select.t-on'));
|
|
|
|
}
|
|
|
|
|
2020-05-28 10:01:11 +02:00
|
|
|
async selectNthPhoto(nPhoto) {
|
2019-07-02 18:16:11 +02:00
|
|
|
await t
|
2020-06-05 15:22:16 +02:00
|
|
|
.hover(Selector('.p-photo', {timeout:4000}).nth(nPhoto))
|
2019-12-10 19:56:32 +01:00
|
|
|
.click(Selector('.t-select.t-off'));
|
2019-07-02 18:16:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async unselectPhoto(nPhoto) {
|
|
|
|
await t
|
2020-06-05 15:22:16 +02:00
|
|
|
.hover(Selector('.p-photo', {timeout:4000}).nth(nPhoto))
|
2019-12-10 19:56:32 +01:00
|
|
|
.click(Selector('.t-select.t-on'));
|
2019-07-02 18:16:11 +02:00
|
|
|
}
|
|
|
|
|
2020-05-28 16:36:32 +02:00
|
|
|
async likePhoto(uid) {
|
2019-07-02 18:16:11 +02:00
|
|
|
await t
|
2020-05-28 18:00:54 +02:00
|
|
|
.click(Selector('.t-like.t-off').withAttribute('data-uid', uid));
|
2019-07-02 18:16:11 +02:00
|
|
|
}
|
2019-11-21 18:56:11 +01:00
|
|
|
|
2020-05-28 16:36:32 +02:00
|
|
|
async dislikePhoto(uid) {
|
|
|
|
await t
|
2020-05-28 18:00:54 +02:00
|
|
|
.click(Selector('.t-like.t-on').withAttribute('data-uid', uid));
|
2020-05-28 16:36:32 +02:00
|
|
|
}
|
|
|
|
|
2020-06-01 17:04:47 +02:00
|
|
|
async archiveSelected() {
|
2020-05-28 10:01:11 +02:00
|
|
|
await t
|
2020-06-23 13:06:55 +02:00
|
|
|
.click(Selector('button.action-menu'))
|
|
|
|
.click(Selector('button.action-archive'))
|
2020-07-03 14:48:43 +02:00
|
|
|
.click(Selector('button.action-confirm'));
|
2020-05-28 10:01:11 +02:00
|
|
|
}
|
|
|
|
|
2020-06-01 17:04:47 +02:00
|
|
|
async restoreSelected() {
|
2020-05-28 10:01:11 +02:00
|
|
|
await t
|
2020-06-23 13:06:55 +02:00
|
|
|
.click(Selector('button.action-menu'))
|
|
|
|
.click(Selector('button.action-restore'));
|
2020-05-28 10:01:11 +02:00
|
|
|
}
|
|
|
|
|
2020-06-01 17:04:47 +02:00
|
|
|
async editSelected() {
|
2020-06-23 13:06:55 +02:00
|
|
|
if (await Selector('button.action-edit').visible) {
|
|
|
|
await t.click(Selector('button.action-edit'));
|
|
|
|
} else if (await Selector('button.action-menu').exists) {
|
2020-05-28 18:00:54 +02:00
|
|
|
await t
|
2020-06-23 13:06:55 +02:00
|
|
|
.click(Selector('button.action-menu'))
|
|
|
|
.click(Selector('button.action-edit'));
|
2020-05-28 18:00:54 +02:00
|
|
|
}
|
2020-05-28 10:01:11 +02:00
|
|
|
}
|
|
|
|
|
2020-06-23 13:06:55 +02:00
|
|
|
async deleteSelected() {
|
2020-06-01 17:04:47 +02:00
|
|
|
await t
|
2020-06-23 13:06:55 +02:00
|
|
|
.click(Selector('button.action-menu'))
|
|
|
|
.click(Selector('button.action-delete'))
|
2020-07-03 14:48:43 +02:00
|
|
|
.click(Selector('button.action-confirm'));
|
2020-06-01 17:04:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async removeSelected() {
|
|
|
|
await t
|
2020-06-23 13:06:55 +02:00
|
|
|
.click(Selector('button.action-menu'))
|
|
|
|
.click(Selector('button.action-delete'));
|
2020-06-01 17:04:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async addSelectedToAlbum(name) {
|
|
|
|
await t
|
2020-06-23 13:06:55 +02:00
|
|
|
.click(Selector('button.action-menu'))
|
|
|
|
.click(Selector('button.action-album'))
|
2020-06-01 17:04:47 +02:00
|
|
|
.typeText(Selector('.input-album input'), name, { replace: true })
|
2020-06-23 13:06:55 +02:00
|
|
|
.pressKey('enter');
|
|
|
|
if (await Selector('div[role="listitem"]').withText(name).visible) {
|
|
|
|
await t.click(Selector('div[role="listitem"]').withText(name));
|
|
|
|
}
|
2020-07-03 14:48:43 +02:00
|
|
|
await t.click(Selector('button.action-confirm'));
|
2020-06-01 17:04:47 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 18:56:11 +01:00
|
|
|
async login(password) {
|
|
|
|
await t
|
|
|
|
.typeText(Selector('input[type="password"]'), password)
|
|
|
|
.pressKey('enter');
|
|
|
|
}
|
|
|
|
|
|
|
|
async logout() {
|
|
|
|
await t
|
2020-07-03 14:48:43 +02:00
|
|
|
.click(Selector('div.nav-logout'));
|
2019-11-21 18:56:11 +01:00
|
|
|
}
|
2019-05-20 18:51:59 +02:00
|
|
|
}
|