Tests: Refactor acceptance tests

This commit is contained in:
theresa 2022-01-21 17:55:03 +01:00
parent 1b5b88a66f
commit e61a8af05c
2 changed files with 220 additions and 0 deletions

View file

@ -0,0 +1,111 @@
import { Selector } from "testcafe";
import testcafeconfig from "./testcafeconfig";
import { RequestLogger } from "testcafe";
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 NewPage from "../page-model/page";
import PhotoViews from "../page-model/photo-views";
const logger = RequestLogger(/http:\/\/localhost:2343\/api\/v1\/*/, {
logResponseHeaders: true,
logResponseBody: true,
});
fixture`Test photos download`.page`${testcafeconfig.url}`
.requestHooks(logger)
.skip("Does not work in container and we have no content-disposition header anymore");
const toolbar = new Toolbar();
const contextmenu = new ContextMenu();
const photo = new Photo();
const photoviewer = new PhotoViewer();
const newpage = new NewPage();
const photoviews = new PhotoViews();
//TODO Make those run from within the container
test.meta("testID", "photos-download-001")(
"Test download jpg file from context menu and fullscreen",
async (t) => {
await toolbar.search("name:monochrome-2.jpg");
const Photo = await photo.getNthPhotoUid("all", 0);
await photoviews.triggerHoverAction("uid", Photo, "select");
await logger.clear();
await contextmenu.triggerContextMenuAction("download", "", "");
const requestInfo = await logger.requests[1].response;
console.log(requestInfo);
const requestInfo0 = await logger.requests[0].response;
console.log(requestInfo0);
await newpage.validateDownloadRequest(requestInfo, "monochrome-2", ".jpg");
await logger.clear();
await contextmenu.clearSelection();
await toolbar.search("name:IMG_20200711_174006.jpg");
const SecondPhoto = await photo.getNthPhotoUid("all", 0);
await t.click(Selector("div").withAttribute("data-uid", SecondPhoto));
await photoviewer.openPhotoViewer("uid", SecondPhoto);
await logger.clear();
await photoviewer.triggerPhotoViewerAction("download");
await logger.clear();
await photoviewer.triggerPhotoViewerAction("close");
}
);
test.meta("testID", "photos-download-002")("Test download video from context menu", async (t) => {
await toolbar.search("name:Mohn.mp4");
const Photo = await photo.getNthPhotoUid("all", 0);
await photoviews.triggerHoverAction("uid", Photo, "select");
await logger.clear();
await contextmenu.triggerContextMenuAction("download", "", "");
const requestInfo = await logger.requests[0].response;
console.log(requestInfo);
const requestInfo2 = await logger.requests[1].response;
await newpage.validateDownloadRequest(requestInfo, "Mohn", ".mp4.jpg");
await newpage.validateDownloadRequest(requestInfo2, "Mohn", ".mp4");
await logger.clear();
await contextmenu.clearSelection();
});
test.meta("testID", "photos-download-003")(
"Test download multiple jpg files from context menu",
async (t) => {
await toolbar.search("name:panorama_2.jpg");
const Photo = await photo.getNthPhotoUid("all", 0);
await photoviews.triggerHoverAction("uid", Photo, "select");
await toolbar.search("name:IMG_6478.JPG");
const SecondPhoto = await photo.getNthPhotoUid("all", 0);
await photoviews.triggerHoverAction("uid", SecondPhoto, "select");
await logger.clear();
await contextmenu.triggerContextMenuAction("download", "", "");
const requestInfo = await logger.requests[1].response;
console.log(requestInfo);
await newpage.validateDownloadRequest(requestInfo, "photoprism-download", ".zip");
await logger.clear();
await contextmenu.clearSelection();
}
);
//TODO Check RAW files as well
test.meta("testID", "photos-download-004")(
"Test raw file from context menu and fullscreen mode",
async (t) => {
await toolbar.search("name:elephantRAW");
const Photo = await photo.getNthPhotoUid("all", 0);
await photoviews.triggerHoverAction("uid", Photo, "select");
await logger.clear();
await contextmenu.triggerContextMenuAction("download", "", "");
const requestInfo = await logger.requests[1].response;
await newpage.validateDownloadRequest(requestInfo, "elephantRAW", ".JPG");
await logger.clear();
await contextmenu.clearSelection();
await t.click(Selector("div").withAttribute("data-uid", Photo));
await t.expect(Selector("#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 newpage.validateDownloadRequest(requestInfo3, "elephantRAW", ".JPG");
//await page.validateDownloadRequest(requestInfo4, "elephantRAW", ".mp4");
await logger.clear();
}
);

View file

@ -0,0 +1,109 @@
import { Selector } from "testcafe";
import testcafeconfig from "./testcafeconfig";
import Menu from "../page-model/menu";
import Toolbar from "../page-model/toolbar";
import Photo from "../page-model/photo";
import PhotoViewer from "../page-model/photoviewer";
import NewPage from "../page-model/page";
import PhotoViews from "../page-model/photo-views";
import PhotoEdit from "../page-model/photo-edit";
import Library from "../page-model/library";
fixture`Test stacks`.page`${testcafeconfig.url}`;
const menu = new Menu();
const toolbar = new Toolbar();
const photo = new Photo();
const photoviewer = new PhotoViewer();
const newpage = new NewPage();
const photoviews = new PhotoViews();
const photoedit = new PhotoEdit();
const library = new Library();
test.meta("testID", "stacks-001")("Change primary file", async (t) => {
await toolbar.search("ski");
const SequentialPhoto = await photo.getNthPhotoUid("all", 0);
await photoviews.checkHoverActionAvailability("uid", SequentialPhoto, "open", true);
if (t.browser.platform === "desktop") {
console.log(t.browser.platform);
await photoviews.triggerHoverAction("nth", 0, "open");
await photoviewer.triggerPhotoViewerAction("next");
await photoviewer.triggerPhotoViewerAction("previous");
await photoviewer.triggerPhotoViewerAction("close");
}
await toolbar.setFilter("view", "Cards");
await t
.click(newpage.cardTitle.withAttribute("data-uid", SequentialPhoto))
.click(Selector("#tab-files"));
const FirstFileName = await Selector("div.caption").nth(0).innerText;
await t
.expect(FirstFileName)
.contains("photos8_1_ski.jpg")
.click(photoedit.toggleExpandFile.nth(1))
.click(photoedit.makeFilePrimary)
.click(photoedit.dialogClose)
.click(newpage.cardTitle.withAttribute("data-uid", SequentialPhoto));
const FirstFileNameAfterChange = await Selector("div.caption").nth(0).innerText;
await t
.expect(FirstFileNameAfterChange)
.notContains("photos8_1_ski.jpg")
.expect(FirstFileNameAfterChange)
.contains("photos8_2_ski.jpg");
});
test.meta("testID", "stacks-002")("Ungroup files", async (t) => {
await toolbar.search("group");
await toolbar.setFilter("view", "Cards");
const PhotoCount = await photo.getPhotoCount("all");
const SequentialPhoto = await photo.getNthPhotoUid("all", 0);
await t.expect(PhotoCount).eql(1);
await menu.openPage("stacks");
await photoviews.checkHoverActionAvailability("uid", SequentialPhoto, "open", true);
await t
.click(newpage.cardTitle.withAttribute("data-uid", SequentialPhoto))
.click(Selector("#tab-files"))
.click(photoedit.toggleExpandFile.nth(0))
.click(photoedit.toggleExpandFile.nth(1))
.click(photoedit.unstackFile)
.wait(12000)
.click(photoedit.dialogClose);
await menu.openPage("browse");
await toolbar.search("group");
if (t.browser.platform === "mobile") {
await t.eval(() => location.reload());
} else {
await toolbar.triggerToolbarAction("reload", "");
}
const PhotoCountAfterUngroup = await photo.getPhotoCount("all");
await t.expect(PhotoCountAfterUngroup).eql(2);
});
test.meta("testID", "stacks-003")("Delete non primary file", async (t) => {
await menu.openPage("library");
await t
.click(Selector("#tab-library-import"))
.click(library.openImportFolderSelect, { timeout: 5000 })
.click(newpage.selectOption.withText("/pizza"))
.click(library.import)
.wait(10000);
await menu.openPage("browse");
await toolbar.search("pizza");
await toolbar.setFilter("view", "Cards");
const PhotoCount = await photo.getPhotoCount("all");
const Photo = await photo.getNthPhotoUid("all", 0);
await t
.expect(PhotoCount)
.eql(1)
.click(newpage.cardTitle.withAttribute("data-uid", Photo))
.click(Selector("#tab-files"));
const FileCount = await photoedit.getFileCount();
await t
.expect(FileCount)
.eql(2)
.click(photoedit.toggleExpandFile.nth(1))
.click(Selector(photoedit.deleteFile))
.click(Selector(".action-confirm"))
.wait(10000);
const FileCountAfterDeletion = await photoedit.getFileCount();
await t.expect(FileCountAfterDeletion).eql(1);
});