fix(react): fix up yarn test error reporting (#3462)

This commit is contained in:
Gabe Lyons 2021-10-26 12:13:53 -07:00 committed by GitHub
parent a52711472e
commit 37394207a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 114 additions and 121 deletions

View File

@ -27,6 +27,7 @@ import { GetTagDocument } from './graphql/tag.generated';
import { GetMlModelDocument } from './graphql/mlModel.generated'; import { GetMlModelDocument } from './graphql/mlModel.generated';
import { GetMlModelGroupDocument } from './graphql/mlModelGroup.generated'; import { GetMlModelGroupDocument } from './graphql/mlModelGroup.generated';
import { GetGlossaryTermDocument, GetGlossaryTermQuery } from './graphql/glossaryTerm.generated'; import { GetGlossaryTermDocument, GetGlossaryTermQuery } from './graphql/glossaryTerm.generated';
import { GetMeDocument } from './graphql/me.generated';
const user1 = { const user1 = {
username: 'sdas', username: 'sdas',
@ -2503,4 +2504,19 @@ export const mocks = [
} as GetSearchResultsForMultipleQuery, } as GetSearchResultsForMultipleQuery,
}, },
}, },
{
request: {
query: GetMeDocument,
variables: {},
},
result: {
data: {
__typename: 'Query',
me: {
__typename: 'AuthenticatedUser',
corpUser: user1,
},
} as GetSearchResultsForMultipleQuery,
},
},
]; ];

View File

@ -18,14 +18,14 @@ const ShowVersionButton = styled(Button)`
display: none; display: none;
`; `;
const KeyButton = styled(Button)<{ highlighted: boolean }>` const KeyButton = styled(Button)<{ $highlighted: boolean }>`
border-radius: 8px 0px 0px 8px; border-radius: 8px 0px 0px 8px;
font-weight: ${(props) => (props.highlighted ? '600' : '400')}; font-weight: ${(props) => (props.$highlighted ? '600' : '400')};
`; `;
const ValueButton = styled(Button)<{ highlighted: boolean }>` const ValueButton = styled(Button)<{ $highlighted: boolean }>`
border-radius: 0px 8px 8px 0px; border-radius: 0px 8px 8px 0px;
font-weight: ${(props) => (props.highlighted ? '600' : '400')}; font-weight: ${(props) => (props.$highlighted ? '600' : '400')};
`; `;
const KeyValueButtonGroup = styled.div` const KeyValueButtonGroup = styled.div`
@ -87,10 +87,10 @@ export default function SchemaHeader({
)} )}
{hasKeySchema && ( {hasKeySchema && (
<KeyValueButtonGroup> <KeyValueButtonGroup>
<KeyButton highlighted={showKeySchema} onClick={() => setShowKeySchema(true)}> <KeyButton $highlighted={showKeySchema} onClick={() => setShowKeySchema(true)}>
Key Key
</KeyButton> </KeyButton>
<ValueButton highlighted={!showKeySchema} onClick={() => setShowKeySchema(false)}> <ValueButton $highlighted={!showKeySchema} onClick={() => setShowKeySchema(false)}>
Value Value
</ValueButton> </ValueButton>
</KeyValueButtonGroup> </KeyValueButtonGroup>

View File

@ -70,6 +70,7 @@ export default function useSchemaTitleRenderer(
) )
.map((constraint) => ( .map((constraint) => (
<ForeignKeyLabel <ForeignKeyLabel
key={constraint?.name}
fieldPath={fieldPath} fieldPath={fieldPath}
constraint={constraint} constraint={constraint}
highlight={constraint?.name === highlightedConstraint} highlight={constraint?.name === highlightedConstraint}

View File

@ -121,7 +121,7 @@ export default function DataProfileView({ profile }: Props) {
(sampleValues && (sampleValues &&
sampleValues sampleValues
.slice(0, sampleValues.length < 3 ? sampleValues?.length : 3) .slice(0, sampleValues.length < 3 ? sampleValues?.length : 3)
.map((value) => <Tag>{value}</Tag>)) || .map((value) => <Tag key={value}>{value}</Tag>)) ||
unknownValue() unknownValue()
); );
}, },
@ -171,6 +171,8 @@ export default function DataProfileView({ profile }: Props) {
pagination={false} pagination={false}
columns={columnStatsColumns} columns={columnStatsColumns}
dataSource={columnStatsTableData} dataSource={columnStatsTableData}
// TODO: this table's types should be cleaned up so `any` is not needed here or in the column definitions
rowKey={(record: any) => record.name}
/> />
</StatsSection> </StatsSection>
</> </>

View File

@ -28,7 +28,7 @@ export const EntitySidebar = <T,>({ sidebarSections }: Props) => {
if (section.display?.visible(entityData, baseEntity) !== true) { if (section.display?.visible(entityData, baseEntity) !== true) {
return null; return null;
} }
return <section.component properties={section.properties} />; return <section.component key={`${section.component}`} properties={section.properties} />;
})} })}
</ContentContainer> </ContentContainer>
); );

View File

@ -92,7 +92,13 @@ export const SidebarAboutSection = () => {
{links?.length > 0 ? ( {links?.length > 0 ? (
<SidebarLinkList> <SidebarLinkList>
{(links || []).map((link) => ( {(links || []).map((link) => (
<LinkButton type="link" href={link.url} target="_blank" rel="noreferrer"> <LinkButton
type="link"
href={link.url}
target="_blank"
rel="noreferrer"
key={`${link.label}-${link.url}-${link.author}`}
>
<LinkOutlined /> <LinkOutlined />
{link.description || link.label} {link.description || link.label}
</LinkButton> </LinkButton>

View File

@ -1,21 +1,16 @@
import React, { useContext, useState } from 'react'; import React, { useContext } from 'react';
import { Badge, Table } from 'antd'; import { Badge } from 'antd';
import styled from 'styled-components'; import styled from 'styled-components';
import { green } from '@ant-design/colors'; import { green } from '@ant-design/colors';
import Modal from 'antd/lib/modal/Modal';
import { Link } from 'react-router-dom';
import { ANTD_GRAY } from '../../../../constants'; import { ANTD_GRAY } from '../../../../constants';
import { EntityType, ForeignKeyConstraint } from '../../../../../../../types.generated'; import { ForeignKeyConstraint } from '../../../../../../../types.generated';
import { useBaseEntity } from '../../../../EntityContext';
import { GetDatasetQuery } from '../../../../../../../graphql/dataset.generated';
import { useEntityRegistry } from '../../../../../../useEntityRegistry';
import { FkContext } from '../utils/selectedFkContext'; import { FkContext } from '../utils/selectedFkContext';
const ForeignKeyBadge = styled(Badge)<{ highlight: boolean }>` const ForeignKeyBadge = styled(Badge)<{ $highlight: boolean }>`
margin-left: 4px; margin-left: 4px;
&&& .ant-badge-count { &&& .ant-badge-count {
background-color: ${(props) => (props.highlight ? green[1] : ANTD_GRAY[1])}; background-color: ${(props) => (props.$highlight ? green[1] : ANTD_GRAY[1])};
color: ${green[5]}; color: ${green[5]};
border: 1px solid ${green[2]}; border: 1px solid ${green[2]};
font-size: 12px; font-size: 12px;
@ -33,9 +28,6 @@ type Props = {
onClick: (params: { fieldPath: string; constraint?: ForeignKeyConstraint | null } | null) => void; onClick: (params: { fieldPath: string; constraint?: ForeignKeyConstraint | null } | null) => void;
}; };
const zip = (a, b) =>
Array.from(Array(Math.max(b.length, a.length)), (_, i) => ({ source: a[i]?.fieldPath, foreign: b[i]?.fieldPath }));
export default function ForeignKeyLabel({ export default function ForeignKeyLabel({
fieldPath, fieldPath,
constraint, constraint,
@ -44,52 +36,26 @@ export default function ForeignKeyLabel({
onClick, onClick,
}: Props) { }: Props) {
const selectedFk = useContext(FkContext); const selectedFk = useContext(FkContext);
const [showModal, setShowModal] = useState(false);
const baseEntity = useBaseEntity<GetDatasetQuery>();
const entityRegistry = useEntityRegistry();
const sourceColumn = { const onOpenFk = () => {
title: ( if (selectedFk?.fieldPath === fieldPath && selectedFk?.constraint?.name === constraint?.name) {
<Link to={entityRegistry.getEntityUrl(EntityType.Dataset, baseEntity?.dataset?.urn || '')}> onClick(null);
{baseEntity.dataset?.name} } else {
</Link> onClick({ fieldPath, constraint });
), }
dataIndex: 'source',
key: 'source',
}; };
const foreignColumn = {
title: (
<Link to={entityRegistry.getEntityUrl(EntityType.Dataset, constraint?.foreignDataset?.urn || '')}>
{constraint?.foreignDataset?.name}
</Link>
),
dataIndex: 'foreign',
key: 'foreign',
};
const rows = zip(constraint?.sourceFields, constraint?.foreignFields);
return ( return (
<> <>
<Modal title={constraint?.name || 'Foreign Key'} visible={showModal} onCancel={() => setShowModal(false)}>
<Table columns={[sourceColumn, foreignColumn]} dataSource={rows} pagination={false} />
</Modal>
<span <span
role="button" role="button"
tabIndex={0} tabIndex={0}
onKeyPress={(e) => (e.key === 'Enter' ? setShowModal(true) : null)} onKeyPress={(e) => (e.key === 'Enter' ? onOpenFk() : null)}
onClick={() => { onClick={onOpenFk}
if (selectedFk?.fieldPath === fieldPath && selectedFk?.constraint?.name === constraint?.name) {
onClick(null);
} else {
onClick({ fieldPath, constraint });
}
}}
onMouseEnter={() => setHighlightedConstraint(constraint?.name || null)} onMouseEnter={() => setHighlightedConstraint(constraint?.name || null)}
onMouseLeave={() => setHighlightedConstraint(null)} onMouseLeave={() => setHighlightedConstraint(null)}
> >
<ForeignKeyBadge highlight={highlight || selectedFk?.fieldPath === fieldPath} count="Foreign Key" /> <ForeignKeyBadge $highlight={highlight || selectedFk?.fieldPath === fieldPath} count="Foreign Key" />
</span> </span>
</> </>
); );

View File

@ -10,24 +10,21 @@ import { ANTD_GRAY } from '../../../../constants';
import { useBaseEntity } from '../../../../EntityContext'; import { useBaseEntity } from '../../../../EntityContext';
import { FkContext } from '../utils/selectedFkContext'; import { FkContext } from '../utils/selectedFkContext';
const ForeignKeyContent = styled.div` const ForeignKeyContent = styled.tr`
position: absolute; position: absolute;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: 100%; width: 100%;
max-height: 600px;
height: 600px;
z-index: 99999; z-index: 99999;
margin-top: -590px; margin-top: -587px;
box-shadow: inset 0 7px 16px -7px ${ANTD_GRAY[5]}; box-shadow: inset 0 7px 16px -7px ${ANTD_GRAY[5]};
`; `;
const EntitySidePanel = styled.div` const EntitySidePanel = styled.div`
overflow-y: scroll; overflow-y: scroll;
max-height: 548px; max-height: 545px;
width: 900px;
height: 548px;
padding: 8px; padding: 8px;
width: 900px;
border-right: 1px solid ${ANTD_GRAY[4]}; border-right: 1px solid ${ANTD_GRAY[4]};
background-color: white; background-color: white;
`; `;
@ -53,8 +50,6 @@ const ConstraintSection = styled.div`
min-height: 100%; min-height: 100%;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
max-height: 548px;
min-height: 548px;
background-color: ${ANTD_GRAY[2]}; background-color: ${ANTD_GRAY[2]};
`; `;
@ -69,7 +64,7 @@ const BodyContent = styled.div`
`; `;
const HeaderContent = styled.div` const HeaderContent = styled.div`
margin-top: 12px; padding-top: 8px;
min-height: 40px; min-height: 40px;
font-size: 16px; font-size: 16px;
font-weight: 500; font-weight: 500;
@ -77,6 +72,12 @@ const HeaderContent = styled.div`
border-bottom: 1px solid ${ANTD_GRAY[4]}; border-bottom: 1px solid ${ANTD_GRAY[4]};
`; `;
const ForiegnKeyTd = styled.td`
&&& {
padding: 0;
}
`;
const DatasetLink = styled(Link)` const DatasetLink = styled(Link)`
color: ${ANTD_GRAY[9]}; color: ${ANTD_GRAY[9]};
font-weight: 800; font-weight: 800;
@ -104,46 +105,48 @@ export const SchemaRow = ({
<tr className={className}>{children}</tr> <tr className={className}>{children}</tr>
{fieldPath === selectedFk?.fieldPath && ( {fieldPath === selectedFk?.fieldPath && (
<ForeignKeyContent> <ForeignKeyContent>
<HeaderContent> <ForiegnKeyTd>
Foreign Key to{' '} <HeaderContent>
<DatasetLink Foreign Key to{' '}
to={entityRegistry.getEntityUrl( <DatasetLink
EntityType.Dataset, to={entityRegistry.getEntityUrl(
selectedFk.constraint?.foreignDataset?.urn || '',
)}
>
{selectedFk.constraint?.foreignDataset?.name}
</DatasetLink>
</HeaderContent>
<BodyContent>
<EntitySidePanel>
<CompactContext.Provider value>
{entityRegistry.renderProfile(
EntityType.Dataset, EntityType.Dataset,
selectedFk.constraint?.foreignDataset?.urn || '', selectedFk.constraint?.foreignDataset?.urn || '',
)} )}
</CompactContext.Provider> >
</EntitySidePanel> {selectedFk.constraint?.foreignDataset?.name}
<ConstraintSection> </DatasetLink>
<div> </HeaderContent>
<TableTitle>{baseEntity.dataset?.name}</TableTitle> <BodyContent>
{selectedFk.constraint?.sourceFields?.map((field) => ( <EntitySidePanel>
<div> <CompactContext.Provider value>
<FieldBadge count={field?.fieldPath} /> {entityRegistry.renderProfile(
</div> EntityType.Dataset,
))} selectedFk.constraint?.foreignDataset?.urn || '',
</div> )}
<ArrowContainer>{'--->'}</ArrowContainer> </CompactContext.Provider>
<div> </EntitySidePanel>
<TableTitle>{selectedFk.constraint?.foreignDataset?.name}</TableTitle> <ConstraintSection>
{selectedFk.constraint?.foreignFields?.map((field) => ( <div>
<div> <TableTitle>{baseEntity.dataset?.name}</TableTitle>
<FieldBadge count={field?.fieldPath} /> {selectedFk.constraint?.sourceFields?.map((field) => (
</div> <div key={field?.fieldPath}>
))} <FieldBadge count={field?.fieldPath} />
</div> </div>
</ConstraintSection> ))}
</BodyContent> </div>
<ArrowContainer>{'--->'}</ArrowContainer>
<div>
<TableTitle>{selectedFk.constraint?.foreignDataset?.name}</TableTitle>
{selectedFk.constraint?.foreignFields?.map((field) => (
<div key={field?.fieldPath}>
<FieldBadge count={field?.fieldPath} />
</div>
))}
</div>
</ConstraintSection>
</BodyContent>
</ForiegnKeyTd>
</ForeignKeyContent> </ForeignKeyContent>
)} )}
</> </>

View File

@ -32,7 +32,7 @@ export default function TypeLabel({ type, nativeDataType }: Props) {
const NativeDataTypeTooltip = ({ children }) => const NativeDataTypeTooltip = ({ children }) =>
nativeDataType ? ( nativeDataType ? (
<Tooltip placement="top" title={capitalizeFirstLetter(nativeDataType)}> <Tooltip placement="top" title={capitalizeFirstLetter(nativeDataType)}>
{children} <span>{children}</span>
</Tooltip> </Tooltip>
) : ( ) : (
<>{children}</> <>{children}</>

View File

@ -141,8 +141,8 @@ export default function DefaultPreviewCard({
return ( return (
<PreviewContainer data-testid={dataTestID}> <PreviewContainer data-testid={dataTestID}>
<div> <div>
<Link to={url}> <TitleContainer>
<TitleContainer> <Link to={url}>
<PlatformInfo> <PlatformInfo>
{logoComponent && logoComponent} {logoComponent && logoComponent}
{!!logoUrl && <PreviewImage preview={false} src={logoUrl} alt={platform} />} {!!logoUrl && <PreviewImage preview={false} src={logoUrl} alt={platform} />}
@ -150,14 +150,12 @@ export default function DefaultPreviewCard({
<PlatformDivider /> <PlatformDivider />
<PlatformText>{type}</PlatformText> <PlatformText>{type}</PlatformText>
</PlatformInfo> </PlatformInfo>
<Link to={url}> <EntityTitle>{name || ' '}</EntityTitle>
<EntityTitle>{name || ' '}</EntityTitle> </Link>
</Link> <TagContainer>
<TagContainer> <TagTermGroup uneditableGlossaryTerms={glossaryTerms} uneditableTags={tags} maxShow={3} />
<TagTermGroup uneditableGlossaryTerms={glossaryTerms} uneditableTags={tags} maxShow={3} /> </TagContainer>
</TagContainer> </TitleContainer>
</TitleContainer>
</Link>
{description.length > 0 && ( {description.length > 0 && (
<DescriptionContainer> <DescriptionContainer>
<NoMarkdownViewer limit={200}>{description}</NoMarkdownViewer> <NoMarkdownViewer limit={200}>{description}</NoMarkdownViewer>

View File

@ -49,6 +49,7 @@ export const SearchFilters = ({ facets, selectedFilters, onFilterSelect, loading
<> <>
{cachedProps.facets.map((facet) => ( {cachedProps.facets.map((facet) => (
<SearchFilter <SearchFilter
key={`${facet.displayName}-${facet.field}`}
facet={facet} facet={facet}
selectedFilters={cachedProps.selectedFilters} selectedFilters={cachedProps.selectedFilters}
onFilterSelect={onFilterSelectAndSetCache} onFilterSelect={onFilterSelectAndSetCache}

View File

@ -7,9 +7,9 @@ import styled from 'styled-components';
import defaultAvatar from '../../../images/default_avatar.png'; import defaultAvatar from '../../../images/default_avatar.png';
import getAvatarColor from './getAvatarColor'; import getAvatarColor from './getAvatarColor';
const AvatarStyled = styled(Avatar)<{ size?: number; backgroundColor: string }>` const AvatarStyled = styled(Avatar)<{ size?: number; $backgroundColor: string }>`
color: #fff; color: #fff;
background-color: ${(props) => props.backgroundColor}; background-color: ${(props) => props.$backgroundColor};
font-size: ${(props) => (props.size ? `${Math.max(props.size / 2.0, 14)}px` : '14px')} !important; font-size: ${(props) => (props.size ? `${Math.max(props.size / 2.0, 14)}px` : '14px')} !important;
margin-right: 4px; margin-right: 4px;
height: 24px; height: 24px;
@ -43,20 +43,20 @@ export default function CustomAvatar({
isGroup = false, isGroup = false,
}: Props) { }: Props) {
const avatarWithInitial = name ? ( const avatarWithInitial = name ? (
<AvatarStyled style={style} size={size} backgroundColor={getAvatarColor(name)}> <AvatarStyled style={style} size={size} $backgroundColor={getAvatarColor(name)}>
{name.charAt(0).toUpperCase()} {name.charAt(0).toUpperCase()}
</AvatarStyled> </AvatarStyled>
) : ( ) : (
<AvatarStyled src={defaultAvatar} style={style} size={size} backgroundColor={getAvatarColor(name)} /> <AvatarStyled src={defaultAvatar} style={style} size={size} $backgroundColor={getAvatarColor(name)} />
); );
const avatarWithDefault = useDefaultAvatar ? ( const avatarWithDefault = useDefaultAvatar ? (
<AvatarStyled src={defaultAvatar} style={style} size={size} backgroundColor={getAvatarColor(name)} /> <AvatarStyled src={defaultAvatar} style={style} size={size} $backgroundColor={getAvatarColor(name)} />
) : ( ) : (
avatarWithInitial avatarWithInitial
); );
const avatar = const avatar =
photoUrl && photoUrl !== '' ? ( photoUrl && photoUrl !== '' ? (
<AvatarStyled src={photoUrl} style={style} size={size} backgroundColor={getAvatarColor(name)} /> <AvatarStyled src={photoUrl} style={style} size={size} $backgroundColor={getAvatarColor(name)} />
) : ( ) : (
avatarWithDefault avatarWithDefault
); );