@@ -609,8 +609,8 @@ async function existingLink(page: Page, route: string): Promise<Locator | null>
609609
610610function searchInput ( page : Page ) {
611611 return page
612- . getByRole ( 'combobox' )
613- . or ( page . getByRole ( 'searchbox' ) )
612+ . getByRole ( 'combobox' , { name : / S e a r c h / i } )
613+ . or ( page . getByRole ( 'searchbox' , { name : / S e a r c h / i } ) )
614614 . or ( page . getByPlaceholder ( / S e a r c h / ) )
615615 . filter ( { visible : true } )
616616 . first ( )
@@ -629,7 +629,7 @@ async function readyForControls(page: Page) {
629629 . click ( )
630630 }
631631 await input . waitFor ( )
632- await page . waitForFunction ( ( ) => document . activeElement instanceof HTMLInputElement )
632+ await expect ( input ) . toBeFocused ( )
633633 await page . keyboard . press ( 'Escape' )
634634 await input . waitFor ( { state : 'hidden' } )
635635}
@@ -940,11 +940,7 @@ async function interactions(browser: Browser, profile: Profile, repetition: numb
940940 const trigger = run . page
941941 . getByRole ( 'button' , { name : / ^ ( E x p a n d .* w o r k f l o w p r e v i e w | I n s p e c t w o r k f l o w : .* ) $ / i } )
942942 . first ( )
943- if ( ! ( await trigger . count ( ) ) )
944- return {
945- status : 'unavailable' ,
946- error : 'No named workflow inspection trigger on this baseline.' ,
947- }
943+ await trigger . waitFor ( { state : 'visible' , timeout : 15_000 } )
948944 await trigger . scrollIntoViewIfNeeded ( )
949945 const start = performance . now ( )
950946 await trigger . click ( )
@@ -1007,6 +1003,44 @@ async function interactions(browser: Browser, profile: Profile, repetition: numb
10071003 }
10081004}
10091005
1006+ async function tabControl (
1007+ run : Awaited < ReturnType < typeof contextFor > > ,
1008+ profile : Profile ,
1009+ repetition : number ,
1010+ route : string ,
1011+ control : { scenario : string ; label : string ; choice : RegExp }
1012+ ) {
1013+ await measure ( profile , route , repetition , control . scenario , async ( ) => {
1014+ const list = run . page . getByRole ( 'tablist' , { name : control . label , exact : true } )
1015+ const tab = list . getByRole ( 'tab' , { name : control . choice } ) . filter ( { visible : true } ) . first ( )
1016+ if ( ! ( await tab . count ( ) ) )
1017+ return {
1018+ status : 'unavailable' ,
1019+ error : `No matching ${ control . label } tab on this baseline.` ,
1020+ }
1021+ const choices = await list . getByRole ( 'tab' ) . count ( )
1022+ await tab . scrollIntoViewIfNeeded ( )
1023+ const start = performance . now ( )
1024+ await tab . click ( )
1025+ await expect ( tab ) . toHaveAttribute ( 'aria-selected' , 'true' )
1026+ const id = await tab . getAttribute ( 'aria-controls' )
1027+ if ( ! id ) throw new Error ( 'Tab has no linked content' )
1028+ const panel = run . page . locator ( `[id="${ id } "]` )
1029+ await panel . waitFor ( { state : 'visible' } )
1030+ await painted ( run . page )
1031+ return {
1032+ status : 'completed' ,
1033+ feedbackMs : choices > 1 ? performance . now ( ) - start : undefined ,
1034+ data : {
1035+ choices,
1036+ selected : await tab . textContent ( ) ,
1037+ contentLength : ( await panel . textContent ( ) ) ?. length ,
1038+ applicableTransition : choices > 1 ,
1039+ } ,
1040+ }
1041+ } )
1042+ }
1043+
10101044async function apiControls (
10111045 run : Awaited < ReturnType < typeof contextFor > > ,
10121046 profile : Profile ,
@@ -1037,39 +1071,11 @@ async function apiControls(
10371071 { scenario : 'response-status-control' , label : 'Response status' , choice : / ^ 4 0 0 $ / } ,
10381072 {
10391073 scenario : 'response-media-control' ,
1040- label : 'Response 400 content type' ,
1074+ label : '400 response content type' ,
10411075 choice : / ^ a p p l i c a t i o n \/ j s o n $ / ,
10421076 } ,
10431077 ] ) {
1044- await measure ( profile , route , repetition , control . scenario , async ( ) => {
1045- const list = run . page . getByRole ( 'tablist' , { name : control . label , exact : true } )
1046- const tab = list . getByRole ( 'tab' , { name : control . choice } ) . filter ( { visible : true } ) . first ( )
1047- if ( ! ( await tab . count ( ) ) )
1048- return {
1049- status : 'unavailable' ,
1050- error : `No matching ${ control . label } tab on this baseline.` ,
1051- }
1052- const choices = await list . getByRole ( 'tab' ) . count ( )
1053- await tab . scrollIntoViewIfNeeded ( )
1054- const start = performance . now ( )
1055- await tab . click ( )
1056- await expect ( tab ) . toHaveAttribute ( 'aria-selected' , 'true' )
1057- const id = await tab . getAttribute ( 'aria-controls' )
1058- if ( ! id ) throw new Error ( 'Tab has no linked content' )
1059- const panel = run . page . locator ( `[id="${ id } "]` )
1060- await panel . waitFor ( { state : 'visible' } )
1061- await painted ( run . page )
1062- return {
1063- status : 'completed' ,
1064- feedbackMs : choices > 1 ? performance . now ( ) - start : undefined ,
1065- data : {
1066- choices,
1067- selected : await tab . textContent ( ) ,
1068- contentLength : ( await panel . textContent ( ) ) ?. length ,
1069- applicableTransition : choices > 1 ,
1070- } ,
1071- }
1072- } )
1078+ await tabControl ( run , profile , repetition , route , control )
10731079 }
10741080 await measure ( profile , route , repetition , 'schema-disclosure-control' , async ( ) => {
10751081 const details = run . page . locator ( 'main details:not([open])' ) . filter ( { visible : true } ) . first ( )
@@ -1127,6 +1133,21 @@ async function apiControls(
11271133 data : { exactSelectedSampleCopied : true , characters : expected ?. length } ,
11281134 }
11291135 } )
1136+ const streamingRoute = '/api-reference/workflows/executeWorkflowV2'
1137+ await measure ( profile , streamingRoute , repetition , 'response-format-readiness' , async ( ) => {
1138+ const response = await run . page . goto ( new URL ( streamingRoute , base ) . href , {
1139+ waitUntil : 'domcontentloaded' ,
1140+ } )
1141+ if ( ! response ?. ok ( ) ) throw new Error ( `Document returned ${ response ?. status ( ) } ` )
1142+ await meaningful ( run . page , streamingRoute )
1143+ await readyForControls ( run . page )
1144+ return { status : 'completed' }
1145+ } )
1146+ await tabControl ( run , profile , repetition , streamingRoute , {
1147+ scenario : 'response-format-control' ,
1148+ label : '200 response content type' ,
1149+ choice : / ^ t e x t \/ e v e n t - s t r e a m $ / ,
1150+ } )
11301151}
11311152
11321153async function lighthouse ( profile : Profile , route : string , repetition : number ) {
@@ -1282,6 +1303,14 @@ if (mode === 'lighthouse') {
12821303 }
12831304 }
12841305 if ( scenarios . has ( 'interactions' ) ) await interactions ( browser , profile , repetition )
1306+ else if ( scenarios . has ( 'api-controls' ) ) {
1307+ const run = await contextFor ( browser , profile )
1308+ try {
1309+ await apiControls ( run , profile , repetition )
1310+ } finally {
1311+ await run . context . close ( )
1312+ }
1313+ }
12851314 }
12861315 } finally {
12871316 await browser . close ( )
0 commit comments