Tests: Add tests for download
This commit is contained in:
parent
7162029bb3
commit
535d295b3d
|
@ -1,8 +1,14 @@
|
|||
import { Selector } from "testcafe";
|
||||
import testcafeconfig from "./testcafeconfig";
|
||||
import Page from "./page-model";
|
||||
import { RequestLogger } from "testcafe";
|
||||
|
||||
fixture`Test calendar`.page`${testcafeconfig.url}`;
|
||||
const logger = RequestLogger(/http:\/\/localhost:2343\/api\/v1\/*/, {
|
||||
logResponseHeaders: true,
|
||||
logResponseBody: true,
|
||||
});
|
||||
|
||||
fixture`Test calendar`.page`${testcafeconfig.url}`.requestHooks(logger);
|
||||
|
||||
const page = new Page();
|
||||
|
||||
|
@ -92,14 +98,14 @@ test.meta("testID", "calendar-004")("Create/delete album during add to album", a
|
|||
const countAlbums = await Selector("a.is-album").count;
|
||||
await page.openNav();
|
||||
await t.click(Selector(".nav-calendar"));
|
||||
const ThirdCalendar = await Selector("a.is-album").nth(2).getAttribute("data-uid");
|
||||
await t.click(Selector("a.is-album").withAttribute("data-uid", ThirdCalendar));
|
||||
const SecondCalendar = await Selector("a.is-album").nth(1).getAttribute("data-uid");
|
||||
await t.click(Selector("a.is-album").withAttribute("data-uid", SecondCalendar));
|
||||
const PhotoCountInCalendar = await Selector("div.is-photo").count;
|
||||
const FirstPhoto = await Selector("div.is-photo.type-image").nth(0).getAttribute("data-uid");
|
||||
const SecondPhoto = await Selector("div.is-photo.type-image").nth(1).getAttribute("data-uid");
|
||||
await page.openNav();
|
||||
await t.click(Selector(".nav-calendar"));
|
||||
await page.selectFromUID(ThirdCalendar);
|
||||
await page.selectFromUID(SecondCalendar);
|
||||
await page.addSelectedToAlbum("NotYetExistingAlbumForCalendar", "clone");
|
||||
await page.openNav();
|
||||
await t.click(Selector(".nav-albums"));
|
||||
|
@ -126,7 +132,7 @@ test.meta("testID", "calendar-004")("Create/delete album during add to album", a
|
|||
await t.expect(countAlbumsAfterDelete).eql(countAlbums);
|
||||
await t
|
||||
.click(Selector(".nav-calendar"))
|
||||
.click(Selector("a.is-album").withAttribute("data-uid", ThirdCalendar))
|
||||
.click(Selector("a.is-album").withAttribute("data-uid", SecondCalendar))
|
||||
.expect(Selector("div").withAttribute("data-uid", FirstPhoto).exists, { timeout: 5000 })
|
||||
.ok()
|
||||
.expect(Selector("div").withAttribute("data-uid", SecondPhoto).exists, { timeout: 5000 })
|
||||
|
|
|
@ -146,6 +146,7 @@ test.meta("testID", "labels-003")("Add label to album", async (t) => {
|
|||
const ThirdPhotoLandscape = await Selector("div.is-photo").nth(2).getAttribute("data-uid");
|
||||
const FourthPhotoLandscape = await Selector("div.is-photo").nth(3).getAttribute("data-uid");
|
||||
const FifthPhotoLandscape = await Selector("div.is-photo").nth(4).getAttribute("data-uid");
|
||||
const SixthPhotoLandscape = await Selector("div.is-photo").nth(5).getAttribute("data-uid");
|
||||
await page.openNav();
|
||||
await t.click(".nav-labels");
|
||||
await page.selectFromUID(LabelLandscape);
|
||||
|
@ -158,15 +159,16 @@ test.meta("testID", "labels-003")("Add label to album", async (t) => {
|
|||
.click(Selector(".nav-albums"))
|
||||
.click(Selector("a.is-album").withAttribute("data-uid", AlbumUid));
|
||||
const PhotoCountAfterAdd = await Selector("div.is-photo", { timeout: 5000 }).count;
|
||||
await t.expect(PhotoCountAfterAdd).eql(PhotoCount + 5);
|
||||
await t.expect(PhotoCountAfterAdd).eql(PhotoCount + 6);
|
||||
await page.selectPhotoFromUID(FirstPhotoLandscape);
|
||||
await page.selectPhotoFromUID(SecondPhotoLandscape);
|
||||
await page.selectPhotoFromUID(ThirdPhotoLandscape);
|
||||
await page.selectPhotoFromUID(FourthPhotoLandscape);
|
||||
await page.selectPhotoFromUID(FifthPhotoLandscape);
|
||||
await page.selectPhotoFromUID(SixthPhotoLandscape);
|
||||
await page.removeSelected();
|
||||
const PhotoCountAfterDelete = await Selector("div.is-photo", { timeout: 5000 }).count;
|
||||
await t.expect(PhotoCountAfterDelete).eql(PhotoCountAfterAdd - 5);
|
||||
await t.expect(PhotoCountAfterDelete).eql(PhotoCountAfterAdd - 6);
|
||||
});
|
||||
|
||||
test.meta("testID", "labels-004")("Delete label", async (t) => {
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
import { Selector, t } from "testcafe";
|
||||
import { RequestLogger } from "testcafe";
|
||||
|
||||
const logger = RequestLogger(/http:\/\/localhost:2343\/api\/v1\/*/, {
|
||||
logResponseHeaders: true,
|
||||
logResponseBody: true,
|
||||
});
|
||||
|
||||
export default class Page {
|
||||
constructor() {
|
||||
|
@ -312,4 +318,16 @@ export default class Page {
|
|||
.expect(Selector("div").withAttribute("data-uid", uid).exists, { timeout: 5000 })
|
||||
.notOk();
|
||||
}
|
||||
|
||||
async validateDownloadRequest(request, filename, extension) {
|
||||
const downloadedFileName = request.headers["content-disposition"];
|
||||
await t
|
||||
.expect(request.statusCode === 200)
|
||||
.ok()
|
||||
.expect(downloadedFileName)
|
||||
.contains(filename)
|
||||
.expect(downloadedFileName)
|
||||
.contains(extension);
|
||||
await logger.clear();
|
||||
}
|
||||
}
|
||||
|
|
112
frontend/tests/acceptance/photos-download.js
Normal file
112
frontend/tests/acceptance/photos-download.js
Normal file
|
@ -0,0 +1,112 @@
|
|||
import { Selector } from "testcafe";
|
||||
import testcafeconfig from "./testcafeconfig";
|
||||
import Page from "./page-model";
|
||||
import { RequestLogger } from "testcafe";
|
||||
|
||||
const logger = RequestLogger(/http:\/\/localhost:2343\/api\/v1\/*/, {
|
||||
logResponseHeaders: true,
|
||||
logResponseBody: true,
|
||||
});
|
||||
|
||||
fixture`Test photos download`.page`${testcafeconfig.url}`.requestHooks(logger);
|
||||
|
||||
const page = new Page();
|
||||
//TODO Make those run from within the container
|
||||
test.skip.meta("testID", "photos-download-001")(
|
||||
"Test download jpg file from context menu and fullscreen",
|
||||
async (t) => {
|
||||
await page.search("name:monochrome-2.jpg");
|
||||
const Photo = await Selector("div.is-photo").nth(0).getAttribute("data-uid");
|
||||
await page.selectPhotoFromUID(Photo);
|
||||
await t.click(Selector("button.action-menu"));
|
||||
await logger.clear();
|
||||
await t.click(Selector("button.action-download"));
|
||||
const requestInfo = await logger.requests[1].response;
|
||||
console.log(requestInfo);
|
||||
const requestInfo0 = await logger.requests[0].response;
|
||||
console.log(requestInfo0);
|
||||
await page.validateDownloadRequest(requestInfo, "monochrome-2", ".jpg");
|
||||
await logger.clear();
|
||||
await page.clearSelection();
|
||||
await page.search("name:IMG_20200711_174006.jpg");
|
||||
const SecondPhoto = await Selector("div.is-photo").nth(0).getAttribute("data-uid");
|
||||
await t.click(Selector("div").withAttribute("data-uid", SecondPhoto));
|
||||
await t.expect(Selector("#p-photo-viewer").visible).ok().hover(Selector(".action-download"));
|
||||
await logger.clear();
|
||||
await t.click(Selector(".action-download"));
|
||||
const requestInfo2 = await logger.requests[1].response;
|
||||
await page.validateDownloadRequest(requestInfo2, "IMG_20200711_174006", ".jpg");
|
||||
await logger.clear();
|
||||
await t.click(Selector(".action-close"));
|
||||
}
|
||||
);
|
||||
|
||||
test.skip.meta("testID", "photos-download-002")(
|
||||
"Test download video from context menu",
|
||||
async (t) => {
|
||||
await page.openNav();
|
||||
await t.click(Selector("div.nav-browse"));
|
||||
await page.search("name:Mohn.mp4");
|
||||
const Photo = await Selector("div.is-photo").nth(0).getAttribute("data-uid");
|
||||
await page.selectPhotoFromUID(Photo);
|
||||
await t.click(Selector("button.action-menu"));
|
||||
await logger.clear();
|
||||
await t.click(Selector("button.action-download"));
|
||||
const requestInfo = await logger.requests[1].response;
|
||||
const requestInfo2 = await logger.requests[2].response;
|
||||
await page.validateDownloadRequest(requestInfo, "Mohn", ".mp4.jpg");
|
||||
await page.validateDownloadRequest(requestInfo2, "Mohn", ".mp4");
|
||||
await logger.clear();
|
||||
await page.clearSelection();
|
||||
}
|
||||
);
|
||||
|
||||
test.skip.meta("testID", "photos-download-003")(
|
||||
"Test download multiple jpg files from context menu",
|
||||
async (t) => {
|
||||
await page.search("name:panorama_2.jpg");
|
||||
const Photo = await Selector("div.is-photo").nth(0).getAttribute("data-uid");
|
||||
await page.selectPhotoFromUID(Photo);
|
||||
await page.search("name:IMG_6478.JPG");
|
||||
const SecondPhoto = await Selector("div.is-photo").nth(0).getAttribute("data-uid");
|
||||
await page.selectPhotoFromUID(SecondPhoto);
|
||||
await t.click(Selector("button.action-menu"));
|
||||
await logger.clear();
|
||||
await t.click(Selector("button.action-download"));
|
||||
const requestInfo = await logger.requests[1].response;
|
||||
console.log(requestInfo);
|
||||
await page.validateDownloadRequest(requestInfo, "photoprism-download", ".zip");
|
||||
await logger.clear();
|
||||
await page.clearSelection();
|
||||
}
|
||||
);
|
||||
|
||||
//TODO Check RAW files as well
|
||||
test.skip.meta("testID", "photos-download-004")(
|
||||
"Test raw file from context menu and fullscreen mode",
|
||||
async (t) => {
|
||||
await page.openNav();
|
||||
await t.click(Selector("div.nav-browse"));
|
||||
await page.search("name:elephantRAW");
|
||||
const Photo = await Selector("div.is-photo").nth(0).getAttribute("data-uid");
|
||||
await page.selectPhotoFromUID(Photo);
|
||||
await t.click(Selector("button.action-menu"));
|
||||
await logger.clear();
|
||||
await t.click(Selector("button.action-download"));
|
||||
const requestInfo = await logger.requests[1].response;
|
||||
//const requestInfo2 = await logger.requests[2].response;
|
||||
await page.validateDownloadRequest(requestInfo, "elephantRAW", ".JPG");
|
||||
//await page.validateDownloadRequest(requestInfo2, "elephantRAW", ".mp4");
|
||||
await logger.clear();
|
||||
await page.clearSelection();
|
||||
await t.click(Selector("div").withAttribute("data-uid", Photo));
|
||||
await t.expect(Selector("#p-photo-viewer").visible).ok().hover(Selector(".action-download"));
|
||||
await logger.clear();
|
||||
await t.click(Selector(".action-download"));
|
||||
const requestInfo3 = await logger.requests[1].response;
|
||||
//const requestInfo4 = await logger.requests[2].response;
|
||||
await page.validateDownloadRequest(requestInfo3, "elephantRAW", ".JPG");
|
||||
//await page.validateDownloadRequest(requestInfo4, "elephantRAW", ".mp4");
|
||||
await logger.clear();
|
||||
}
|
||||
);
|
|
@ -569,6 +569,7 @@ test.meta("testID", "photos-010")("Ungroup files", async (t) => {
|
|||
.click(Selector("button.action-title-edit").withAttribute("data-uid", SequentialPhoto))
|
||||
.click(Selector("#tab-files"))
|
||||
.click(Selector("li.v-expansion-panel__container").nth(1))
|
||||
.click(Selector("li.v-expansion-panel__container").nth(0))
|
||||
.click(Selector(".action-unstack"))
|
||||
.wait(12000)
|
||||
.click(Selector("button.action-close"));
|
||||
|
|
Loading…
Reference in a new issue