photoprism/frontend/tests/acceptance/photos.js

481 lines
19 KiB
JavaScript
Raw Normal View History

2019-05-21 15:00:46 +00:00
import { Selector } from 'testcafe';
import testcafeconfig from './testcafeconfig';
import Page from "./page-model";
import { RequestLogger } from 'testcafe';
2019-05-21 15:00:46 +00:00
const logger = RequestLogger( /http:\/\/localhost:2342\/api\/v1\/photos*/ , {
logResponseHeaders: true,
logResponseBody: true
});
fixture `Test photos`
.page`${testcafeconfig.url}`
.requestHooks(logger);
2019-05-21 15:00:46 +00:00
const page = new Page();
//?search + filters --> oder search js
// raw file icon? live photo icon? - search for type look for icon --> do it in search test
//?views including fullscreen--> oder view js
//?upload + Later: delete--> oder nur in library?
//scroll to top
//download
//clipboard --> extra test needed or include in other tests done for private, archive
//TODO add part for video as well
/*test('#8 approve photo', async t => {
await page.openNav();
await t
.click(Selector('div.p-navigation-photos + div'))
.click(Selector('.p-navigation-review'));
logger.clear();
await page.search('type:image');
const request1 = await logger.requests[0].response.body;
const FirstPhoto = await Selector('div.p-photo').nth(0).getAttribute('data-uid');
await page.selectPhotoFromUID(FirstPhoto);
await page.editSelectedPhotos();
logger.clear();
await t
.click(Selector('button.p-photo-dialog-close'));
await t
.click(Selector('button.action-reload'));
const request12 = await logger.requests[0].response.body;
logger.clear();
await t
.expect(Selector('div').withAttribute('data-uid', FirstPhoto).visible).ok();
await page.editSelectedPhotos();
const request2 = await logger.requests[0].response.body;
logger.clear();
await t
.click(Selector('button.action-approve'))
.click(Selector('button.action-ok'));
const request3 = await logger.requests[0].response.body;
logger.clear();
await t
.click(Selector('button.action-reload'));
const request4 = await logger.requests[0].response.body;
logger.clear();
await t
.expect(Selector('div').withAttribute('data-uid', FirstPhoto).exists).notOk()
.click(Selector('.p-navigation-photos'));
const request5 = await logger.requests[0].response.body;
logger.clear();
await page.search('type:image');
const request6 = await logger.requests[0].response.body;
await t
.expect(Selector('div').withAttribute('data-uid', FirstPhoto).visible).ok();
});
//review - add/remove date to photo so that it appears in photos
test('#9 approve photo', async t => {
await page.openNav();
await t
.click(Selector('div.p-navigation-photos + div'))
.click(Selector('.p-navigation-review'));
logger.clear();
await page.search('type:image');
const request1 = await logger.requests[0].response.body;
const FirstPhoto = await Selector('div.p-photo').nth(0).getAttribute('data-uid');
await page.selectPhotoFromUID(FirstPhoto);
await page.editSelectedPhotos();
logger.clear();
2019-05-21 15:00:46 +00:00
await t
.click(Selector('button.p-photo-dialog-close'));
await t
.click(Selector('button.action-reload'));
const request12 = await logger.requests[0].response.body;
logger.clear();
await t
.expect(Selector('div').withAttribute('data-uid', FirstPhoto).visible).ok();
await page.editSelectedPhotos();
const request2 = await logger.requests[0].response.body;
logger.clear();
await t
.click(Selector('button.action-approve'))
.click(Selector('button.action-ok'));
const request3 = await logger.requests[0].response.body;
logger.clear();
await t
.click(Selector('button.action-reload'));
const request4 = await logger.requests[0].response.body;
logger.clear();
await t
.expect(Selector('div').withAttribute('data-uid', FirstPhoto).exists).notOk()
.click(Selector('.p-navigation-photos'));
const request5 = await logger.requests[0].response.body;
logger.clear();
await page.search('type:image');
const request6 = await logger.requests[0].response.body;
await t
.expect(Selector('div').withAttribute('data-uid', FirstPhoto).visible).ok();
});*/
//videos - play video
test('#1 like/dislike photo', async t => {
logger.clear();
const FirstLikeButton = await Selector('i.t-off').nth(0).parent(0).nth(0);
//const FirstPhoto = FirstLikeButton.parent('div.p-photo');
//const FirstPhoto = FirstLikeButton.parent(5);
//console.log(FirstPhoto);
const FirstPhotoUid = FirstLikeButton.getAttribute('class');
console.log('test');
console.log(FirstPhotoUid);
await t.click(Selector('.p-navigation-favorites'));
await t
.expect(Selector('div').withAttribute('data-uid', FirstPhotoUid).exists).notOk()
.click(Selector('.p-navigation-photos'));
logger.clear();
await page.search('favorite:false');
await page.likePhoto(FirstPhotoUid);
const request = await logger.requests[0].response.body;
logger.clear();
await t
.click(Selector('.action-reload'))
.expect(Selector('div').withAttribute('data-uid', FirstPhotoUid).exists).ok();
logger.clear();
2019-05-21 15:00:46 +00:00
await t
.click(Selector('.p-navigation-favorites'));
const request2 = await logger.requests[0].response.body;
logger.clear();
await t
.expect(Selector('div').withAttribute('data-uid', FirstPhotoUid).exists).ok()
.expect(Selector('div.v-image__image').visible).ok();
await page.dislikePhoto(FirstPhotoUid);
logger.clear();
await t.click(Selector('.action-reload'));
const request3 = await logger.requests[0].response.body;
await t
.expect(Selector('div').withAttribute('data-uid', FirstPhotoUid).exists).notOk();
});
/*test('#2 like/dislike video', async t => {
await t.click(Selector('.p-navigation-video'));
logger.clear();
await page.search('favorite:false');
const request1 = await logger.requests[0].response.body;
const FirstPhoto = await Selector('div.p-photo').nth(0).getAttribute('data-uid');
await t
.click(Selector('.p-navigation-favorites'))
.expect(Selector('div').withAttribute('data-uid', FirstPhoto).exists).notOk()
.click(Selector('.p-navigation-photos'));
await t.click(Selector('.p-navigation-video'));
logger.clear();
await page.search('favorite:false');
await page.likePhoto(FirstPhoto);
const request = await logger.requests[0].response.body;
logger.clear();
await t
.click(Selector('.action-reload'))
.expect(Selector('div').withAttribute('data-uid', FirstPhoto).exists).ok();
logger.clear();
await t
.click(Selector('.p-navigation-favorites'));
logger.clear();
await page.search('type:video');
const request2 = await logger.requests[0].response.body;
await t
.expect(Selector('div').withAttribute('data-uid', FirstPhoto).exists).ok()
.expect(Selector('div.v-image__image').visible).ok();
await page.dislikePhoto(FirstPhoto);
logger.clear();
await t.click(Selector('.action-reload'));
const request3 = await logger.requests[0].response.body;
await t
.expect(Selector('div').withAttribute('data-uid', FirstPhoto).exists).notOk();
});
test('#6 private/unprivate photo/video using clipboard and list', async t => {
logger.clear();
await t
.click(Selector('.p-navigation-photos'))
.click(Selector('.p-expand-search'));
logger.clear();
await page.setFilter('view', 'Mosaik');
const request0 = await logger.requests[0].response.body;
const FirstPhoto = await Selector('div.p-photo').nth(0).getAttribute('data-uid');
const SecondPhoto = await Selector('div.p-photo').nth(1).getAttribute('data-uid');
const ThirdPhoto = await Selector('div.p-photo').nth(2).getAttribute('data-uid');
await t
.click(Selector('.p-navigation-video'));
const request = await logger.requests[0].response.body;
const FirstVideo = await Selector('div.p-photo').nth(0).getAttribute('data-uid');
const SecondVideo = await Selector('div.p-photo').nth(1).getAttribute('data-uid');
await t.click(Selector('.p-navigation-private'));
const request1 = await logger.requests[0].response.body;
await t
.expect(Selector('div').withAttribute('data-uid', FirstPhoto).exists).notOk()
.expect(Selector('div').withAttribute('data-uid', SecondPhoto).exists).notOk()
.expect(Selector('div').withAttribute('data-uid', ThirdPhoto).exists).notOk()
.expect(Selector('div').withAttribute('data-uid', FirstVideo).exists).notOk()
.expect(Selector('div').withAttribute('data-uid', SecondVideo).exists).notOk()
.click(Selector('.p-navigation-photos'));
logger.clear();
await page.selectPhotoFromUID(FirstPhoto);
await page.selectPhotoFromUID(SecondPhoto);
await t
.click(Selector('button.p-photo-clipboard-menu'))
.click(Selector('button.p-photo-clipboard-private'));
logger.clear();
await page.setFilter('view', 'Liste');
const request12 = await logger.requests[0].response.body;
await t
.click(Selector('button.p-photo-private').withAttribute('data-uid', ThirdPhoto));
logger.clear();
await t
.click(Selector('.action-reload'));
const request2 = await logger.requests[0].response.body;
logger.clear();
await t
.expect(Selector('td').withAttribute('data-uid', FirstPhoto).exists).notOk()
.expect(Selector('td').withAttribute('data-uid', SecondPhoto).exists).notOk()
.expect(Selector('td').withAttribute('data-uid', ThirdPhoto).exists).notOk()
.click(Selector('.p-navigation-video'));
logger.clear();
await t
.click(Selector('button.p-photo-private').withAttribute('data-uid', SecondVideo));
await page.setFilter('view', 'Mosaik');
const request13 = await logger.requests[0].response.body;
logger.clear();
await page.selectPhotoFromUID(FirstVideo);
await t
.click(Selector('button.p-photo-clipboard-menu'))
.click(Selector('button.p-photo-clipboard-private'));
logger.clear();
await t
.click(Selector('.action-reload'));
const request3 = await logger.requests[0].response.body;
logger.clear();
await t
.expect(Selector('div').withAttribute('data-uid', FirstVideo).exists).notOk()
.expect(Selector('div').withAttribute('data-uid', SecondVideo).exists).notOk()
.click(Selector('.p-navigation-private'));
const request4 = await logger.requests[0].response.body;
logger.clear();
await t
.expect(Selector('div').withAttribute('data-uid', FirstPhoto).exists).ok()
.expect(Selector('div').withAttribute('data-uid', SecondPhoto).exists).ok()
.expect(Selector('div').withAttribute('data-uid', FirstVideo).exists).ok()
.expect(Selector('div').withAttribute('data-uid', SecondVideo).exists).ok();
await page.selectPhotoFromUID(FirstPhoto);
await page.selectPhotoFromUID(SecondPhoto);
await page.selectPhotoFromUID(FirstVideo);
await t
.click(Selector('button.p-photo-clipboard-menu'))
.click(Selector('button.p-photo-clipboard-private'));
await page.setFilter('view', 'Liste');
await t
.click(Selector('button.p-photo-private').withAttribute('data-uid', ThirdPhoto))
.click(Selector('button.p-photo-private').withAttribute('data-uid', SecondVideo));
await page.setFilter('view', 'Mosaik');
logger.clear();
await t.click(Selector('.action-reload'));
const request5 = await logger.requests[0].response.body;
logger.clear();
await t
.expect(Selector('div').withAttribute('data-uid', FirstPhoto).exists).notOk()
.expect(Selector('div').withAttribute('data-uid', SecondPhoto).exists).notOk()
.expect(Selector('div').withAttribute('data-uid', ThirdPhoto).exists).notOk()
.expect(Selector('div').withAttribute('data-uid', FirstVideo).exists).notOk()
.expect(Selector('div').withAttribute('data-uid', SecondVideo).exists).notOk()
.click(Selector('.p-navigation-photos'));
const request6 = await logger.requests[0].response.body;
logger.clear();
await t
.expect(Selector('div').withAttribute('data-uid', FirstPhoto).exists).ok()
.expect(Selector('div').withAttribute('data-uid', SecondPhoto).exists).ok()
.expect(Selector('div').withAttribute('data-uid', ThirdPhoto).exists).ok()
.click(Selector('.p-navigation-video'));
const request7 = await logger.requests[0].response.body;
logger.clear();
await t
.expect(Selector('div').withAttribute('data-uid', FirstVideo).exists).ok()
.expect(Selector('div').withAttribute('data-uid', SecondVideo).exists).ok();
});
test('#7 archive/restore video, photos, private photos and review photos using clipboard', async t => {
logger.clear();
await page.openNav();
await t
.click(Selector('.p-navigation-photos'))
.click(Selector('.p-expand-search'));
logger.clear();
await page.setFilter('view', 'Mosaik');
const request0 = await logger.requests[0].response.body;
const FirstPhoto = await Selector('div.p-photo').nth(0).getAttribute('data-uid');
const SecondPhoto = await Selector('div.p-photo').nth(1).getAttribute('data-uid');
await t
.click(Selector('.p-navigation-video'));
const request = await logger.requests[0].response.body;
const FirstVideo = await Selector('div.p-photo').nth(0).getAttribute('data-uid');
logger.clear();
await t
.click(Selector('.p-navigation-private'));
const request1 = await logger.requests[0].response.body;
const FirstPrivatePhoto = await Selector('div.p-photo').nth(0).getAttribute('data-uid');
logger.clear();
await t
.click(Selector('div.p-navigation-photos + div'))
.click(Selector('.p-navigation-review'));
const request2 = await logger.requests[0].response.body;
const FirstReviewPhoto = await Selector('div.p-photo').nth(0).getAttribute('data-uid');
logger.clear();
await t
.click(Selector('.p-navigation-archive'));
const request3 = await logger.requests[0].response.body;
logger.clear();
await t
.expect(Selector('div').withAttribute('data-uid', FirstPhoto).exists).notOk()
.expect(Selector('div').withAttribute('data-uid', SecondPhoto).exists).notOk()
.expect(Selector('div').withAttribute('data-uid', FirstVideo).exists).notOk()
.expect(Selector('div').withAttribute('data-uid', FirstPrivatePhoto).exists).notOk()
.expect(Selector('div').withAttribute('data-uid', FirstReviewPhoto).exists).notOk();
await t
.click(Selector('.p-navigation-video'));
const request4 = await logger.requests[0].response.body;
logger.clear();
await page.selectPhotoFromUID(FirstVideo);
await page.archiveSelectedPhotos();
logger.clear();
await t
.click(Selector('.action-reload'));
const request5 = await logger.requests[0].response.body;
logger.clear();
await t
.expect(Selector('div').withAttribute('data-uid', FirstVideo).exists).notOk()
.click(Selector('.p-navigation-photos'));
const request6 = await logger.requests[0].response.body;
logger.clear();
await page.selectPhotoFromUID(FirstPhoto);
await page.selectPhotoFromUID(SecondPhoto);
await page.archiveSelectedPhotos();
logger.clear();
await t
.click(Selector('.action-reload'));
const request7 = await logger.requests[0].response.body;
logger.clear();
await t
.expect(Selector('div').withAttribute('data-uid', FirstPhoto).exists).notOk()
.expect(Selector('div').withAttribute('data-uid', SecondPhoto).exists).notOk()
.click(Selector('.p-navigation-private'));
const request8 = await logger.requests[0].response.body;
logger.clear();
await page.selectPhotoFromUID(FirstPrivatePhoto);
await page.archiveSelectedPhotos();
logger.clear();
await t
.click(Selector('.action-reload'));
const request9 = await logger.requests[0].response.body;
logger.clear();
await t
.expect(Selector('div').withAttribute('data-uid', FirstPrivatePhoto).exists).notOk()
.click(Selector('.p-navigation-review'));
const request10 = await logger.requests[0].response.body;
logger.clear();
await page.selectPhotoFromUID(FirstReviewPhoto);
await page.archiveSelectedPhotos();
logger.clear();
await t
.click(Selector('.action-reload'));
const request11 = await logger.requests[0].response.body;
logger.clear();
await t
.expect(Selector('div').withAttribute('data-uid', FirstReviewPhoto).exists).notOk()
.click(Selector('.p-navigation-archive'));
const request12 = await logger.requests[0].response.body;
logger.clear();
await t
.expect(Selector('div').withAttribute('data-uid', FirstPhoto).exists).ok()
.expect(Selector('div').withAttribute('data-uid', SecondPhoto).exists).ok()
.expect(Selector('div').withAttribute('data-uid', FirstVideo).exists).ok()
.expect(Selector('div').withAttribute('data-uid', FirstPrivatePhoto).exists).ok()
.expect(Selector('div').withAttribute('data-uid', FirstReviewPhoto).exists).ok();
await page.selectPhotoFromUID(FirstPhoto);
await page.selectPhotoFromUID(SecondPhoto);
await page.selectPhotoFromUID(FirstVideo);
await page.selectPhotoFromUID(FirstPrivatePhoto);
await page.selectPhotoFromUID(FirstReviewPhoto);
await page.restoreSelectedPhotos();
logger.clear();
await t.click(Selector('.action-reload'));
const request13 = await logger.requests[0].response.body;
await t
.expect(Selector('div').withAttribute('data-uid', FirstPhoto).exists).notOk()
.expect(Selector('div').withAttribute('data-uid', SecondPhoto).exists).notOk()
.expect(Selector('div').withAttribute('data-uid', FirstVideo).exists).notOk()
.expect(Selector('div').withAttribute('data-uid', FirstPrivatePhoto).exists).notOk()
.expect(Selector('div').withAttribute('data-uid', FirstReviewPhoto).exists).notOk();
logger.clear();
await t
.click(Selector('.p-navigation-video'));
const request14 = await logger.requests[0].response.body;
logger.clear();
await t
.expect(Selector('div').withAttribute('data-uid', FirstVideo).exists).ok();
await t
.click(Selector('.p-navigation-photos'));
const request15 = await logger.requests[0].response.body;
logger.clear();
await t
.expect(Selector('div').withAttribute('data-uid', FirstPhoto).exists).ok()
.expect(Selector('div').withAttribute('data-uid', SecondPhoto).exists).ok();
await t
.click(Selector('.p-navigation-private'));
const request16 = await logger.requests[0].response.body;
logger.clear();
await t
.expect(Selector('div').withAttribute('data-uid', FirstPrivatePhoto).exists).ok();
await t
.click(Selector('.p-navigation-review'));
const request17 = await logger.requests[0].response.body;
logger.clear();
await t
.expect(Selector('div').withAttribute('data-uid', FirstReviewPhoto).exists).ok();
});*/
//open photoeditdialogue (multiple ways) + edit photo details
//change primary file
//navigate to places
//??Check count in navi gets updated --> gt/lt or matches count of images