Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix: fix the flaky test (#9255)

Shaheer Kochaia22ef64bb05f
diff --git a/frontend/src/container/SpanDetailsDrawer/__tests__/SpanDetailsDrawer.test.tsx b/frontend/src/container/SpanDetailsDrawer/__tests__/SpanDetailsDrawer.test.tsx
index 6004d550ac..be73fefcac 100644
--- a/frontend/src/container/SpanDetailsDrawer/__tests__/SpanDetailsDrawer.test.tsx
+++ b/frontend/src/container/SpanDetailsDrawer/__tests__/SpanDetailsDrawer.test.tsx
@@ -261,18 +261,16 @@ describe('SpanDetailsDrawer', () => {
const logsButton = screen.getByRole('radio', { name: /logs/i });
fireEvent.click(logsButton);
- // Wait for logs view to open
+ // Wait for logs view to open and logs to be displayed
await waitFor(() => {
expect(screen.getByTestId('overlay-scrollbar')).toBeInTheDocument();
- });
-
- // Verify logs are displayed
- await waitFor(() => {
// eslint-disable-next-line sonarjs/no-duplicate-string
expect(screen.getByTestId('raw-log-span-log-1')).toBeInTheDocument();
+ // eslint-disable-next-line sonarjs/no-duplicate-string
expect(screen.getByTestId('raw-log-span-log-2')).toBeInTheDocument();
// eslint-disable-next-line sonarjs/no-duplicate-string
expect(screen.getByTestId('raw-log-context-log-before')).toBeInTheDocument();
+ // eslint-disable-next-line sonarjs/no-duplicate-string
expect(screen.getByTestId('raw-log-context-log-after')).toBeInTheDocument();
});
});
@@ -285,12 +283,9 @@ describe('SpanDetailsDrawer', () => {
fireEvent.click(logsButton);
// Wait for all API calls to complete
- await waitFor(
- () => {
- expect(GetMetricQueryRange).toHaveBeenCalledTimes(3);
- },
- { timeout: 5000 },
- );
+ await waitFor(() => {
+ expect(GetMetricQueryRange).toHaveBeenCalledTimes(3);
+ });
// Verify the three distinct queries were made
const [spanQuery, beforeQuery, afterQuery] = apiCallHistory;
@@ -319,12 +314,9 @@ describe('SpanDetailsDrawer', () => {
fireEvent.click(logsButton);
// Wait for all API calls to complete
- await waitFor(
- () => {
- expect(GetMetricQueryRange).toHaveBeenCalledTimes(3);
- },
- { timeout: 5000 },
- );
+ await waitFor(() => {
+ expect(GetMetricQueryRange).toHaveBeenCalledTimes(3);
+ });
const [spanQuery, beforeQuery, afterQuery] = apiCallHistory;
@@ -484,9 +476,17 @@ describe('SpanDetailsDrawer', () => {
const logsButton = screen.getByRole('radio', { name: /logs/i });
fireEvent.click(logsButton);
- // Wait for logs to load
+ // Wait for all API calls to complete first
+ await waitFor(() => {
+ expect(GetMetricQueryRange).toHaveBeenCalledTimes(3);
+ });
+
+ // Wait for all logs to be rendered - both span logs and context logs
await waitFor(() => {
expect(screen.getByTestId('raw-log-span-log-1')).toBeInTheDocument();
+ expect(screen.getByTestId('raw-log-span-log-2')).toBeInTheDocument();
+ expect(screen.getByTestId('raw-log-context-log-before')).toBeInTheDocument();
+ expect(screen.getByTestId('raw-log-context-log-after')).toBeInTheDocument();
});
// Verify span logs are highlighted