Skip to content

Commit

Permalink
Merge pull request #76 from kubeshop/mm/feat/assertionresultsdata
Browse files Browse the repository at this point in the history
fix: create assertion trace data
  • Loading branch information
mortada-codes committed Mar 10, 2022
2 parents bdd63da + 13a62be commit 5cd3602
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2,021 deletions.
4 changes: 3 additions & 1 deletion web/src/components/Trace/AssertionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import CreateAssertionModal from './CreateAssertionModal';
interface IProps {
testId: string;
targetSpan: ISpan;
trace: any;
}

const AssertionList = ({testId, targetSpan}: IProps) => {
const AssertionList = ({testId, targetSpan, trace}: IProps) => {
const [openCreateAssertion, setOpenCreateAssertion] = useState(false);
const {data: testAssertions} = useGetTestAssertionsQuery(testId);
return (
Expand All @@ -19,6 +20,7 @@ const AssertionList = ({testId, targetSpan}: IProps) => {
<CreateAssertionModal
key={`KEY_${targetSpan.spanId}`}
testId={testId}
trace={trace}
span={targetSpan}
open={openCreateAssertion}
onClose={() => setOpenCreateAssertion(false)}
Expand Down
8 changes: 4 additions & 4 deletions web/src/components/Trace/CreateAssertionModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import Text from 'antd/lib/typography/Text';

import {IAttribute, ISpan} from 'types';
import {useCreateAssertionMutation} from 'services/TestService';
import data from './data.json';

const {Title} = Typography;
interface IProps {
open: boolean;
onClose: () => void;
span: ISpan;
testId: string;
trace: any;
}

const Select = styled(AntSelect)`
Expand Down Expand Up @@ -43,11 +43,11 @@ const selectorConditionBuilder = (attribute: IAttribute) => {
}
};

const CreateAssertionModal = ({testId, span, open, onClose}: IProps) => {
const CreateAssertionModal = ({testId, span, trace, open, onClose}: IProps) => {
const [assertionList, setAssertionList] = useState<Array<string>>(Array(3).fill(''));
const [createAssertion, result] = useCreateAssertionMutation();
const attrs = jemsPath.search(trace, filterBySpanId(span.spanId));

const attrs = jemsPath.search(data, filterBySpanId(span.spanId));
const selectorCondition = assertionList
.map(k => {
return attrs?.find((el: any) => el.key === k);
Expand All @@ -56,7 +56,7 @@ const CreateAssertionModal = ({testId, span, open, onClose}: IProps) => {
.map(item => selectorConditionBuilder(item))
.join(' && ');
console.log('@@query', selectionPipe(filterByAttributes(selectorCondition)));
const effectedSpans = jemsPath.search(data, selectionPipe(filterByAttributes(selectorCondition)));
const effectedSpans = jemsPath.search(trace, selectionPipe(filterByAttributes(selectorCondition)));
const spanTagsMap = attrs.reduce((acc: {[x: string]: any}, item: {key: string}) => {
const keyPrefix = item.key.split('.').shift() || item.key;
if (!keyPrefix) {
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Trace/Trace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const Trace = ({test, testResultId}: {test: Test; testResultId: string}) => {
</Tabs.TabPane>
{spanMap[selectedSpan.id]?.data && (
<Tabs.TabPane tab="Assertions" key="2">
<AssertionList testId={test.id} targetSpan={spanMap[selectedSpan.id]?.data} />
<AssertionList trace={traceData} testId={test.id} targetSpan={spanMap[selectedSpan.id]?.data} />
</Tabs.TabPane>
)}
</Tabs>
Expand Down
Loading

0 comments on commit 5cd3602

Please sign in to comment.