@@ -5,8 +5,8 @@ import type { SessionHistory, RecordedStep } from '../../src/types/recording';
55
66const START_BROWSER_STEP : RecordedStep = {
77 index : 1 ,
8- tool : 'start_browser ' ,
9- params : { browser : 'chrome' , headless : true , windowWidth : 1920 , windowHeight : 1080 } ,
8+ tool : 'start_session ' ,
9+ params : { platform : 'browser' , browser : 'chrome' , headless : true , windowWidth : 1920 , windowHeight : 1080 } ,
1010 status : 'ok' ,
1111 durationMs : 0 ,
1212 timestamp : '2026-01-01T00:00:00.000Z' ,
@@ -35,14 +35,13 @@ function makeHistory(steps: Partial<RecordedStep>[]): SessionHistory {
3535}
3636
3737describe ( 'generateCode - header' , ( ) => {
38- it ( 'wraps output in remote() setup and deleteSession ' , ( ) => {
38+ it ( 'wraps output in remote() setup' , ( ) => {
3939 const code = generateCode ( makeHistory ( [ ] ) ) ;
4040 expect ( code ) . toContain ( "import { remote } from 'webdriverio';" ) ;
41- expect ( code ) . toContain ( 'await browser.deleteSession();' ) ;
4241 expect ( code ) . toContain ( 'browserName' ) ;
4342 } ) ;
4443
45- it ( 'generates start_browser using history.capabilities, not reconstructed from params ' , ( ) => {
44+ it ( 'generates start_session (browser) using history.capabilities' , ( ) => {
4645 const history : SessionHistory = {
4746 sessionId : 'caps-123' ,
4847 type : 'browser' ,
@@ -54,8 +53,8 @@ describe('generateCode - header', () => {
5453 } ,
5554 steps : [ {
5655 index : 1 ,
57- tool : 'start_browser ' ,
58- params : { browser : 'chrome' , headless : true } ,
56+ tool : 'start_session ' ,
57+ params : { platform : 'browser' , browser : 'chrome' , headless : true } ,
5958 status : 'ok' ,
6059 durationMs : 100 ,
6160 timestamp : '2026-01-01T00:00:00.000Z' ,
@@ -64,10 +63,10 @@ describe('generateCode - header', () => {
6463 const code = generateCode ( history ) ;
6564 expect ( code ) . toContain ( 'const browser = await remote(' ) ;
6665 expect ( code ) . toContain ( '"browserName": "chrome"' ) ;
67- expect ( code ) . toContain ( '--custom-flag' ) ; // only present in history.capabilities
66+ expect ( code ) . toContain ( '--custom-flag' ) ;
6867 } ) ;
6968
70- it ( 'generates attach_browser using history.capabilities' , ( ) => {
69+ it ( 'generates start_session (attach mode) using history.capabilities' , ( ) => {
7170 const history : SessionHistory = {
7271 sessionId : 'attach-123' ,
7372 type : 'browser' ,
@@ -78,8 +77,8 @@ describe('generateCode - header', () => {
7877 } ,
7978 steps : [ {
8079 index : 1 ,
81- tool : 'attach_browser ' ,
82- params : { port : 9222 , host : 'localhost' , userDataDir : '/tmp/chrome-debug' } ,
80+ tool : 'start_session ' ,
81+ params : { platform : 'browser' , attach : true , port : 9222 , host : 'localhost' , userDataDir : '/tmp/chrome-debug' } ,
8382 status : 'ok' ,
8483 durationMs : 100 ,
8584 timestamp : '2026-01-01T00:00:00.000Z' ,
@@ -91,16 +90,16 @@ describe('generateCode - header', () => {
9190 expect ( code ) . toContain ( '--user-data-dir=/tmp/chrome-debug' ) ;
9291 } ) ;
9392
94- it ( 'appends browser.url() when navigationUrl is set on start_browser ' , ( ) => {
93+ it ( 'appends browser.url() when navigationUrl is set on start_session (browser) ' , ( ) => {
9594 const history : SessionHistory = {
9695 sessionId : 'nav-123' ,
9796 type : 'browser' ,
9897 startedAt : '2026-01-01T00:00:00.000Z' ,
9998 capabilities : { browserName : 'chrome' } ,
10099 steps : [ {
101100 index : 1 ,
102- tool : 'start_browser ' ,
103- params : { browser : 'chrome' , headless : false , windowWidth : 1920 , windowHeight : 1080 , navigationUrl : 'https://github.com/login' } ,
101+ tool : 'start_session ' ,
102+ params : { platform : 'browser' , browser : 'chrome' , headless : false , windowWidth : 1920 , windowHeight : 1080 , navigationUrl : 'https://github.com/login' } ,
104103 status : 'ok' ,
105104 durationMs : 0 ,
106105 timestamp : '2026-01-01T00:00:00.000Z' ,
@@ -110,7 +109,7 @@ describe('generateCode - header', () => {
110109 expect ( code ) . toContain ( "await browser.url('https://github.com/login');" ) ;
111110 } ) ;
112111
113- it ( 'generates start_app_session using history.appiumConfig for connection config' , ( ) => {
112+ it ( 'generates start_session (mobile) using history.appiumConfig for connection config' , ( ) => {
114113 const history : SessionHistory = {
115114 sessionId : 'app-123' ,
116115 type : 'android' ,
@@ -123,15 +122,15 @@ describe('generateCode - header', () => {
123122 appiumConfig : { hostname : '127.0.0.1' , port : 4723 , path : '/' } ,
124123 steps : [ {
125124 index : 1 ,
126- tool : 'start_app_session ' ,
127- params : { platform : 'Android ' , deviceName : 'emulator-5554' } , // no appiumHost in params
125+ tool : 'start_session ' ,
126+ params : { platform : 'android ' , deviceName : 'emulator-5554' } ,
128127 status : 'ok' ,
129128 durationMs : 100 ,
130129 timestamp : '2026-01-01T00:00:00.000Z' ,
131130 } ] ,
132131 } ;
133132 const code = generateCode ( history ) ;
134- expect ( code ) . toContain ( '"hostname": "127.0.0.1"' ) ; // from history.appiumConfig, not params fallback
133+ expect ( code ) . toContain ( '"hostname": "127.0.0.1"' ) ;
135134 expect ( code ) . toContain ( '"port": 4723' ) ;
136135 expect ( code ) . toContain ( '"platformName": "Android"' ) ;
137136 } ) ;
0 commit comments