photoprism/frontend/tests/acceptance/people.js

281 lines
10 KiB
JavaScript
Raw Normal View History

2021-09-23 22:03:11 +02:00
import { Selector } from "testcafe";
import testcafeconfig from "./testcafeconfig";
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 Subject from "../page-model/subject";
import PhotoEdit from "../page-model/photo-edit";
2021-09-23 22:03:11 +02:00
fixture`Test people`.page`${testcafeconfig.url}`;
2021-09-23 22:03:11 +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 subject = new Subject();
const photoedit = new PhotoEdit();
2021-09-23 22:03:11 +02:00
2022-04-15 15:46:25 +02:00
test.meta("testID", "people-001").meta({ type: "smoke" })(
"Add name to new face and rename subject",
2021-09-23 22:03:11 +02:00
async (t) => {
2022-04-15 15:46:25 +02:00
await menu.openPage("people");
await t.click(subject.newTab);
await subject.triggerToolbarAction("reload", "");
const FaceCount = await subject.getFaceCount();
await t.click(subject.recognizedTab);
const SubjectCount = await subject.getSubjectCount();
await t.click(subject.newTab);
const FirstFaceID = await subject.getNthFaceUid(0);
await subject.openFaceWithUid(FirstFaceID);
const PhotosInFaceCount = await photo.getPhotoCount("all");
await menu.openPage("people");
await t.click(subject.newTab);
await subject.addNameToFace(FirstFaceID, "Jane Doe");
await subject.triggerToolbarAction("reload");
const FaceCountAfterAdd = await subject.getFaceCount();
await t.expect(FaceCountAfterAdd).eql(FaceCount - 1);
await t.click(subject.recognizedTab);
await subject.checkFaceVisibility(FirstFaceID, false);
await t.eval(() => location.reload());
await t.wait(6000);
const SubjectCountAfterAdd = await subject.getSubjectCount();
await t.expect(SubjectCountAfterAdd).eql(SubjectCount + 1);
await toolbar.search("Jane");
const JaneUID = await subject.getNthSubjectUid(0);
await t
.expect(Selector("a[data-uid=" + JaneUID + "] div.caption").innerText)
.contains(PhotosInFaceCount.toString());
await subject.openSubjectWithUid(JaneUID);
const PhotosInSubjectCount = await photo.getPhotoCount("all");
await t.expect(PhotosInFaceCount).eql(PhotosInSubjectCount);
await photo.triggerHoverAction("nth", 0, "select");
await photo.triggerHoverAction("nth", 1, "select");
await photo.triggerHoverAction("nth", 2, "select");
await contextmenu.triggerContextMenuAction("edit", "");
await t.click(photoedit.peopleTab);
await t.expect(photoedit.inputName.nth(0).value).contains("Jane Doe");
await t.click(photoedit.dialogClose);
await menu.openPage("people");
await subject.renameSubject(JaneUID, "Max Mu");
await t
.expect(Selector("a[data-uid=" + JaneUID + "] div.v-card__title").innerText)
.contains("Max Mu");
await subject.openSubjectWithUid(JaneUID);
await t.eval(() => location.reload());
await contextmenu.checkContextMenuCount("3");
await contextmenu.triggerContextMenuAction("edit", "");
await t.click(photoedit.peopleTab);
await t.expect(photoedit.inputName.nth(0).value).contains("Max Mu");
await t.click(photoedit.dialogNext);
await t.expect(photoedit.inputName.nth(0).value).contains("Max Mu").click(photoedit.dialogNext);
await t
.expect(photoedit.inputName.nth(0).value)
.contains("Max Mu")
.click(photoedit.dialogClose);
await contextmenu.clearSelection();
await toolbar.search("person:max-mu");
const PhotosInSubjectAfterRenameCount = await photo.getPhotoCount("all");
await t.expect(PhotosInSubjectAfterRenameCount).eql(PhotosInSubjectCount);
}
);
test.meta("testID", "people-002").meta({ type: "smoke" })(
"Add + Reject name on people tab",
async (t) => {
await menu.openPage("people");
await t.click(subject.newTab);
await subject.triggerToolbarAction("reload");
const FirstFaceID = await subject.getNthFaceUid(0);
await subject.addNameToFace(FirstFaceID, "Andrea Doe");
await t.click(subject.recognizedTab);
await toolbar.search("Andrea");
const AndreaUID = await subject.getNthSubjectUid(0);
await subject.openSubjectWithUid(AndreaUID);
await t.eval(() => location.reload());
2021-09-23 22:03:11 +02:00
await t.wait(5000);
2022-04-15 15:46:25 +02:00
const PhotosInAndreaCount = await photo.getPhotoCount("all");
await photo.triggerHoverAction("nth", 1, "select");
await contextmenu.triggerContextMenuAction("edit", "");
await t
.click(photoedit.peopleTab)
.expect(photoedit.inputName.nth(0).value)
.eql("Andrea Doe")
.click(photoedit.rejectName.nth(0));
await t.expect(photoedit.inputName.nth(0).value).eql("");
await t
.typeText(photoedit.inputName.nth(0), "Nicole", { replace: true })
.pressKey("enter")
.click(photoedit.dialogClose);
await contextmenu.clearSelection();
await t.eval(() => location.reload());
await t.wait(5000);
const PhotosInAndreaAfterRejectCount = await photo.getPhotoCount("all");
const Diff = PhotosInAndreaCount - PhotosInAndreaAfterRejectCount;
await toolbar.search("person:nicole");
await t.eval(() => location.reload());
await t.wait(5000);
const PhotosInNicoleCount = await photo.getPhotoCount("all");
await t.expect(Diff).gte(PhotosInNicoleCount);
2021-09-23 22:03:11 +02:00
}
);
2022-04-15 15:46:25 +02:00
test.meta("testID", "people-003")("Test mark subject as favorite", async (t) => {
await menu.openPage("people");
const FirstSubjectUid = await subject.getNthSubjectUid(0);
const SecondSubjectUid = await subject.getNthSubjectUid(1);
await subject.triggerHoverAction("uid", SecondSubjectUid, "favorite");
await subject.triggerToolbarAction("reload");
const FirstSubjectUidAfterFavorite = await subject.getNthSubjectUid(0);
await t.expect(FirstSubjectUid).notEql(FirstSubjectUidAfterFavorite);
await t.expect(SecondSubjectUid).eql(FirstSubjectUidAfterFavorite);
await subject.checkHoverActionState("uid", SecondSubjectUid, "favorite", true);
await subject.triggerHoverAction("uid", SecondSubjectUid, "favorite");
await subject.checkHoverActionState("uid", SecondSubjectUid, "favorite", false);
2021-09-23 22:03:11 +02:00
});
2022-04-15 15:46:25 +02:00
test.meta("testID", "people-004")("Test new face autocomplete", async (t) => {
await menu.openPage("people");
await t.click(subject.newTab);
await subject.triggerToolbarAction("reload");
const FirstFaceID = await subject.getNthFaceUid(0);
2021-09-23 22:03:11 +02:00
await t
.expect(Selector("div.menuable__content__active").nth(0).visible)
.notOk()
.click(Selector("div[data-id=" + FirstFaceID + "] div.input-name input"))
2022-04-15 15:46:25 +02:00
.typeText(Selector("div[data-id=" + FirstFaceID + "] div.input-name input"), "Otto");
2021-09-23 22:03:11 +02:00
await t
2022-04-15 15:46:25 +02:00
.expect(Selector("div.menuable__content__active").nth(0).withText("Otto Visible").visible)
.ok();
2021-09-23 22:03:11 +02:00
});
2021-09-24 17:17:24 +02:00
2022-04-15 15:46:25 +02:00
test.meta("testID", "people-005")("Remove face", async (t) => {
await toolbar.search("face:new");
const FirstPhotoUid = await photo.getNthPhotoUid("all", 0);
await photo.triggerHoverAction("nth", 0, "select");
await contextmenu.triggerContextMenuAction("edit", "");
await t.click(photoedit.peopleTab);
const MarkerCount = await subject.getMarkerCount();
if ((await photoedit.inputName.nth(0).value) == "") {
2021-09-24 17:17:24 +02:00
await t
2022-04-15 15:46:25 +02:00
.expect(photoedit.undoRemoveMarker.nth(0).visible)
2021-09-24 17:17:24 +02:00
.notOk()
2022-04-15 15:46:25 +02:00
.expect(photoedit.inputName.nth(0).value)
2021-09-24 17:17:24 +02:00
.eql("")
2022-04-15 15:46:25 +02:00
.click(photoedit.removeMarker)
.expect(photoedit.undoRemoveMarker.nth(0).visible)
2021-09-24 17:17:24 +02:00
.ok()
2022-04-15 15:46:25 +02:00
.click(photoedit.undoRemoveMarker);
} else if ((await photoedit.inputName.nth(0).value) != "") {
2021-09-24 17:17:24 +02:00
await t
2022-04-15 15:46:25 +02:00
.expect(photoedit.inputName.nth(1).value)
2021-09-24 17:17:24 +02:00
.eql("")
2022-04-15 15:46:25 +02:00
.click(photoedit.removeMarker)
.expect(photoedit.undoRemoveMarker.nth(0).visible)
2021-09-24 17:17:24 +02:00
.ok()
2022-04-15 15:46:25 +02:00
.click(photoedit.undoRemoveMarker);
2021-09-24 17:17:24 +02:00
}
2022-04-15 15:46:25 +02:00
await t.click(photoedit.dialogClose);
await contextmenu.clearSelection();
2021-09-24 17:17:24 +02:00
await t.eval(() => location.reload());
2022-04-15 15:46:25 +02:00
await t.wait(5000);
await photo.triggerHoverAction("uid", FirstPhotoUid, "select");
await contextmenu.triggerContextMenuAction("edit", "");
await t.click(photoedit.peopleTab);
if ((await photoedit.inputName.nth(0).value) == "") {
2021-09-24 17:17:24 +02:00
await t
2022-04-15 15:46:25 +02:00
.expect(photoedit.undoRemoveMarker.nth(0).visible)
2021-09-24 17:17:24 +02:00
.notOk()
2022-04-15 15:46:25 +02:00
.expect(photoedit.inputName.nth(0).value)
2021-09-24 17:17:24 +02:00
.eql("")
2022-04-15 15:46:25 +02:00
.click(photoedit.removeMarker)
.expect(photoedit.undoRemoveMarker.nth(0).visible)
2021-09-24 17:17:24 +02:00
.ok();
2022-04-15 15:46:25 +02:00
} else if ((await photoedit.inputName.nth(0).value) != "") {
2021-09-24 17:17:24 +02:00
await t
2022-04-15 15:46:25 +02:00
.expect(photoedit.undoRemoveMarker.nth(0).visible)
2021-09-24 17:17:24 +02:00
.notOk()
2022-04-15 15:46:25 +02:00
.expect(photoedit.inputName.nth(1).value)
2021-09-24 17:17:24 +02:00
.eql("")
2022-04-15 15:46:25 +02:00
.click(photoedit.removeMarker)
.expect(photoedit.undoRemoveMarker.nth(0).visible)
2021-09-24 17:17:24 +02:00
.ok();
}
2022-04-15 15:46:25 +02:00
await t.click(photoedit.dialogClose);
2021-09-24 17:17:24 +02:00
await t.eval(() => location.reload());
2022-04-15 15:46:25 +02:00
await contextmenu.triggerContextMenuAction("edit", "");
await t.click(photoedit.peopleTab);
const MarkerCountAfterRemove = await subject.getMarkerCount();
2021-09-24 17:17:24 +02:00
await t.expect(MarkerCountAfterRemove).eql(MarkerCount - 1);
});
2022-04-15 15:46:25 +02:00
test.meta("testID", "people-006")("Hide face", async (t) => {
await menu.openPage("people");
await t.click(subject.newTab);
await subject.triggerToolbarAction("reload");
const FirstFaceID = await subject.getNthFaceUid(0);
await subject.checkFaceVisibility(FirstFaceID, true);
await subject.triggerHoverAction("id", FirstFaceID, "hidden");
2021-10-06 18:22:12 +02:00
await t.eval(() => location.reload());
2022-04-15 15:46:25 +02:00
await t.wait(5000);
await subject.checkFaceVisibility(FirstFaceID, false);
await subject.triggerToolbarAction("show-hidden");
2021-09-24 17:17:24 +02:00
await t.eval(() => location.reload());
2022-04-15 15:46:25 +02:00
await t.wait(6000);
await subject.checkFaceVisibility(FirstFaceID, true);
await subject.triggerHoverAction("id", FirstFaceID, "hidden");
await subject.triggerToolbarAction("exclude-hidden");
2021-10-06 18:22:12 +02:00
await t.eval(() => location.reload());
2022-04-15 15:46:25 +02:00
await t.wait(6000);
await subject.checkFaceVisibility(FirstFaceID, true);
2021-10-06 18:22:12 +02:00
});
2022-04-15 15:46:25 +02:00
test.meta("testID", "people-007")("Hide person", async (t) => {
await menu.openPage("people");
await t.click(subject.recognizedTab);
const FirstPersonUid = await subject.getNthSubjectUid(0);
await subject.checkSubjectVisibility("uid", FirstPersonUid, true);
await subject.triggerHoverAction("uid", FirstPersonUid, "hidden");
2021-10-06 18:22:12 +02:00
await t.eval(() => location.reload());
2022-04-15 15:46:25 +02:00
await t.wait(6000);
await subject.checkSubjectVisibility("uid", FirstPersonUid, false);
await subject.triggerToolbarAction("show-hidden");
2021-10-06 18:22:12 +02:00
await t.eval(() => location.reload());
2022-04-15 15:46:25 +02:00
await t.wait(6000);
await subject.checkSubjectVisibility("uid", FirstPersonUid, true);
await subject.triggerHoverAction("uid", FirstPersonUid, "hidden");
await subject.triggerToolbarAction("exclude-hidden");
2021-10-06 18:22:12 +02:00
await t.eval(() => location.reload());
2022-04-15 15:46:25 +02:00
await t.wait(5000);
await subject.checkSubjectVisibility("uid", FirstPersonUid, true);
2021-09-24 17:17:24 +02:00
});