photoprism/frontend/tests/acceptance/photos.js

378 lines
13 KiB
JavaScript
Raw Normal View History

2021-01-15 17:02:39 +01:00
import { Selector } from "testcafe";
import testcafeconfig from "./testcafeconfig";
import { ClientFunction } from "testcafe";
2022-04-15 15:46:25 +02:00
import Menu from "../page-model/menu";
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";
import PhotoEdit from "../page-model/photo-edit";
2020-05-31 19:31:48 +02:00
const scroll = ClientFunction((x, y) => window.scrollTo(x, y));
const getcurrentPosition = ClientFunction(() => window.pageYOffset);
2021-01-15 17:02:39 +01:00
fixture`Test photos`.page`${testcafeconfig.url}`;
2019-05-21 17:00:46 +02:00
2022-04-15 15:46:25 +02:00
const menu = new Menu();
const toolbar = new Toolbar();
const contextmenu = new ContextMenu();
const photo = new Photo();
const photoviewer = new PhotoViewer();
2019-05-21 17:00:46 +02:00
const page = new Page();
2022-04-15 15:46:25 +02:00
const photoedit = new PhotoEdit();
2019-05-21 17:00:46 +02:00
2021-01-25 19:12:25 +01:00
test.meta("testID", "photos-001")("Scroll to top", async (t) => {
2022-04-15 15:46:25 +02:00
await toolbar.setFilter("view", "Cards");
2021-01-15 17:02:39 +01:00
await t
.expect(Selector("button.is-photo-scroll-top").exists)
.notOk()
.expect(getcurrentPosition())
.eql(0)
.expect(Selector('div[class="v-image__image v-image__image--cover"]').nth(0).visible)
.ok();
2022-04-15 15:46:25 +02:00
2021-01-15 17:02:39 +01:00
await scroll(0, 1400);
await scroll(0, 900);
2022-04-15 15:46:25 +02:00
2021-01-15 17:02:39 +01:00
await t.click(Selector("button.p-scroll-top")).expect(getcurrentPosition()).eql(0);
2020-05-31 19:31:48 +02:00
});
2022-04-15 15:46:25 +02:00
//TODO Covered by admin role test
2021-01-15 17:02:39 +01:00
test.meta("testID", "photos-002")(
"Download single photo/video using clipboard and fullscreen mode",
async (t) => {
2022-04-15 15:46:25 +02:00
const FirstPhotoUid = await photo.getNthPhotoUid("image", 0);
const SecondPhotoUid = await photo.getNthPhotoUid("image", 1);
const FirstVideoUid = await photo.getNthPhotoUid("video", 0);
await photoviewer.openPhotoViewer("uid", SecondPhotoUid);
await photoviewer.checkPhotoViewerActionAvailability("download", true);
await photoviewer.triggerPhotoViewerAction("close");
await photo.triggerHoverAction("uid", FirstPhotoUid, "select");
await photo.triggerHoverAction("uid", FirstVideoUid, "select");
await contextmenu.checkContextMenuCount("2");
await contextmenu.checkContextMenuActionAvailability("download", true);
2021-01-15 17:02:39 +01:00
}
);
2022-04-15 15:46:25 +02:00
test.meta("testID", "photos-003").meta({ type: "smoke" })(
2021-01-15 17:02:39 +01:00
"Approve photo using approve and by adding location",
async (t) => {
2022-04-15 15:46:25 +02:00
await menu.openPage("review");
const FirstPhotoUid = await photo.getNthPhotoUid("all", 0);
const SecondPhotoUid = await photo.getNthPhotoUid("all", 1);
const ThirdPhotoUid = await photo.getNthPhotoUid("all", 2);
await menu.openPage("browse");
await photo.checkPhotoVisibility(FirstPhotoUid, false);
await photo.checkPhotoVisibility(SecondPhotoUid, false);
await menu.openPage("review");
await photo.triggerHoverAction("uid", FirstPhotoUid, "select");
await contextmenu.triggerContextMenuAction("edit", "");
await t.click(photoedit.detailsClose);
if (t.browser.platform === "mobile") {
await t.eval(() => location.reload());
} else {
2022-04-15 15:46:25 +02:00
await toolbar.triggerToolbarAction("reload");
}
2022-04-15 15:46:25 +02:00
await photo.checkPhotoVisibility(FirstPhotoUid, true);
await contextmenu.triggerContextMenuAction("edit", "");
await t.click(photoedit.detailsApprove);
if (t.browser.platform === "mobile") {
2022-04-15 15:46:25 +02:00
await t.click(photoedit.detailsApply).click(photoedit.detailsClose);
} else {
2022-04-15 15:46:25 +02:00
await t.click(photoedit.detailsDone);
}
2022-04-15 15:46:25 +02:00
await photo.triggerHoverAction("uid", SecondPhotoUid, "select");
await contextmenu.triggerContextMenuAction("edit", "");
await t
2022-04-15 15:46:25 +02:00
.typeText(photoedit.latitude, "9.999", { replace: true })
.typeText(photoedit.longitude, "9.999", { replace: true });
if (t.browser.platform === "mobile") {
2022-04-15 15:46:25 +02:00
await t.click(photoedit.detailsApply).click(photoedit.detailsClose);
} else {
2022-04-15 15:46:25 +02:00
await t.click(photoedit.detailsDone);
}
2022-04-15 15:46:25 +02:00
await toolbar.setFilter("view", "Cards");
const ApproveButtonThirdPhoto =
'div.is-photo[data-uid="' + ThirdPhotoUid + '"] button.action-approve';
await t.click(Selector(ApproveButtonThirdPhoto));
if (t.browser.platform === "mobile") {
await t.eval(() => location.reload());
} else {
2022-04-15 15:46:25 +02:00
await toolbar.triggerToolbarAction("reload");
}
2022-04-15 15:46:25 +02:00
await photo.checkPhotoVisibility(FirstPhotoUid, false);
await photo.checkPhotoVisibility(SecondPhotoUid, false);
await photo.checkPhotoVisibility(ThirdPhotoUid, false);
await menu.openPage("browse");
await photo.checkPhotoVisibility(FirstPhotoUid, true);
await photo.checkPhotoVisibility(SecondPhotoUid, true);
await photo.checkPhotoVisibility(ThirdPhotoUid, true);
2021-01-15 17:02:39 +01:00
}
2021-01-20 17:13:42 +01:00
);
2021-01-15 17:02:39 +01:00
2022-04-15 15:46:25 +02:00
test.meta("testID", "photos-004").meta({ type: "smoke" })("Like/dislike photo/video", async (t) => {
const FirstPhotoUid = await photo.getNthPhotoUid("image", 0);
const SecondPhotoUid = await photo.getNthPhotoUid("image", 1);
const FirstVideoUid = await photo.getNthPhotoUid("video", 0);
await menu.openPage("favorites");
2021-01-15 17:02:39 +01:00
2022-04-15 15:46:25 +02:00
await photo.checkPhotoVisibility(FirstPhotoUid, false);
await photo.checkPhotoVisibility(SecondPhotoUid, false);
await photo.checkPhotoVisibility(FirstVideoUid, false);
await menu.openPage("browse");
await photo.triggerHoverAction("uid", FirstPhotoUid, "favorite");
await photo.triggerHoverAction("uid", FirstVideoUid, "favorite");
await photo.triggerHoverAction("uid", SecondPhotoUid, "select");
await contextmenu.triggerContextMenuAction("edit", "");
await photoedit.turnSwitchOn("favorite");
await t.click(photoedit.dialogClose);
await contextmenu.clearSelection();
await photo.checkPhotoVisibility(FirstPhotoUid, true);
await photo.checkPhotoVisibility(FirstVideoUid, true);
await photo.checkPhotoVisibility(SecondPhotoUid, true);
await menu.openPage("favorites");
await photo.checkPhotoVisibility(FirstPhotoUid, true);
await photo.checkPhotoVisibility(FirstVideoUid, true);
await photo.checkPhotoVisibility(SecondPhotoUid, true);
await photo.triggerHoverAction("uid", SecondPhotoUid, "favorite");
await photo.triggerHoverAction("uid", FirstVideoUid, "select");
await contextmenu.triggerContextMenuAction("edit", "");
await photoedit.turnSwitchOff("favorite");
await t.click(photoedit.dialogClose);
await contextmenu.clearSelection();
await photoviewer.openPhotoViewer("uid", FirstPhotoUid);
await photoviewer.triggerPhotoViewerAction("like");
await photoviewer.triggerPhotoViewerAction("close");
if (t.browser.platform === "mobile") {
await t.eval(() => location.reload());
} else {
2022-04-15 15:46:25 +02:00
await toolbar.triggerToolbarAction("reload");
}
2022-04-15 15:46:25 +02:00
await photo.checkPhotoVisibility(FirstPhotoUid, false);
await photo.checkPhotoVisibility(FirstVideoUid, false);
await photo.checkPhotoVisibility(SecondPhotoUid, false);
});
2022-04-15 15:46:25 +02:00
test.meta("testID", "photos-005").meta({ type: "smoke" })("Edit photo/video", async (t) => {
await toolbar.setFilter("view", "Cards");
const FirstPhotoUid = await photo.getNthPhotoUid("image", 0);
await t.click(page.cardTitle.withAttribute("data-uid", FirstPhotoUid));
await t.expect(photoedit.latitude.visible).ok();
await t.click(photoedit.dialogNext);
2021-01-15 17:02:39 +01:00
2022-04-15 15:46:25 +02:00
await t.expect(photoedit.dialogPrevious.getAttribute("disabled")).notEql("disabled");
await t.click(photoedit.dialogPrevious).click(photoedit.dialogClose);
await photoviewer.openPhotoViewer("uid", FirstPhotoUid);
await photoviewer.triggerPhotoViewerAction("edit");
const FirstPhotoTitle = await photoedit.title.value;
const FirstPhotoLocalTime = await photoedit.localTime.value;
const FirstPhotoDay = await photoedit.day.value;
const FirstPhotoMonth = await photoedit.month.value;
const FirstPhotoYear = await photoedit.year.value;
const FirstPhotoTimezone = await photoedit.timezone.value;
const FirstPhotoLatitude = await photoedit.latitude.value;
const FirstPhotoLongitude = await photoedit.longitude.value;
const FirstPhotoAltitude = await photoedit.altitude.value;
const FirstPhotoCountry = await photoedit.country.value;
const FirstPhotoCamera = await photoedit.camera.innerText;
const FirstPhotoIso = await photoedit.iso.value;
const FirstPhotoExposure = await photoedit.exposure.value;
const FirstPhotoLens = await photoedit.lens.innerText;
const FirstPhotoFnumber = await photoedit.fnumber.value;
const FirstPhotoFocalLength = await photoedit.focallength.value;
const FirstPhotoSubject = await photoedit.subject.value;
const FirstPhotoArtist = await photoedit.artist.value;
const FirstPhotoCopyright = await photoedit.copyright.value;
const FirstPhotoLicense = await photoedit.license.value;
const FirstPhotoDescription = await photoedit.description.value;
const FirstPhotoKeywords = await photoedit.keywords.value;
const FirstPhotoNotes = await photoedit.notes.value;
2021-01-15 17:02:39 +01:00
await t
2022-04-15 15:46:25 +02:00
.typeText(photoedit.title, "Not saved photo title", { replace: true })
.click(photoedit.detailsClose)
.click(Selector("button.action-date-edit").withAttribute("data-uid", FirstPhotoUid));
await t.expect(photoedit.title.value).eql(FirstPhotoTitle);
await photoedit.editPhoto(
2021-10-28 10:49:56 +02:00
"New Photo Title",
"Europe/Moscow",
"15",
"07",
"2019",
"04:30:30",
"-1",
"41.15333",
"20.168331",
"32",
"1/32",
"29",
"33",
"Super nice edited photo",
"Happy",
"Happy2020",
"Super nice cat license",
"Description of a nice image :)",
", cat, love",
"Some notes"
2021-02-15 15:56:56 +01:00
);
if (t.browser.platform === "mobile") {
await t.eval(() => location.reload());
} else {
2022-04-15 15:46:25 +02:00
await toolbar.triggerToolbarAction("reload");
}
2022-04-15 15:46:25 +02:00
2021-01-15 17:02:39 +01:00
await t
2022-04-15 15:46:25 +02:00
.expect(page.cardTitle.withAttribute("data-uid", FirstPhotoUid).innerText)
2021-01-15 17:02:39 +01:00
.eql("New Photo Title");
2022-04-15 15:46:25 +02:00
await photo.triggerHoverAction("uid", FirstPhotoUid, "select");
await contextmenu.triggerContextMenuAction("edit", "");
//const expectedValues = [{ FirstPhotoTitle: photoedit.title }, { "bluh bla": photoedit.day }];
/*const expectedValues = [
[FirstPhotoTitle, photoedit.title],
["blah", photoedit.day],
];
await photoedit.checkEditFormValuesNewNew(expectedValues);*/
await photoedit.checkEditFormValues(
2021-10-28 10:49:56 +02:00
"New Photo Title",
"15",
"07",
"2019",
"04:30:30",
"Europe/Moscow",
"Albania",
"-1",
"",
"",
"",
"32",
"1/32",
"",
"29",
"33",
"Super nice edited photo",
"Happy",
"Happy2020",
"Super nice cat license",
"Description of a nice image :)",
"cat",
2022-04-15 15:46:25 +02:00
"Some notes"
2021-10-28 10:49:56 +02:00
);
2022-04-15 15:46:25 +02:00
await photoedit.undoPhotoEdit(
2021-10-28 10:49:56 +02:00
FirstPhotoTitle,
FirstPhotoTimezone,
FirstPhotoDay,
FirstPhotoMonth,
FirstPhotoYear,
FirstPhotoLocalTime,
FirstPhotoAltitude,
FirstPhotoLatitude,
FirstPhotoLongitude,
FirstPhotoCountry,
FirstPhotoIso,
FirstPhotoExposure,
FirstPhotoFnumber,
FirstPhotoFocalLength,
FirstPhotoSubject,
FirstPhotoArtist,
FirstPhotoCopyright,
FirstPhotoLicense,
FirstPhotoDescription,
FirstPhotoKeywords,
FirstPhotoNotes
);
2022-04-15 15:46:25 +02:00
await contextmenu.checkContextMenuCount("1");
await contextmenu.clearSelection();
2020-10-20 18:10:38 +02:00
});
2022-04-15 15:46:25 +02:00
test.skip.meta("testID", "photos-006")("Navigate from card view to place", async (t) => {
await toolbar.setFilter("view", "Cards");
await t.click(page.cardLocation.nth(0));
2021-01-15 17:02:39 +01:00
await t
.expect(Selector("#map").exists, { timeout: 15000 })
.ok()
.expect(Selector("div.p-map-control").visible)
.ok()
.expect(Selector(".input-search input").value)
.notEql("");
2020-05-31 19:31:48 +02:00
});
2022-04-15 15:46:25 +02:00
test.meta("testID", "photos-007")("Mark photos/videos as panorama/scan", async (t) => {
const FirstPhotoUid = await photo.getNthPhotoUid("image", 0);
const FirstVideoUid = await photo.getNthPhotoUid("video", 1);
await menu.openPage("scans");
2022-04-15 15:46:25 +02:00
await photo.checkPhotoVisibility(FirstPhotoUid, false);
await photo.checkPhotoVisibility(FirstVideoUid, false);
2021-01-20 17:13:42 +01:00
2022-04-15 15:46:25 +02:00
await menu.openPage("panoramas");
await photo.checkPhotoVisibility(FirstPhotoUid, false);
await photo.checkPhotoVisibility(FirstVideoUid, false);
await menu.openPage("browse");
await photo.triggerHoverAction("uid", FirstPhotoUid, "select");
await photo.triggerHoverAction("uid", FirstVideoUid, "select");
await contextmenu.triggerContextMenuAction("edit", "");
await photoedit.turnSwitchOn("scan");
await photoedit.turnSwitchOn("panorama");
await t.click(photoedit.dialogNext);
await photoedit.turnSwitchOn("scan");
await photoedit.turnSwitchOn("panorama");
await t.click(photoedit.dialogClose);
await contextmenu.clearSelection();
await photo.checkPhotoVisibility(FirstPhotoUid, true);
await photo.checkPhotoVisibility(FirstVideoUid, true);
await menu.openPage("scans");
await photo.checkPhotoVisibility(FirstPhotoUid, true);
await photo.checkPhotoVisibility(FirstVideoUid, false);
await menu.openPage("panoramas");
await photo.checkPhotoVisibility(FirstPhotoUid, true);
await photo.checkPhotoVisibility(FirstVideoUid, true);
await photo.triggerHoverAction("uid", FirstPhotoUid, "select");
await photo.triggerHoverAction("uid", FirstVideoUid, "select");
await contextmenu.triggerContextMenuAction("edit", "");
await photoedit.turnSwitchOff("scan");
await photoedit.turnSwitchOff("panorama");
await t.click(photoedit.dialogNext);
await photoedit.turnSwitchOff("scan");
await photoedit.turnSwitchOff("panorama");
await t.click(photoedit.dialogClose);
await toolbar.triggerToolbarAction("reload");
await contextmenu.clearSelection();
await photo.checkPhotoVisibility(FirstPhotoUid, false);
await photo.checkPhotoVisibility(FirstVideoUid, false);
2021-01-25 19:12:25 +01:00
});