Skip to content

Commit 8494780

Browse files
authored
fix: fix observability e2e tests (#1629)
1 parent a88ccd3 commit 8494780

File tree

4 files changed

+40
-13
lines changed

4 files changed

+40
-13
lines changed

tests/e2e/features/mcp-registry/mcp-registry.data.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ function normalizeHeaders(parsed: Record<string, string | EnvVarLike>): Record<s
9090
* Create SSE MCP client data.
9191
* URL and headers are injected via workflow env: MCP_SSE_URL, MCP_SSE_HEADERS (JSON).
9292
* Supports: {"Authorization":"Bearer ...","K":"V"} or {"Authorization":{"value":"...","env_var":"","from_env":false}}.
93-
* When unset, uses local http://localhost:3001/sse and no headers (no secrets in code).
9493
*/
9594
export function createSSEClientData(overrides: Partial<MCPClientConfig> = {}): MCPClientConfig {
9695
const connectionUrl = "https://ts-mcp-sse-proxy.fly.dev/npx%20-y%20exa-mcp-server/sse"

tests/e2e/features/observability/observability.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,14 @@ test.describe('Observability', () => {
4848
await observabilityPage.selectConnector('otel')
4949

5050
// The metrics endpoint is in an input field with value containing /metrics
51+
await observabilityPage.enableMetricsExport()
5152
const metricsValue = await observabilityPage.getMetricsEndpointValue()
52-
expect(metricsValue).toContain('/metrics')
53+
const metricsInput = observabilityPage.page.getByPlaceholder(/v1\/metrics|otel-collector.*metrics/i)
54+
const placeholder = await metricsInput.getAttribute('placeholder').catch(() => null)
55+
const hasMetrics =
56+
(metricsValue != null && metricsValue.includes('/metrics')) ||
57+
(placeholder != null && placeholder.includes('/metrics'))
58+
expect(hasMetrics).toBe(true)
5359
})
5460

5561
test('should toggle OTel connector', async ({ observabilityPage }) => {

tests/e2e/features/observability/pages/observability.page.ts

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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: /metrics/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(/Metrics.*scraping/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(/Enable Metrics Export/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(/Metrics Endpoint/i).isVisible().catch(() => false)
323+
return labelVisible
307324
}
308325

309326
/**

ui/app/workspace/observability/fragments/otelFormFragment.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,12 @@ export function OtelFormFragment({ currentConfig: initialConfig, onSave, isLoadi
297297
</p>
298298
</div>
299299
<div className="ml-auto">
300-
<Switch checked={field.value} onCheckedChange={field.onChange} disabled={!hasOtelAccess} />
300+
<Switch
301+
data-testid="otel-metrics-export-toggle"
302+
checked={field.value}
303+
onCheckedChange={field.onChange}
304+
disabled={!hasOtelAccess}
305+
/>
301306
</div>
302307
</div>
303308
</FormItem>

0 commit comments

Comments
 (0)