photoprism/frontend/tests/acceptance/acceptance-public/photos-download.js

120 lines
4.7 KiB
JavaScript
Raw Normal View History

2021-01-30 17:49:52 +00:00
import { Selector } from "testcafe";
import testcafeconfig from "../../testcafeconfig.json";
2021-01-30 17:49:52 +00:00
import { RequestLogger } from "testcafe";
2022-04-15 13:46:25 +00:00
import Toolbar from "../page-model/toolbar";
import ContextMenu from "../page-model/context-menu";
import Photo from "../page-model/photo";
import PhotoViewer from "../page-model/photoviewer";
import Page from "../page-model/page";
2021-01-30 17:49:52 +00:00
const logger = RequestLogger(/http:\/\/localhost:2343\/api\/v1\/*/, {
logResponseHeaders: true,
logResponseBody: true,
});
2022-04-15 13:46:25 +00:00
fixture`Test photos download`.page`${testcafeconfig.url}`
.requestHooks(logger)
.skip("Does not work in container and we have no content-disposition header anymore");
2021-01-30 17:49:52 +00:00
2022-04-15 13:46:25 +00:00
const toolbar = new Toolbar();
const contextmenu = new ContextMenu();
const photo = new Photo();
const photoviewer = new PhotoViewer();
2021-01-30 17:49:52 +00:00
const page = new Page();
2022-04-15 13:46:25 +00:00
2022-07-14 08:19:04 +00:00
test.meta("testID", "photos-download-001").meta({ type: "short", mode: "public" })(
"Common: Test download jpg file from context menu and fullscreen",
2021-01-30 17:49:52 +00:00
async (t) => {
2022-04-15 13:46:25 +00:00
await toolbar.search("name:monochrome-2.jpg");
const PhotoUid = await photo.getNthPhotoUid("all", 0);
await photo.triggerHoverAction("uid", PhotoUid, "select");
2021-01-30 17:49:52 +00:00
await logger.clear();
2022-04-15 13:46:25 +00:00
await contextmenu.triggerContextMenuAction("download", "");
2021-01-30 17:49:52 +00:00
const requestInfo = await logger.requests[1].response;
console.log(requestInfo);
const requestInfo0 = await logger.requests[0].response;
console.log(requestInfo0);
2022-04-15 13:46:25 +00:00
2021-01-30 17:49:52 +00:00
await page.validateDownloadRequest(requestInfo, "monochrome-2", ".jpg");
2022-04-15 13:46:25 +00:00
2021-01-30 17:49:52 +00:00
await logger.clear();
2022-04-15 13:46:25 +00:00
await contextmenu.clearSelection();
await toolbar.search("name:IMG_20200711_174006.jpg");
const SecondPhotoUid = await photo.getNthPhotoUid("all", 0);
await t.click(Selector("div").withAttribute("data-uid", SecondPhotoUid));
await photoviewer.openPhotoViewer("uid", SecondPhotoUid);
2021-01-30 17:49:52 +00:00
await logger.clear();
2022-04-15 13:46:25 +00:00
await photoviewer.triggerPhotoViewerAction("download");
2021-01-30 17:49:52 +00:00
await logger.clear();
2022-04-15 13:46:25 +00:00
await photoviewer.triggerPhotoViewerAction("close");
2021-01-30 17:49:52 +00:00
}
);
2022-07-14 08:19:04 +00:00
test.meta("testID", "photos-download-002").meta({ type: "short", mode: "public" })(
"Common: Test download video from context menu",
2021-01-30 17:49:52 +00:00
async (t) => {
2022-04-15 13:46:25 +00:00
await toolbar.search("name:Mohn.mp4");
const PhotoUid = await photo.getNthPhotoUid("all", 0);
await photo.triggerHoverAction("uid", PhotoUid, "select");
2021-01-30 17:49:52 +00:00
await logger.clear();
2022-04-15 13:46:25 +00:00
await contextmenu.triggerContextMenuAction("download", "");
const requestInfo = await logger.requests[0].response;
console.log(requestInfo);
const requestInfo2 = await logger.requests[1].response;
2021-01-30 17:49:52 +00:00
await page.validateDownloadRequest(requestInfo, "Mohn", ".mp4.jpg");
await page.validateDownloadRequest(requestInfo2, "Mohn", ".mp4");
2022-04-15 13:46:25 +00:00
2021-01-30 17:49:52 +00:00
await logger.clear();
2022-04-15 13:46:25 +00:00
await contextmenu.clearSelection();
2021-01-30 17:49:52 +00:00
}
);
2022-07-14 08:19:04 +00:00
test.meta("testID", "photos-download-003").meta({ mode: "public" })(
"Common: Test download multiple jpg files from context menu",
2021-01-30 17:49:52 +00:00
async (t) => {
2022-04-15 13:46:25 +00:00
await toolbar.search("name:panorama_2.jpg");
const PhotoUid = await photo.getNthPhotoUid("all", 0);
await photo.triggerHoverAction("uid", PhotoUid, "select");
await toolbar.search("name:IMG_6478.JPG");
const SecondPhotoUid = await photo.getNthPhotoUid("all", 0);
await photo.triggerHoverAction("uid", SecondPhotoUid, "select");
2021-01-30 17:49:52 +00:00
await logger.clear();
2022-04-15 13:46:25 +00:00
await contextmenu.triggerContextMenuAction("download", "");
2021-01-30 17:49:52 +00:00
const requestInfo = await logger.requests[1].response;
console.log(requestInfo);
2022-04-15 13:46:25 +00:00
2021-01-30 17:49:52 +00:00
await page.validateDownloadRequest(requestInfo, "photoprism-download", ".zip");
2022-04-15 13:46:25 +00:00
2021-01-30 17:49:52 +00:00
await logger.clear();
2022-04-15 13:46:25 +00:00
await contextmenu.clearSelection();
2021-01-30 17:49:52 +00:00
}
);
//TODO Check RAW files as well
2022-07-14 08:19:04 +00:00
test.meta("testID", "photos-download-004").meta({ mode: "public" })(
"Common: Test raw file from context menu and fullscreen mode",
2021-01-30 17:49:52 +00:00
async (t) => {
2022-04-15 13:46:25 +00:00
await toolbar.search("name:elephantRAW");
const PhotoUid = await photo.getNthPhotoUid("all", 0);
await photo.triggerHoverAction("uid", PhotoUid, "select");
2021-01-30 17:49:52 +00:00
await logger.clear();
2022-04-15 13:46:25 +00:00
await contextmenu.triggerContextMenuAction("download", "");
2021-01-30 17:49:52 +00:00
const requestInfo = await logger.requests[1].response;
2022-04-15 13:46:25 +00:00
2021-01-30 17:49:52 +00:00
await page.validateDownloadRequest(requestInfo, "elephantRAW", ".JPG");
2022-04-15 13:46:25 +00:00
2021-01-30 17:49:52 +00:00
await logger.clear();
2022-04-15 13:46:25 +00:00
await contextmenu.clearSelection();
2021-01-30 17:49:52 +00:00
await t.click(Selector("div").withAttribute("data-uid", Photo));
2021-02-15 14:57:28 +00:00
await t.expect(Selector("#photo-viewer").visible).ok().hover(Selector(".action-download"));
2021-01-30 17:49:52 +00:00
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();
}
);