Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(frontend): fix test specs detail list #3642

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web/src/components/RunDetailTest/TestPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ interface IProps {

const TestPanel = ({run, testId, runEvents}: IProps) => {
const [query, updateQuery] = useSearchParams();
const {selectedSpan, onSetFocusedSpan, onSelectSpan} = useSpan();
const {selectedSpan, onSetFocusedSpan} = useSpan();
const {remove, revert, selectedTestSpec, setSelectedSpec, setSelectorSuggestions, setPrevSelector, specs} =
useTestSpecs();
const {isOpen: isTestSpecFormOpen, formProps, onSubmit, open, close, isValid, onIsValid} = useTestSpecForm();
Expand Down
90 changes: 49 additions & 41 deletions web/src/components/TestSpecDetail/Content.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {useEffect, useMemo, useRef} from 'react';
import {FixedSizeList as List} from 'react-window';
import {useCallback, useEffect, useMemo, useRef} from 'react';
import {VariableSizeList as List} from 'react-window';
import AutoSizer, {Size} from 'react-virtualized-auto-sizer';

import {useAppSelector} from 'redux/hooks';
Expand All @@ -10,6 +10,7 @@ import {TAssertionResultEntry} from 'models/AssertionResults.model';
import Header from './Header';
import ResultCard from './ResultCard';
import Search from './Search';
import * as S from './TestSpecDetail.styled';

interface IProps {
onClose(): void;
Expand Down Expand Up @@ -53,51 +54,58 @@ const Content = ({
}
}, [results, selectedSpan]);

const itemSize = useMemo(() => {
const [, checkResults = []] = results[0];
const getItemSize = useCallback(
index => {
const [, checkResults = []] = results[index];

return checkResults.length * 72.59 + 40 + 16;
}, [results]);
return checkResults.length * 72.59 + 40 + 16;
},
[results]
);

return (
<>
<Header
affectedSpans={spanIds?.length ?? 0}
assertionsFailed={totalPassedChecks?.false ?? 0}
assertionsPassed={totalPassedChecks?.true ?? 0}
isDeleted={isDeleted}
isDraft={isDraft}
onClose={onClose}
onDelete={() => {
onDelete(testSpec.selector);
onClose();
}}
onEdit={() => {
onEdit(testSpec, name);
}}
onRevert={() => {
onRevert(originalSelector);
}}
selector={selector}
title={!selector && !name ? 'All Spans' : name}
/>
<div>
<Header
affectedSpans={spanIds?.length ?? 0}
assertionsFailed={totalPassedChecks?.false ?? 0}
assertionsPassed={totalPassedChecks?.true ?? 0}
isDeleted={isDeleted}
isDraft={isDraft}
onClose={onClose}
onDelete={() => {
onDelete(testSpec.selector);
onClose();
}}
onEdit={() => {
onEdit(testSpec, name);
}}
onRevert={() => {
onRevert(originalSelector);
}}
selector={selector}
title={!selector && !name ? 'All Spans' : name}
/>

<Search />
<Search />
</div>

<AutoSizer>
{({height, width}: Size) => (
<List
ref={listRef}
height={height}
itemCount={results.length}
itemData={results}
itemSize={itemSize}
width={width}
>
{ResultCard}
</List>
)}
</AutoSizer>
<S.DrawerRow>
<AutoSizer>
{({height, width}: Size) => (
<List
ref={listRef}
height={height}
itemCount={results.length}
itemData={results}
itemSize={getItemSize}
width={width}
>
{ResultCard}
</List>
)}
</AutoSizer>
</S.DrawerRow>
</>
);
};
Expand Down
9 changes: 9 additions & 0 deletions web/src/components/TestSpecDetail/TestSpecDetail.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ export const CardContainer = styled(Card)<{$isSelected: boolean; $type: Semantic
export const DrawerContainer = styled(Drawer)`
position: absolute;
overflow: hidden;

.ant-drawer-body {
display: flex;
flex-direction: column;
}
`;

export const DrawerRow = styled.div`
flex: 1;
`;

export const GridContainer = styled.div`
Expand Down
Loading