photoprism/frontend/tests/acceptance/files.js

89 lines
3.5 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";
import { RequestLogger } from 'testcafe';
const logger = RequestLogger( /http:\/\/localhost:2342\/api\/v1\/*/ , {
logResponseHeaders: true,
logResponseBody: true
});
fixture `Test files`
.page`${testcafeconfig.url}`
.requestHooks(logger);
const page = new Page();
test('#1 Add files to album', async t => {
logger.clear();
await page.openNav();
await t.click(Selector('.p-navigation-albums'));
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
2020-06-03 13:06:06 +02:00
.expect(Selector('h3').innerText).eql('No albums matched your search');
2020-06-03 08:42:56 +02:00
await t
.click(Selector('div.p-navigation-library + div'))
.click(Selector('.p-navigation-files'));
2020-06-03 13:06:06 +02:00
const FirstItem = await Selector('div.v-card__title').nth(0).innerText;
2020-06-03 08:42:56 +02:00
await t
.expect(FirstItem).contains('Vacation')
2020-06-03 13:06:06 +02:00
.click(Selector('button').withText('Vacation'));
const FirstItemInVacation = await Selector('div.v-card__title').nth(0).innerText;
const KanadaUid = await Selector('div.v-card__title').nth(0).getAttribute('data-uid');
const SecondItemInVacation = await Selector('div.v-card__title').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
2020-06-03 13:06:06 +02:00
const FirstItemInKanada = await Selector('div.v-card__title').nth(0).innerText;
const SecondItemInKanada = await Selector('div.v-card__title').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'))
.click(Selector('a[href="/files/Vacation"]'));
await page.selectFromUID(KanadaUid);
2020-06-03 08:42:56 +02:00
const clipboardCount = await Selector('span.t-clipboard-count');
await t
.expect(clipboardCount.textContent).eql("1")
2020-06-03 13:06:06 +02:00
.click(Selector('button.p-file-clipboard-menu'))
.click(Selector('button.p-file-clipboard-album'))
.typeText(Selector('.input-album input'), 'KanadaVacation', { replace: true })
.pressKey('enter')
2020-06-03 08:42:56 +02:00
.click(Selector('button.p-photo-dialog-confirm'))
.click(Selector('.p-navigation-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('.p-navigation-albums'));
await page.selectFromUID(AlbumUid);
await page.deleteSelectedAlbum();
});
//TODO test download itself + clipboard count after download
test('#2 Download files', async t => {
await page.openNav();
2020-06-03 08:42:56 +02:00
await t
2020-06-03 13:06:06 +02:00
.click(Selector('div.p-navigation-library + div'))
.click(Selector('.p-navigation-files'));
const FirstFile = await Selector('div.p-file').nth(0).getAttribute('data-uid');
await page.selectFromUID(FirstFile);
const clipboardCount = await Selector('span.t-clipboard-count');
2020-06-03 08:42:56 +02:00
await t
2020-06-03 13:06:06 +02:00
.expect(clipboardCount.textContent).eql("1")
.click(Selector('button.p-file-clipboard-menu'))
.expect(Selector('button.p-file-clipboard-download').visible).ok();
2020-06-03 08:42:56 +02:00
});