grafana/public/app/features/explore/PrometheusListView/RawListContainer.test.tsx
Galen Kistler 0e265245eb
Prometheus: New instant query results view in Explore (#60479)
Add new default instant query UI option for prometheus users in Explore.

Co-authored-by: Beto Muniz <contato@betomuniz.com>
Co-authored-by: Giordano Ricci <me@giordanoricci.com>
2023-01-04 10:46:03 -06:00

71 lines
1.6 KiB
TypeScript

import { render, screen, within } from '@testing-library/react';
import React from 'react';
import { FieldType, FormattedValue, toDataFrame } from '@grafana/data/src';
import RawListContainer, { RawListContainerProps } from './RawListContainer';
function getList(): HTMLElement {
return screen.getByRole('table');
}
const display = (input: string): FormattedValue => {
return {
text: input,
};
};
const dataFrame = toDataFrame({
name: 'A',
fields: [
{
name: 'Time',
type: FieldType.time,
values: [1609459200000, 1609470000000, 1609462800000, 1609466400000],
config: {
custom: {
filterable: false,
},
},
},
{
display: display,
name: 'text',
type: FieldType.string,
values: ['test_string_1', 'test_string_2', 'test_string_3', 'test_string_4'],
config: {
custom: {
filterable: false,
},
},
},
{
name: '__name__',
type: FieldType.string,
values: ['test_string_1', 'test_string_2', 'test_string_3', 'test_string_4'],
config: {
custom: {
filterable: false,
},
},
},
],
});
const defaultProps: RawListContainerProps = {
tableResult: dataFrame,
};
describe('RawListContainer', () => {
it('should render', () => {
render(<RawListContainer {...defaultProps} />);
expect(getList()).toBeInTheDocument();
const rows = within(getList()).getAllByRole('row');
expect(rows).toHaveLength(4);
rows.forEach((row, index) => {
expect(screen.getAllByText(`test_string_${index + 1}`)[0]).toBeVisible();
});
});
});