Fix #3727 Usage queries tab UI issues (#3737)

This commit is contained in:
Sachin Chaurasiya 2022-03-30 15:53:11 +05:30 committed by GitHub
parent 227d81951c
commit f8922e97a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 70 additions and 34 deletions

View File

@ -11,7 +11,12 @@
* limitations under the License. * limitations under the License.
*/ */
import { findByText, getByTestId, render } from '@testing-library/react'; import {
findByText,
getByTestId,
queryByTestId,
render,
} from '@testing-library/react';
import React from 'react'; import React from 'react';
import { MemoryRouter } from 'react-router-dom'; import { MemoryRouter } from 'react-router-dom';
import QueryCard from './QueryCard'; import QueryCard from './QueryCard';
@ -54,4 +59,28 @@ describe('Test QueryCard Component', () => {
expect(query).toBeInTheDocument(); expect(query).toBeInTheDocument();
expect(copyQueryButton).toBeInTheDocument(); expect(copyQueryButton).toBeInTheDocument();
}); });
it('Should not render header if user is undefined', async () => {
const { container } = render(
<QueryCard query={{ ...mockQueryData, user: undefined }} />,
{
wrapper: MemoryRouter,
}
);
const queryHeader = queryByTestId(container, 'query-header');
expect(queryHeader).not.toBeInTheDocument();
});
it('Should not render header if duration is undefined', async () => {
const { container } = render(
<QueryCard query={{ ...mockQueryData, duration: undefined }} />,
{
wrapper: MemoryRouter,
}
);
const queryHeader = queryByTestId(container, 'query-header');
expect(queryHeader).not.toBeInTheDocument();
});
}); });

View File

@ -12,6 +12,7 @@
*/ */
import classNames from 'classnames'; import classNames from 'classnames';
import { isUndefined } from 'lodash';
import React, { FC, HTMLAttributes, useState } from 'react'; import React, { FC, HTMLAttributes, useState } from 'react';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { getUserPath } from '../../constants/constants'; import { getUserPath } from '../../constants/constants';
@ -31,6 +32,7 @@ const QueryCard: FC<QueryCardProp> = ({ className, query }) => {
<div <div
className="tw-cursor-pointer" className="tw-cursor-pointer"
onClick={() => setExpanded((pre) => !pre)}> onClick={() => setExpanded((pre) => !pre)}>
{!isUndefined(query.user) && !isUndefined(query.duration) ? (
<div <div
className="tw-flex tw-py-1 tw-justify-between" className="tw-flex tw-py-1 tw-justify-between"
data-testid="query-header"> data-testid="query-header">
@ -65,6 +67,7 @@ const QueryCard: FC<QueryCardProp> = ({ className, query }) => {
)} )}
</button> </button>
</div> </div>
) : null}
</div> </div>
<div className="tw-border tw-border-main tw-rounded-md tw-p-px"> <div className="tw-border tw-border-main tw-rounded-md tw-p-px">
<div <div

View File

@ -891,6 +891,10 @@ body .profiler-graph .recharts-active-dot circle {
height: auto !important; height: auto !important;
} }
.CodeMirror-wrap pre.CodeMirror-line {
padding-right: 40px;
}
.entity-feed-list { .entity-feed-list {
grid-template-columns: 200px auto 200px; grid-template-columns: 200px auto 200px;
} }