@@ -177,6 +177,20 @@ export class ObservabilityPage extends BasePage {
177177 }
178178 }
179179
180+ /**
181+ * Enable Metrics Export
182+ */
183+ async enableMetricsExport ( ) : Promise < void > {
184+ await this . selectConnector ( 'otel' )
185+ const switch_ = this . page . getByTestId ( 'otel-metrics-export-toggle' )
186+ await switch_ . waitFor ( { state : 'visible' , timeout : 5000 } )
187+ const checked = await switch_ . getAttribute ( 'data-state' ) === 'checked'
188+ if ( ! checked ) {
189+ await switch_ . click ( )
190+ await this . page . waitForTimeout ( 400 )
191+ }
192+ }
193+
180194 /**
181195 * Configure OTel endpoint
182196 */
@@ -290,20 +304,23 @@ export class ObservabilityPage extends BasePage {
290304 }
291305
292306 /**
293- * Check if metrics endpoint is displayed (in the OTel view)
307+ * Check if OTel-specific content is visible (confirms we're on the OTel panel).
308+ * The metrics endpoint input is only in the DOM when "Enable Metrics Export" is on,
309+ * so we also treat the "Enable Metrics Export" section as OTel content.
294310 */
295311 async isMetricsEndpointVisible ( ) : Promise < boolean > {
296- // The metrics endpoint is shown in a read-only input field
297- const metricsInput = this . page . locator ( 'input[readonly]' ) . filter ( { hasText : / m e t r i c s / i } )
312+ // Metrics endpoint input (only visible when Enable Metrics Export is on)
298313 const metricsInputByValue = this . page . locator ( 'input[value*="/metrics"]' )
299-
300- const inputVisible = await metricsInput . isVisible ( ) . catch ( ( ) => false )
301314 const valueVisible = await metricsInputByValue . isVisible ( ) . catch ( ( ) => false )
302-
303- // Also check for the label text
304- const labelVisible = await this . page . getByText ( / M e t r i c s .* s c r a p i n g / i) . isVisible ( ) . catch ( ( ) => false )
305-
306- return inputVisible || valueVisible || labelVisible
315+ if ( valueVisible ) return true
316+
317+ // "Enable Metrics Export" section is always visible on OTel tab (metrics subsection)
318+ const enableMetricsVisible = await this . page . getByText ( / E n a b l e M e t r i c s E x p o r t / i) . isVisible ( ) . catch ( ( ) => false )
319+ if ( enableMetricsVisible ) return true
320+
321+ // Label "Metrics Endpoint" (when metrics export is enabled)
322+ const labelVisible = await this . page . getByText ( / M e t r i c s E n d p o i n t / i) . isVisible ( ) . catch ( ( ) => false )
323+ return labelVisible
307324 }
308325
309326 /**
0 commit comments