photoprism/frontend/tests/acceptance/originals.js

70 lines
2.9 KiB
JavaScript
Raw Normal View History

2020-06-03 08:42:56 +02:00
import { Selector } from 'testcafe';
import testcafeconfig from './testcafeconfig';
import Page from "./page-model";
fixture `Test files`
2020-06-04 18:25:29 +02:00
.page`${testcafeconfig.url}`;
2020-06-03 08:42:56 +02:00
const page = new Page();
2020-06-23 13:06:55 +02:00
test('#1 Add originals files to album', async t => {
2020-06-03 08:42:56 +02:00
await page.openNav();
await t.click(Selector('.nav-albums'));
2020-06-03 08:42:56 +02:00
await t
2020-06-03 13:06:06 +02:00
.typeText(Selector('.p-albums-search input'), 'KanadaVacation')
2020-06-03 08:42:56 +02:00
.pressKey('enter');
await t
.expect(Selector('h3').innerText).eql('Couldn\'t find anything');
2020-06-03 08:42:56 +02:00
await t
.click(Selector('div.nav-library + div'))
.click(Selector('.nav-originals'))
2020-06-03 13:06:06 +02:00
.click(Selector('button').withText('Vacation'));
const FirstItemInVacation = await Selector('div.p-photo-desc').nth(0).innerText;
const KanadaUid = await Selector('div.p-photo-desc').nth(0).getAttribute('data-uid');
const SecondItemInVacation = await Selector('div.p-photo-desc').nth(1).innerText;
2020-06-03 08:42:56 +02:00
await t
2020-06-03 13:06:06 +02:00
.expect(FirstItemInVacation).contains('Kanada')
.expect(SecondItemInVacation).contains('Korsika')
.click(Selector('button').withText('Kanada'));
2020-06-03 08:42:56 +02:00
const FirstItemInKanada = await Selector('div.p-photo-desc').nth(0).innerText;
const SecondItemInKanada = await Selector('div.p-photo-desc').nth(1).innerText;
2020-06-03 08:42:56 +02:00
await t
2020-06-03 13:06:06 +02:00
.expect(FirstItemInKanada).contains('BotanicalGarden')
.expect(SecondItemInKanada).contains('IMG')
.click(Selector('button').withText('BotanicalGarden'))
2020-06-05 18:03:22 +02:00
.click(Selector('a[href="/library/files/Vacation"]'));
2020-06-03 13:06:06 +02:00
await page.selectFromUID(KanadaUid);
2020-06-23 13:06:55 +02:00
const clipboardCount = await Selector('span.count-clipboard');
await t
.expect(clipboardCount.textContent).eql("1");
await page.addSelectedToAlbum('KanadaVacation');
2020-06-03 08:42:56 +02:00
await t
.click(Selector('.nav-albums'))
2020-06-03 13:06:06 +02:00
.typeText(Selector('.p-albums-search input'), 'KanadaVacation')
.pressKey('enter');
const AlbumUid = await Selector('div.p-album').nth(0).getAttribute('data-uid');
await t
.click(Selector('div.p-album').nth(0));
2020-06-03 08:42:56 +02:00
const PhotoCountAfterAdd = await Selector('div.p-photo').count;
await t
2020-06-03 13:06:06 +02:00
.expect(PhotoCountAfterAdd).eql(2)
.click(Selector('.nav-albums'));
2020-06-03 13:06:06 +02:00
await page.selectFromUID(AlbumUid);
2020-06-23 13:06:55 +02:00
await page.deleteSelected();
2020-06-03 13:06:06 +02:00
});
//TODO test download itself + clipboard count after download
2020-06-23 13:06:55 +02:00
test('#2 Download original files', async t => {
2020-06-03 13:06:06 +02:00
await page.openNav();
2020-06-03 08:42:56 +02:00
await t
.click(Selector('div.nav-library + div'))
.click(Selector('.nav-originals'));
2020-06-03 13:06:06 +02:00
const FirstFile = await Selector('div.p-file').nth(0).getAttribute('data-uid');
await page.selectFromUID(FirstFile);
2020-06-23 13:06:55 +02:00
const clipboardCount = await Selector('span.count-clipboard');
2020-06-03 08:42:56 +02:00
await t
2020-06-03 13:06:06 +02:00
.expect(clipboardCount.textContent).eql("1")
2020-06-23 13:06:55 +02:00
.click(Selector('button.action-menu'))
.expect(Selector('button.action-download').visible).ok();
2020-06-04 18:25:29 +02:00
});