@@ -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