Skip to content

Commit

Permalink
511 adding the types coming from the openapi specs
Browse files Browse the repository at this point in the history
  • Loading branch information
xoscar authored and cescoferraro committed May 23, 2022
1 parent ed4b9c9 commit f78a8f5
Show file tree
Hide file tree
Showing 137 changed files with 1,758 additions and 2,156 deletions.
184 changes: 184 additions & 0 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"test:unit": "craco test --watchAll=false --coverage",
"test:integration": "npm run cy:run",
"lint": "npm run eslint && npm run types",
"types:generate": "openapi-typescript ../api/openapi.yaml --output ./src/types/Generated.types.ts",
"types": "tsc",
"eslint": "eslint ./src/**/*.{ts,tsx}",
"test": "npm run test:unit",
Expand Down Expand Up @@ -126,6 +127,7 @@
"eslint-plugin-react-hooks": "4.3.0",
"eslint-plugin-unused-imports": "2.0.0",
"jest-fetch-mock": "3.0.3",
"openapi-typescript": "5.3.0",
"prettier": "2.5.1",
"webpack": "5.72.0"
},
Expand Down
30 changes: 16 additions & 14 deletions web/src/components/AssertionCard/AssertionCard.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import {useCallback, useMemo} from 'react';
import {useStore} from 'react-flow-renderer';
import {IAssertionResult} from '../../types/Assertion.types';
import {TAssertionResultEntry, TSpanSelector} from '../../types/Assertion.types';
import AssertionCheckRow from '../AssertionCheckRow';
import * as S from './AssertionCard.styled';

interface IAssertionCardProps {
assertionResult: IAssertionResult;
interface TAssertionCardProps {
assertionResult: TAssertionResultEntry;
selectorList: TSpanSelector[];
onSelectSpan(spanId: string): void;
onDelete(assertionId: string): void;
onEdit(assertionResult: IAssertionResult): void;
onEdit(assertionResult: TAssertionResultEntry): void;
}

const AssertionCard: React.FC<IAssertionCardProps> = ({
assertionResult: {assertion: {selectors = [], assertionId = ''} = {}, spanListAssertionResult},
const AssertionCard: React.FC<TAssertionCardProps> = ({
assertionResult: {resultList, id: assertionId},
selectorList,
assertionResult,
onSelectSpan,
onDelete,
Expand All @@ -21,10 +23,10 @@ const AssertionCard: React.FC<IAssertionCardProps> = ({
const store = useStore();

const spanCountText = useMemo(() => {
const spanCount = spanListAssertionResult.length;
const spanCount = resultList.length;

return `${spanCount} ${spanCount > 1 ? 'spans' : 'span'}`;
}, [spanListAssertionResult.length]);
}, [resultList.length]);

const getIsSelectedSpan = useCallback(
(id: string): boolean => {
Expand All @@ -40,7 +42,7 @@ const AssertionCard: React.FC<IAssertionCardProps> = ({
<S.AssertionCard data-cy="assertion-card">
<S.Header>
<div>
<S.SelectorListText>{selectors.map(({value}) => value).join(' ')}</S.SelectorListText>
<S.SelectorListText>{selectorList.map(({value}) => value).join(' ')}</S.SelectorListText>
<S.SpanCountText>{spanCountText}</S.SpanCountText>
</div>
<div>
Expand All @@ -49,15 +51,15 @@ const AssertionCard: React.FC<IAssertionCardProps> = ({
</div>
</S.Header>
<S.Body>
{spanListAssertionResult.flatMap(({span, resultList}) =>
resultList.map(result => (
{resultList.flatMap(({spanResults, assertion: {attribute}, assertion}) =>
spanResults.map(result => (
<AssertionCheckRow
key={`${result.propertyName}-${span.spanId}`}
key={`${attribute}-${result.spanId}`}
assertion={assertion}
result={result}
span={span}
onSelectSpan={onSelectSpan}
getIsSelectedSpan={getIsSelectedSpan}
assertionSelectorList={selectors.map(({value}) => value)}
assertionSelectorList={selectorList.map(({value}) => value)}
/>
))
)}
Expand Down

This file was deleted.

Loading

0 comments on commit f78a8f5

Please sign in to comment.