-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: overall improvements to span logs drawer empty state (i.e. trace logs empty state vs. span logs empty state + UI improvements) #9252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ahmadshaheer
merged 20 commits into
main
from
fix/overall-improvements-to-span-logs-drawer
Oct 29, 2025
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
d0eaffe
chore: remove the applied filters in related signals drawer
ahmadshaheer 469d2de
chore: make the span logs highlight color more prominent
ahmadshaheer ad6db55
fix: add label to open trace logs in logs explorer button
ahmadshaheer 40c3bef
feat: improve the span logs empty state i.e. add support for no logs …
ahmadshaheer da5331d
refactor: refactor the span logs content and make it readable
ahmadshaheer c9663e7
test: add tests for span logs
ahmadshaheer 0f86b90
chore: improve tests
ahmadshaheer 6bee416
refactor: simplify condition
ahmadshaheer 102bf04
chore: remove redundant test
ahmadshaheer 297fba4
Merge branch 'main' into fix/overall-improvements-to-span-logs-drawer
ahmadshaheer bfce92b
fix: make trace_id logs request only if drawer is open
ahmadshaheer 9b89314
chore: fix failing tests + overall improvements
ahmadshaheer dc5a832
Update frontend/src/container/SpanDetailsDrawer/__tests__/SpanDetails…
ahmadshaheer 54f2ce2
Revert "refactor: refactor the span logs content and make it readable"
ahmadshaheer 1a73c4a
chore: fix the failing test
ahmadshaheer c56b823
fix: fix the light mode styles for empty logs component
ahmadshaheer 1b54e8b
Merge branch 'main' into fix/overall-improvements-to-span-logs-drawer
ahmadshaheer 19e3977
chore: update the empty state copy
ahmadshaheer 1532128
chore: fix the failing tests by updating the assertions with correct …
ahmadshaheer aba35cb
Merge branch 'main' into fix/overall-improvements-to-span-logs-drawer
ahmadshaheer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
214 changes: 214 additions & 0 deletions
214
frontend/src/container/SpanDetailsDrawer/SpanLogs/__tests__/SpanLogs.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,214 @@ | ||
| import { getEmptyLogsListConfig } from 'container/LogsExplorerList/utils'; | ||
| import { server } from 'mocks-server/server'; | ||
| import { render, screen, userEvent } from 'tests/test-utils'; | ||
|
|
||
| import SpanLogs from '../SpanLogs'; | ||
|
|
||
| // Mock external dependencies | ||
| jest.mock('hooks/queryBuilder/useQueryBuilder', () => ({ | ||
| useQueryBuilder: (): any => ({ | ||
| updateAllQueriesOperators: jest.fn().mockReturnValue({ | ||
| builder: { | ||
| queryData: [ | ||
| { | ||
| dataSource: 'logs', | ||
| queryName: 'A', | ||
| aggregateOperator: 'noop', | ||
| filter: { expression: "trace_id = 'test-trace-id'" }, | ||
| expression: 'A', | ||
| disabled: false, | ||
| orderBy: [{ columnName: 'timestamp', order: 'desc' }], | ||
| groupBy: [], | ||
| limit: null, | ||
| having: [], | ||
| }, | ||
| ], | ||
| queryFormulas: [], | ||
| }, | ||
| queryType: 'builder', | ||
| }), | ||
| }), | ||
| })); | ||
|
|
||
| // Mock window.open | ||
| const mockWindowOpen = jest.fn(); | ||
| Object.defineProperty(window, 'open', { | ||
| writable: true, | ||
| value: mockWindowOpen, | ||
| }); | ||
|
|
||
| // Mock Virtuoso to avoid complex virtualization | ||
| jest.mock('react-virtuoso', () => ({ | ||
| Virtuoso: jest.fn(({ data, itemContent }: any) => ( | ||
| <div data-testid="virtuoso"> | ||
| {data?.map((item: any, index: number) => ( | ||
| <div key={item.id || index} data-testid={`log-item-${item.id}`}> | ||
| {itemContent(index, item)} | ||
| </div> | ||
| ))} | ||
| </div> | ||
| )), | ||
| })); | ||
|
|
||
| // Mock RawLogView component | ||
| jest.mock( | ||
| 'components/Logs/RawLogView', | ||
| () => | ||
| function MockRawLogView({ | ||
| data, | ||
| onLogClick, | ||
| isHighlighted, | ||
| helpTooltip, | ||
| }: any): JSX.Element { | ||
| return ( | ||
| <button | ||
| type="button" | ||
| data-testid={`raw-log-${data.id}`} | ||
| className={isHighlighted ? 'log-highlighted' : 'log-context'} | ||
| title={helpTooltip} | ||
| onClick={(e): void => onLogClick?.(data, e)} | ||
| > | ||
| <div>{data.body}</div> | ||
| <div>{data.timestamp}</div> | ||
| </button> | ||
| ); | ||
| }, | ||
| ); | ||
|
|
||
| // Mock PreferenceContextProvider | ||
| jest.mock('providers/preferences/context/PreferenceContextProvider', () => ({ | ||
| PreferenceContextProvider: ({ children }: any): JSX.Element => ( | ||
| <div>{children}</div> | ||
| ), | ||
| })); | ||
|
|
||
| // Mock OverlayScrollbar | ||
| jest.mock('components/OverlayScrollbar/OverlayScrollbar', () => ({ | ||
| default: ({ children }: any): JSX.Element => ( | ||
| <div data-testid="overlay-scrollbar">{children}</div> | ||
| ), | ||
| })); | ||
|
|
||
| // Mock LogsLoading component | ||
| jest.mock('container/LogsLoading/LogsLoading', () => ({ | ||
| LogsLoading: function MockLogsLoading(): JSX.Element { | ||
| return <div data-testid="logs-loading">Loading logs...</div>; | ||
| }, | ||
| })); | ||
|
|
||
| // Mock LogsError component | ||
| jest.mock( | ||
| 'container/LogsError/LogsError', | ||
| () => | ||
| function MockLogsError(): JSX.Element { | ||
| return <div data-testid="logs-error">Error loading logs</div>; | ||
| }, | ||
| ); | ||
|
|
||
| // Don't mock EmptyLogsSearch - test the actual component behavior | ||
|
|
||
| const TEST_TRACE_ID = 'test-trace-id'; | ||
| const TEST_SPAN_ID = 'test-span-id'; | ||
|
|
||
| const defaultProps = { | ||
| traceId: TEST_TRACE_ID, | ||
| spanId: TEST_SPAN_ID, | ||
| timeRange: { | ||
| startTime: 1640995200000, | ||
| endTime: 1640995260000, | ||
| }, | ||
| logs: [], | ||
| isLoading: false, | ||
| isError: false, | ||
| isFetching: false, | ||
| isLogSpanRelated: jest.fn().mockReturnValue(false), | ||
| handleExplorerPageRedirect: jest.fn(), | ||
| }; | ||
|
|
||
| describe('SpanLogs', () => { | ||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| mockWindowOpen.mockClear(); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| server.resetHandlers(); | ||
| }); | ||
|
|
||
| it('should show simple empty state when emptyStateConfig is not provided', () => { | ||
| // eslint-disable-next-line react/jsx-props-no-spreading | ||
| render(<SpanLogs {...defaultProps} />); | ||
|
|
||
| // Should show simple empty state (no emptyStateConfig provided) | ||
| expect( | ||
| screen.getByText('No logs found for selected span.'), | ||
| ).toBeInTheDocument(); | ||
| expect( | ||
| screen.getByText('View logs for the current trace.'), | ||
| ).toBeInTheDocument(); | ||
| expect( | ||
| screen.getByRole('button', { | ||
| name: /view logs/i, | ||
| }), | ||
| ).toBeInTheDocument(); | ||
|
|
||
| // Should NOT show enhanced empty state | ||
| expect(screen.queryByTestId('empty-logs-search')).not.toBeInTheDocument(); | ||
| expect(screen.queryByTestId('documentation-links')).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('should show enhanced empty state when entire trace has no logs', () => { | ||
| render( | ||
| <SpanLogs | ||
| // eslint-disable-next-line react/jsx-props-no-spreading | ||
| {...defaultProps} | ||
| emptyStateConfig={getEmptyLogsListConfig(jest.fn())} | ||
| />, | ||
| ); | ||
|
|
||
| // Should show enhanced empty state with custom message | ||
| expect(screen.getByText('No logs found for this trace.')).toBeInTheDocument(); | ||
| expect(screen.getByText('This could be because :')).toBeInTheDocument(); | ||
|
|
||
| // Should show description list | ||
| expect( | ||
| screen.getByText('Logs are not linked to Traces.'), | ||
| ).toBeInTheDocument(); | ||
| expect( | ||
| screen.getByText('Logs are not being sent to SigNoz.'), | ||
| ).toBeInTheDocument(); | ||
| expect( | ||
| screen.getByText('No logs are associated with this particular trace/span.'), | ||
| ).toBeInTheDocument(); | ||
|
|
||
| // Should show documentation links | ||
| expect(screen.getByText('RESOURCES')).toBeInTheDocument(); | ||
| expect(screen.getByText('Sending logs to SigNoz')).toBeInTheDocument(); | ||
| expect(screen.getByText('Correlate traces and logs')).toBeInTheDocument(); | ||
|
|
||
| // Should NOT show simple empty state | ||
| expect( | ||
| screen.queryByText('No logs found for selected span.'), | ||
| ).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('should call handleExplorerPageRedirect when Log Explorer button is clicked', async () => { | ||
| const user = userEvent.setup({ pointerEventsCheck: 0 }); | ||
| const mockHandleExplorerPageRedirect = jest.fn(); | ||
|
|
||
| render( | ||
| <SpanLogs | ||
| // eslint-disable-next-line react/jsx-props-no-spreading | ||
| {...defaultProps} | ||
| handleExplorerPageRedirect={mockHandleExplorerPageRedirect} | ||
| />, | ||
| ); | ||
|
|
||
| const logExplorerButton = screen.getByRole('button', { | ||
| name: /view logs/i, | ||
| }); | ||
| await user.click(logExplorerButton); | ||
|
|
||
| expect(mockHandleExplorerPageRedirect).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.