11// Browser tests cover pw role snapshot plugin behavior.
22import { describe , expect , it } from "vitest" ;
33import {
4- annotateRoleSnapshotDelta ,
54 buildRoleSnapshotFromAiSnapshot ,
65 buildRoleSnapshotFromAriaSnapshot ,
76 finalizeRoleSnapshot ,
@@ -137,7 +136,7 @@ describe("pw-role-snapshot", () => {
137136 const snapshot = '- button "Save" [ref=e1]' ;
138137 const refs = { e1 : { role : "button" , name : "Save" } } ;
139138
140- const result = annotateRoleSnapshotDelta ( { snapshot, refs, mode : "role" } ) ;
139+ const result = finalizeRoleSnapshot ( { snapshot, refs, delta : { mode : "role" } } ) ;
141140
142141 expect ( result . snapshot ) . toBe ( snapshot ) ;
143142 expect ( result . newElements ) . toBeUndefined ( ) ;
@@ -152,39 +151,36 @@ describe("pw-role-snapshot", () => {
152151 e7 : { role : "button" , name : "Save" } ,
153152 e8 : { role : "dialog" , name : "Confirmation" } ,
154153 } ;
155- const annotated = annotateRoleSnapshotDelta ( {
154+ const finalized = finalizeRoleSnapshot ( {
156155 snapshot : [ '- button "Save" [ref=e7]' , '- dialog "Confirmation" [ref=e8]' ] . join ( "\n" ) ,
157156 refs,
158- mode : "role" ,
159- previousKeys,
157+ delta : { mode : "role" , previousKeys } ,
160158 } ) ;
161- const finalized = finalizeRoleSnapshot ( { snapshot : annotated . snapshot , refs } ) ;
162159
163- expect ( annotated . snapshot ) . toBe (
160+ expect ( finalized . snapshot ) . toBe (
164161 [
165162 '- button "Save" [ref=e7]' ,
166163 '- dialog "Confirmation" [ref=e8] [new]' ,
167164 "1 new element(s) since last snapshot" ,
168165 ] . join ( "\n" ) ,
169166 ) ;
170- expect ( annotated . newElements ) . toBe ( 1 ) ;
167+ expect ( finalized . newElements ) . toBe ( 1 ) ;
171168 expect ( finalized . refs ) . toEqual ( refs ) ;
172169 } ) ;
173170
174171 it ( "uses preserved aria refs as AI snapshot identities" , ( ) => {
175- const annotated = annotateRoleSnapshotDelta ( {
172+ const finalized = finalizeRoleSnapshot ( {
176173 snapshot : [ '- button "Save" [ref=7]' , '- dialog "Confirmation" [ref=8]' ] . join ( "\n" ) ,
177174 refs : {
178175 "7" : { role : "button" , name : "Save" } ,
179176 "8" : { role : "dialog" , name : "Confirmation" } ,
180177 } ,
181- mode : "aria" ,
182- previousKeys : new Set ( [ "7" ] ) ,
178+ delta : { mode : "aria" , previousKeys : new Set ( [ "7" ] ) } ,
183179 } ) ;
184180
185- expect ( annotated . snapshot ) . toContain ( '- button "Save" [ref=7]\n' ) ;
186- expect ( annotated . snapshot ) . toContain ( '- dialog "Confirmation" [ref=8] [new]' ) ;
187- expect ( annotated . newElements ) . toBe ( 1 ) ;
181+ expect ( finalized . snapshot ) . toContain ( '- button "Save" [ref=7]\n' ) ;
182+ expect ( finalized . snapshot ) . toContain ( '- dialog "Confirmation" [ref=8] [new]' ) ;
183+ expect ( finalized . newElements ) . toBe ( 1 ) ;
188184 } ) ;
189185
190186 it ( "annotates before truncation and keeps only complete annotated refs" , ( ) => {
0 commit comments