@@ -40,6 +40,52 @@ function makeElement(
4040 } as Element ;
4141}
4242
43+ describe ( 'AgentRuntime.beginStep() stepId format' , ( ) => {
44+ it ( 'generates stepId in step-N format' , ( ) => {
45+ const sink = new MockSink ( ) ;
46+ const tracer = new Tracer ( 'test-run' , sink ) ;
47+ const page = new MockPage ( 'https://example.com' ) as any ;
48+ const browserLike = {
49+ snapshot : async ( ) => ( {
50+ status : 'success' ,
51+ url : 'https://example.com' ,
52+ elements : [ ] ,
53+ timestamp : 't1' ,
54+ } ) ,
55+ } ;
56+
57+ const runtime = new AgentRuntime ( browserLike as any , page as any , tracer ) ;
58+
59+ const stepId1 = runtime . beginStep ( 'Step 1' ) ;
60+ expect ( stepId1 ) . toBe ( 'step-1' ) ;
61+ expect ( runtime . stepIndex ) . toBe ( 1 ) ;
62+
63+ const stepId2 = runtime . beginStep ( 'Step 2' ) ;
64+ expect ( stepId2 ) . toBe ( 'step-2' ) ;
65+ expect ( runtime . stepIndex ) . toBe ( 2 ) ;
66+ } ) ;
67+
68+ it ( 'generates stepId matching explicit stepIndex' , ( ) => {
69+ const sink = new MockSink ( ) ;
70+ const tracer = new Tracer ( 'test-run' , sink ) ;
71+ const page = new MockPage ( 'https://example.com' ) as any ;
72+ const browserLike = {
73+ snapshot : async ( ) => ( {
74+ status : 'success' ,
75+ url : 'https://example.com' ,
76+ elements : [ ] ,
77+ timestamp : 't1' ,
78+ } ) ,
79+ } ;
80+
81+ const runtime = new AgentRuntime ( browserLike as any , page as any , tracer ) ;
82+
83+ const stepId = runtime . beginStep ( 'Custom step' , 10 ) ;
84+ expect ( stepId ) . toBe ( 'step-10' ) ;
85+ expect ( runtime . stepIndex ) . toBe ( 10 ) ;
86+ } ) ;
87+ } ) ;
88+
4389describe ( 'AgentRuntime.assert() with state predicates' , ( ) => {
4490 it ( 'uses snapshot context for enabled/disabled/value assertions' , ( ) => {
4591 const sink = new MockSink ( ) ;
0 commit comments