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

120 lines
4.6 KiB
JavaScript
Raw Normal View History

2021-01-30 18:49:52 +01:00
import { Selector } from "testcafe";
import testcafeconfig from "./testcafeconfig";
import { RequestLogger } from "testcafe";
2022-04-15 15:46:25 +02: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 18:49:52 +01:00
const logger = RequestLogger(/http:\/\/localhost:2343\/api\/v1\/*/, {
logResponseHeaders: true,
logResponseBody: true,
});
2022-04-15 15:46:25 +02: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 18:49:52 +01:00
2022-04-15 15:46:25 +02:00
const toolbar = new Toolbar();
const contextmenu = new ContextMenu();
const photo = new Photo();
const photoviewer = new PhotoViewer();
2021-01-30 18:49:52 +01:00
const page = new Page();
2022-04-15 15:46:25 +02:00
test.meta("testID", "photos-download-001").meta({ type: "smoke" })(
2021-01-30 18:49:52 +01:00
"Test download jpg file from context menu and fullscreen",
async (t) => {
2022-04-15 15:46:25 +02:00
await toolbar.search("name:monochrome-2.jpg");
const PhotoUid = await photo.getNthPhotoUid("all", 0);
await photo.triggerHoverAction("uid", PhotoUid, "select");
2021-01-30 18:49:52 +01:00
await logger.clear();
2022-04-15 15:46:25 +02:00
await contextmenu.triggerContextMenuAction("download", "");
2021-01-30 18:49:52 +01:00
const requestInfo = await logger.requests[1].response;
console.log(requestInfo);
const requestInfo0 = await logger.requests[0].response;
console.log(requestInfo0);
2022-04-15 15:46:25 +02:00
2021-01-30 18:49:52 +01:00
await page.validateDownloadRequest(requestInfo, "monochrome-2", ".jpg");
2022-04-15 15:46:25 +02:00
2021-01-30 18:49:52 +01:00
await logger.clear();
2022-04-15 15:46:25 +02: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 18:49:52 +01:00
await logger.clear();
2022-04-15 15:46:25 +02:00
await photoviewer.triggerPhotoViewerAction("download");
2021-01-30 18:49:52 +01:00
await logger.clear();
2022-04-15 15:46:25 +02:00
await photoviewer.triggerPhotoViewerAction("close");
2021-01-30 18:49:52 +01:00
}
);
2022-04-15 15:46:25 +02:00
test.meta("testID", "photos-download-002").meta({ type: "smoke" })(
2021-01-30 18:49:52 +01:00
"Test download video from context menu",
async (t) => {
2022-04-15 15:46:25 +02:00
await toolbar.search("name:Mohn.mp4");
const PhotoUid = await photo.getNthPhotoUid("all", 0);
await photo.triggerHoverAction("uid", PhotoUid, "select");
2021-01-30 18:49:52 +01:00
await logger.clear();
2022-04-15 15:46:25 +02: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 18:49:52 +01:00
await page.validateDownloadRequest(requestInfo, "Mohn", ".mp4.jpg");
await page.validateDownloadRequest(requestInfo2, "Mohn", ".mp4");
2022-04-15 15:46:25 +02:00
2021-01-30 18:49:52 +01:00
await logger.clear();
2022-04-15 15:46:25 +02:00
await contextmenu.clearSelection();
2021-01-30 18:49:52 +01:00
}
);
2021-02-05 16:48:39 +01:00
test.meta("testID", "photos-download-003")(
2021-01-30 18:49:52 +01:00
"Test download multiple jpg files from context menu",
async (t) => {
2022-04-15 15:46:25 +02: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 18:49:52 +01:00
await logger.clear();
2022-04-15 15:46:25 +02:00
await contextmenu.triggerContextMenuAction("download", "");
2021-01-30 18:49:52 +01:00
const requestInfo = await logger.requests[1].response;
console.log(requestInfo);
2022-04-15 15:46:25 +02:00
2021-01-30 18:49:52 +01:00
await page.validateDownloadRequest(requestInfo, "photoprism-download", ".zip");
2022-04-15 15:46:25 +02:00
2021-01-30 18:49:52 +01:00
await logger.clear();
2022-04-15 15:46:25 +02:00
await contextmenu.clearSelection();
2021-01-30 18:49:52 +01:00
}
);
//TODO Check RAW files as well
2021-02-05 16:48:39 +01:00
test.meta("testID", "photos-download-004")(
2021-01-30 18:49:52 +01:00
"Test raw file from context menu and fullscreen mode",
async (t) => {
2022-04-15 15:46:25 +02:00
await toolbar.search("name:elephantRAW");
const PhotoUid = await photo.getNthPhotoUid("all", 0);
await photo.triggerHoverAction("uid", PhotoUid, "select");
2021-01-30 18:49:52 +01:00
await logger.clear();
2022-04-15 15:46:25 +02:00
await contextmenu.triggerContextMenuAction("download", "");
2021-01-30 18:49:52 +01:00
const requestInfo = await logger.requests[1].response;
2022-04-15 15:46:25 +02:00
2021-01-30 18:49:52 +01:00
await page.validateDownloadRequest(requestInfo, "elephantRAW", ".JPG");
2022-04-15 15:46:25 +02:00
2021-01-30 18:49:52 +01:00
await logger.clear();
2022-04-15 15:46:25 +02:00
await contextmenu.clearSelection();
2021-01-30 18:49:52 +01:00
await t.click(Selector("div").withAttribute("data-uid", Photo));
2021-02-15 15:57:28 +01:00
await t.expect(Selector("#photo-viewer").visible).ok().hover(Selector(".action-download"));
2021-01-30 18:49:52 +01: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();
}
);