mirror of https://github.com/grafana/grafana
Common labels/displayed fields: Show label names with values (#86345)
* LogLabels: create specialized component for arrays of labels * Logs: sort displayed fields when assigning to state * LogsMetaRow: fix types and use specialized components * LogLabels: show label and value * LogsPanel: update common labels * LogsMetaRow: use LogsLabelsList * Update unit tests * Formatting * Update betterer * Prettier * Logs panel: update test * LogLabels: add actual tooltip * Logs: remove sorting of displayed fieldspull/86524/head
parent
bbf4281d8d
commit
99f34cb1ed
@ -1,27 +1,35 @@ |
||||
import { render, screen } from '@testing-library/react'; |
||||
import React from 'react'; |
||||
|
||||
import { LogLabels } from './LogLabels'; |
||||
import { LogLabels, LogLabelsList } from './LogLabels'; |
||||
|
||||
describe('<LogLabels />', () => { |
||||
it('renders notice when no labels are found', () => { |
||||
render(<LogLabels labels={{}} />); |
||||
render(<LogLabels labels={{}} emptyMessage="(no unique labels)" />); |
||||
expect(screen.queryByText('(no unique labels)')).toBeInTheDocument(); |
||||
}); |
||||
it('renders labels', () => { |
||||
render(<LogLabels labels={{ foo: 'bar', baz: '42' }} />); |
||||
expect(screen.queryByText('bar')).toBeInTheDocument(); |
||||
expect(screen.queryByText('42')).toBeInTheDocument(); |
||||
expect(screen.queryByText('foo=bar')).toBeInTheDocument(); |
||||
expect(screen.queryByText('baz=42')).toBeInTheDocument(); |
||||
}); |
||||
it('excludes labels with certain names or labels starting with underscore', () => { |
||||
render(<LogLabels labels={{ foo: 'bar', level: '42', _private: '13' }} />); |
||||
expect(screen.queryByText('bar')).toBeInTheDocument(); |
||||
expect(screen.queryByText('42')).not.toBeInTheDocument(); |
||||
expect(screen.queryByText('foo=bar')).toBeInTheDocument(); |
||||
expect(screen.queryByText('level=42')).not.toBeInTheDocument(); |
||||
expect(screen.queryByText('13')).not.toBeInTheDocument(); |
||||
}); |
||||
it('excludes labels with empty string values', () => { |
||||
render(<LogLabels labels={{ foo: 'bar', baz: '' }} />); |
||||
expect(screen.queryByText('foo=bar')).toBeInTheDocument(); |
||||
expect(screen.queryByText(/baz/)).not.toBeInTheDocument(); |
||||
}); |
||||
}); |
||||
|
||||
describe('<LogLabelsList />', () => { |
||||
it('renders labels', () => { |
||||
render(<LogLabelsList labels={['bar', '42']} />); |
||||
expect(screen.queryByText('bar')).toBeInTheDocument(); |
||||
expect(screen.queryByText('baz')).not.toBeInTheDocument(); |
||||
expect(screen.queryByText('42')).toBeInTheDocument(); |
||||
}); |
||||
}); |
||||
|
Loading…
Reference in new issue