mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-11 16:58:38 +00:00
parent
227d81951c
commit
f8922e97a6
@ -11,7 +11,12 @@
|
||||
* 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 { MemoryRouter } from 'react-router-dom';
|
||||
import QueryCard from './QueryCard';
|
||||
@ -54,4 +59,28 @@ describe('Test QueryCard Component', () => {
|
||||
expect(query).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();
|
||||
});
|
||||
});
|
||||
|
@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
import classNames from 'classnames';
|
||||
import { isUndefined } from 'lodash';
|
||||
import React, { FC, HTMLAttributes, useState } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { getUserPath } from '../../constants/constants';
|
||||
@ -31,40 +32,42 @@ const QueryCard: FC<QueryCardProp> = ({ className, query }) => {
|
||||
<div
|
||||
className="tw-cursor-pointer"
|
||||
onClick={() => setExpanded((pre) => !pre)}>
|
||||
<div
|
||||
className="tw-flex tw-py-1 tw-justify-between"
|
||||
data-testid="query-header">
|
||||
<p>
|
||||
Last run by{' '}
|
||||
<Link
|
||||
className="button-comp"
|
||||
to={getUserPath(query.user?.name as string)}>
|
||||
<button className="tw-font-medium tw-text-grey-body ">
|
||||
{query.user?.displayName ?? query.user?.name}
|
||||
</button>{' '}
|
||||
</Link>
|
||||
and took{' '}
|
||||
<span className="tw-font-medium">{query.duration} seconds</span>
|
||||
</p>
|
||||
{!isUndefined(query.user) && !isUndefined(query.duration) ? (
|
||||
<div
|
||||
className="tw-flex tw-py-1 tw-justify-between"
|
||||
data-testid="query-header">
|
||||
<p>
|
||||
Last run by{' '}
|
||||
<Link
|
||||
className="button-comp"
|
||||
to={getUserPath(query.user?.name as string)}>
|
||||
<button className="tw-font-medium tw-text-grey-body ">
|
||||
{query.user?.displayName ?? query.user?.name}
|
||||
</button>{' '}
|
||||
</Link>
|
||||
and took{' '}
|
||||
<span className="tw-font-medium">{query.duration} seconds</span>
|
||||
</p>
|
||||
|
||||
<button className="tw-pr-px">
|
||||
{expanded ? (
|
||||
<SVGIcons
|
||||
alt="arrow-up"
|
||||
className="tw-mr-4"
|
||||
icon={Icons.ICON_UP}
|
||||
width="16px"
|
||||
/>
|
||||
) : (
|
||||
<SVGIcons
|
||||
alt="arrow-down"
|
||||
className="tw-mr-4"
|
||||
icon={Icons.ICON_DOWN}
|
||||
width="16px"
|
||||
/>
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
<button className="tw-pr-px">
|
||||
{expanded ? (
|
||||
<SVGIcons
|
||||
alt="arrow-up"
|
||||
className="tw-mr-4"
|
||||
icon={Icons.ICON_UP}
|
||||
width="16px"
|
||||
/>
|
||||
) : (
|
||||
<SVGIcons
|
||||
alt="arrow-down"
|
||||
className="tw-mr-4"
|
||||
icon={Icons.ICON_DOWN}
|
||||
width="16px"
|
||||
/>
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="tw-border tw-border-main tw-rounded-md tw-p-px">
|
||||
<div
|
||||
|
@ -891,6 +891,10 @@ body .profiler-graph .recharts-active-dot circle {
|
||||
height: auto !important;
|
||||
}
|
||||
|
||||
.CodeMirror-wrap pre.CodeMirror-line {
|
||||
padding-right: 40px;
|
||||
}
|
||||
|
||||
.entity-feed-list {
|
||||
grid-template-columns: 200px auto 200px;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user