Skip to content

Commit cfb3fd1

Browse files
committed
Tests: Adapt tests to changes
1 parent e6dd202 commit cfb3fd1

File tree

3 files changed

+46
-26
lines changed

3 files changed

+46
-26
lines changed

frontend/tests/acceptance/acceptance-public/people.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,13 @@ test.meta("testID", "people-005").meta({ mode: "public" })("Common: Remove face"
185185
await t.click(photoedit.peopleTab);
186186
const MarkerCount = await subject.getMarkerCount();
187187

188-
if ((await photoedit.inputName.nth(0).value) == "") {
188+
if ((await photoedit.inputName.nth(0).value) === "") {
189189
await t.expect(photoedit.undoRemoveMarker.nth(0).visible).notOk();
190190
await t.expect(photoedit.inputName.nth(0).value).eql("");
191191
await photoedit.removeFace();
192192
await t.expect(photoedit.undoRemoveMarker.nth(0).visible).ok();
193193
await t.click(photoedit.undoRemoveMarker);
194-
} else if ((await photoedit.inputName.nth(0).value) != "") {
194+
} else if ((await photoedit.inputName.nth(0).value) !== "") {
195195
await t.expect(photoedit.inputName.nth(1).value).eql("");
196196
await photoedit.removeFace(1);
197197
await t.expect(photoedit.undoRemoveMarker.nth(0).visible).ok();
@@ -206,12 +206,12 @@ test.meta("testID", "people-005").meta({ mode: "public" })("Common: Remove face"
206206
await contextmenu.triggerContextMenuAction("edit", "");
207207
await t.click(photoedit.peopleTab);
208208

209-
if ((await photoedit.inputName.nth(0).value) == "") {
209+
if ((await photoedit.inputName.nth(0).value) === "") {
210210
await t.expect(photoedit.undoRemoveMarker.nth(0).visible).notOk();
211211
await t.expect(photoedit.inputName.nth(0).value).eql("");
212212
await photoedit.removeFace();
213213
await t.expect(photoedit.undoRemoveMarker.nth(0).visible).ok();
214-
} else if ((await photoedit.inputName.nth(0).value) != "") {
214+
} else if ((await photoedit.inputName.nth(0).value) !== "") {
215215
await t.expect(photoedit.undoRemoveMarker.nth(0).visible).notOk();
216216
await t.expect(photoedit.inputName.nth(1).value).eql("");
217217
await photoedit.removeFace();

frontend/tests/acceptance/page-model/photo-edit.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export default class Page {
6868

6969
this.rejectName = Selector("i.mdi-eject", { timeout: 15000 });
7070
this.faceActionMenuButton = Selector(".p-faces .p-action-menu .action-menu__btn", { timeout: 15000 });
71-
this.removeFaceAction = Selector(".v-list-item.action-remove-face, .action-remove-face", { timeout: 15000 });
71+
this.removeMarker = Selector("button.input-reject", { timeout: 15000 });
7272
this.goToPersonAction = Selector(".v-list-item.action-go-to-person, .action-go-to-person", { timeout: 15000 });
7373
this.setPersonCoverAction = Selector(".v-list-item.action-set-person-cover, .action-set-person-cover", {
7474
timeout: 15000,
@@ -166,8 +166,7 @@ export default class Page {
166166
}
167167

168168
async removeFace(index = 0) {
169-
await this.openFaceMenu(index);
170-
await t.click(this.removeFaceAction.nth(0));
169+
await t.click(this.removeMarker.nth(0));
171170
}
172171

173172
async goToPerson(index = 0) {

frontend/tests/vitest/component/photo/people-tab.test.js

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ describe("PTabPhotoPeople face actions", () => {
88
let wrapper;
99
let setCoverSpy;
1010
let windowOpenSpy;
11+
let assignedMarker;
12+
let unassignedMarker;
1113

1214
const mockPeople = [
1315
{
@@ -28,6 +30,22 @@ describe("PTabPhotoPeople face actions", () => {
2830

2931
windowOpenSpy = vi.spyOn(window, "open").mockImplementation(() => {});
3032

33+
assignedMarker = new Marker({
34+
UID: "marker-assigned",
35+
SubjUID: "js6sg6b2h8njw0sx",
36+
Invalid: false,
37+
Thumb: "hash-1234",
38+
Name: "John Doe",
39+
});
40+
41+
unassignedMarker = new Marker({
42+
UID: "marker-unassigned",
43+
SubjUID: "",
44+
Invalid: false,
45+
Thumb: "",
46+
Name: "",
47+
});
48+
3149
wrapper = mount(PeopleTab, {
3250
props: {
3351
uid: "test-photo-uid",
@@ -57,15 +75,7 @@ describe("PTabPhotoPeople face actions", () => {
5775
$view: {
5876
getData: vi.fn(() => ({
5977
model: {
60-
getMarkers: vi.fn(() => [
61-
new Marker({
62-
UID: "marker1",
63-
SubjUID: "js6sg6b2h8njw0sx",
64-
Invalid: false,
65-
Thumb: "hash-1234",
66-
Name: "John Doe",
67-
}),
68-
]),
78+
getMarkers: vi.fn(() => [assignedMarker, unassignedMarker]),
6979
},
7080
})),
7181
},
@@ -95,23 +105,35 @@ describe("PTabPhotoPeople face actions", () => {
95105
}
96106
});
97107

98-
it("provides go-to-person and set-cover actions for assigned faces", () => {
108+
it("provides go-to-person and set-cover actions for assigned faces", async () => {
99109
const marker = { SubjUID: "js6sg6b2h8njw0sx", Invalid: false, Thumb: "hash-1234" };
100110

101111
const actions = wrapper.vm.getFaceActions(marker);
102112
const visible = actions.filter((action) => action.visible).map((action) => action.name);
103113

104-
expect(visible).toEqual(expect.arrayContaining(["go-to-person", "set-person-cover"]));
105-
expect(actions.find((action) => action.name === "remove-face").visible).toBe(false);
114+
expect(visible).toEqual(["go-to-person", "set-person-cover"]);
115+
expect(actions.some((action) => action.name === "remove-face")).toBe(false);
116+
117+
wrapper.vm.markers = [assignedMarker];
118+
await wrapper.vm.$nextTick();
119+
120+
const removeButton = wrapper.find(`[data-id="${assignedMarker.UID}"] .action-reject`);
121+
expect(removeButton.exists()).toBe(false);
106122
});
107123

108-
it("shows remove-face action for unassigned faces only", () => {
124+
it("renders quick remove button for unassigned faces", async () => {
109125
const marker = { SubjUID: "", Invalid: false };
110126

111127
const actions = wrapper.vm.getFaceActions(marker);
112128
const visible = actions.filter((action) => action.visible).map((action) => action.name);
113129

114-
expect(visible).toEqual(["remove-face"]);
130+
expect(visible).toEqual([]);
131+
132+
wrapper.vm.markers = [unassignedMarker];
133+
await wrapper.vm.$nextTick();
134+
135+
const removeButton = wrapper.find(`[data-id="${unassignedMarker.UID}"] .action-reject`);
136+
expect(removeButton.exists()).toBe(true);
115137
});
116138

117139
it("opens subject route in new window when navigating to person", async () => {
@@ -159,14 +181,14 @@ describe("PTabPhotoPeople face actions", () => {
159181
expect(wrapper.vm.hasFaceMenu(marker)).toBe(false);
160182
});
161183

162-
it("returns true for unassigned valid faces (remove action)", () => {
184+
it("returns false for unassigned valid faces", () => {
163185
const marker = new Marker({
164186
UID: "marker3",
165187
SubjUID: "",
166188
Invalid: false,
167189
});
168190

169-
expect(wrapper.vm.hasFaceMenu(marker)).toBe(true);
191+
expect(wrapper.vm.hasFaceMenu(marker)).toBe(false);
170192
});
171193
});
172194

@@ -186,18 +208,17 @@ describe("PTabPhotoPeople face actions", () => {
186208

187209
// Check props
188210
expect(actionMenu.props("buttonIcon")).toBe("mdi-dots-vertical");
189-
expect(actionMenu.props("buttonClass")).toBe("input-reject");
211+
expect(actionMenu.props("buttonClass")).toBe("input-menu");
190212
expect(actionMenu.props("items")).toBeInstanceOf(Function);
191213

192214
// Call items function to verify it returns correct actions
193215
const actions = actionMenu.props("items")();
194216
expect(Array.isArray(actions)).toBe(true);
195-
expect(actions.length).toBe(3); // go-to-person, set-person-cover, remove-face
217+
expect(actions.length).toBe(2); // go-to-person, set-person-cover
196218

197219
const actionNames = actions.map((a) => a.name);
198220
expect(actionNames).toContain("go-to-person");
199221
expect(actionNames).toContain("set-person-cover");
200-
expect(actionNames).toContain("remove-face");
201222
});
202223
});
203224
});

0 commit comments

Comments
 (0)