Skip to content

Commit

Permalink
Add Selector Language cheat sheet (#1392)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeepc committed Oct 26, 2022
1 parent 15ca8b9 commit 278f33d
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 21 deletions.
Binary file added web/public/SL_cheat_sheet.pdf
Binary file not shown.
5 changes: 4 additions & 1 deletion web/src/components/TestHeader/__tests__/TestHeader.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import TestMock from '../../../models/__mocks__/Test.mock';
import TestHeader from '../TestHeader';

test('SpanAttributesTable', () => {
const {getByTestId} = render(<TestHeader onBack={jest.fn()} test={TestMock.model()} />);
const test = TestMock.model();
const {getByTestId} = render(
<TestHeader description={test.description} id={test.id} onBack={jest.fn()} onDelete={jest.fn} title={test.name} />
);
expect(getByTestId('test-details-name')).toBeInTheDocument();
});
14 changes: 12 additions & 2 deletions web/src/components/TestSpecForm/TestSpecForm.styled.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {DeleteOutlined} from '@ant-design/icons';
import {DeleteOutlined, ReadOutlined} from '@ant-design/icons';
import {Button, Select as AntSelect, Typography} from 'antd';
import styled from 'styled-components';

Expand Down Expand Up @@ -88,6 +88,12 @@ export const FormSectionRow1 = styled.div`
gap: 12px;
`;

export const FormSectionHeaderSelector = styled.div`
align-items: center;
display: flex;
justify-content: space-between;
`;

export const FormSectionTitle = styled(Typography.Title).attrs({level: 3})<{$noMargin?: boolean}>`
&& {
margin-bottom: ${({$noMargin}) => ($noMargin ? '0' : '4px')};
Expand All @@ -98,6 +104,10 @@ export const FormSectionText = styled(Typography.Text)`
color: ${({theme}) => theme.color.textSecondary};
`;

export const ReadIcon = styled(ReadOutlined)`
margin-top: 4px;
`;

export const ExpectedInputContainer = styled.div`
width: 0;
flex-basis: 50%;
Expand All @@ -112,7 +122,7 @@ export const ExpectedInputContainer = styled.div`
outline: 1px solid grey;
height: 32px;
font-family: SFPro, serif;
outline: 1px solid #CDD1DB;
outline: 1px solid #cdd1db;
}
.cm-content {
Expand Down
25 changes: 14 additions & 11 deletions web/src/components/TestSpecForm/TestSpecForm.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import {Button, Form, Tag} from 'antd';
import {useState} from 'react';
import {ADVANCE_SELECTORS_DOCUMENTATION_URL} from 'constants/Common.constants';

import {SELECTOR_LANGUAGE_CHEAT_SHEET_URL} from 'constants/Common.constants';
import {CompareOperator} from 'constants/Operator.constants';
import {useAppSelector} from 'redux/hooks';
import AssertionSelectors from 'selectors/Assertion.selectors';
import SpanSelectors from 'selectors/Span.selectors';
import OperatorService from 'services/Operator.service';
import {TStructuredAssertion} from 'types/Assertion.types';
import {singularOrPlural} from 'utils/Common';
import AssertionCheckList from './AssertionCheckList';
import useAssertionFormValues from './hooks/useAssertionFormValues';
import useOnFieldsChange from './hooks/useOnFieldsChange';
import SelectorInput from './SelectorInput';
import * as S from './TestSpecForm.styled';
import {CompareOperator} from '../../constants/Operator.constants';
import OperatorService from '../../services/Operator.service';

export interface IValues {
assertions?: TStructuredAssertion[];
Expand Down Expand Up @@ -77,15 +78,17 @@ const TestSpecForm = ({
onFieldsChange={onFieldsChange}
>
<S.FormSection>
<S.FormSectionRow1>
<S.FormSectionTitle $noMargin>1. Select Spans</S.FormSectionTitle>
<Tag color="blue">{`${spanIdList.length} ${singularOrPlural('span', spanIdList.length)} selected`}</Tag>
</S.FormSectionRow1>
<S.FormSectionRow>
<S.FormSectionText>Specify which spans to assert using the </S.FormSectionText>
<a href={ADVANCE_SELECTORS_DOCUMENTATION_URL} target="_blank">
Selector Language
<S.FormSectionHeaderSelector>
<S.FormSectionRow1>
<S.FormSectionTitle $noMargin>1. Select Spans</S.FormSectionTitle>
<Tag color="blue">{`${spanIdList.length} ${singularOrPlural('span', spanIdList.length)} selected`}</Tag>
</S.FormSectionRow1>
<a href={SELECTOR_LANGUAGE_CHEAT_SHEET_URL} target="_blank">
<S.ReadIcon /> SL cheat sheet
</a>
</S.FormSectionHeaderSelector>
<S.FormSectionRow>
<S.FormSectionText>Select the spans to which a set of assertions will be applied</S.FormSectionText>
</S.FormSectionRow>
<SelectorInput form={form} testId={testId} runId={runId} onValidSelector={setIsValid} />
</S.FormSection>
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/TestSpecs/Empty.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ADVANCE_SELECTORS_DOCUMENTATION_URL} from 'constants/Common.constants';
import {ADD_TEST_SPECS_DOCUMENTATION_URL} from 'constants/Common.constants';
import * as S from './TestSpecs.styled';

const Empty = () => (
Expand All @@ -8,7 +8,7 @@ const Empty = () => (
<S.EmptyText>Add a Test Spec to validate your trace.</S.EmptyText>
<S.EmptyText>
Learn more about writing specs{' '}
<a href={ADVANCE_SELECTORS_DOCUMENTATION_URL} target="_blank">
<a href={ADD_TEST_SPECS_DOCUMENTATION_URL} target="_blank">
here
</a>
</S.EmptyText>
Expand Down
3 changes: 2 additions & 1 deletion web/src/components/TransactionHeader/TransactionHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import TestCardActions from 'components/TestCard/TestCardActions';
import {noop} from 'lodash';
import {useTransaction} from '../../providers/TransactionRunDetail/TransactionRunDetailProvider';
import {useTransaction} from 'providers/TransactionRunDetail/TransactionRunDetailProvider';
import * as S from './TransactionHeader.styled';

interface IProps {
Expand All @@ -9,6 +9,7 @@ interface IProps {

const TransactionHeader = ({onBack}: IProps) => {
const {transaction} = useTransaction();

return (
<S.Container>
<S.Section>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {render} from 'test-utils';
import TransactionMock from '../../../models/__mocks__/Transaction.mock';
import TransactionHeader from '../TransactionHeader';

test('TransactionHeader', () => {
const {getByTestId} = render(<TransactionHeader onBack={jest.fn()} transaction={TransactionMock.model()} />);
const {getByTestId} = render(<TransactionHeader onBack={jest.fn()} />);
expect(getByTestId('transaction-details-name')).toBeInTheDocument();
});
5 changes: 3 additions & 2 deletions web/src/constants/Common.constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export const BASE_URL = 'http://localhost:11633';
export const SENTRY_DNS = 'https://8411cbb3b7d84c879f711f0e642a28e3@o1229268.ingest.sentry.io/6375361';

export const SENTRY_ALLOWED_URLS = [/.*?localhost:3000/, /.*?tracetest.io/];
Expand All @@ -15,7 +14,9 @@ export const RESOURCE_SEMANTIC_CONVENTIONS_URL =
export const TRACE_DOCUMENTATION_URL =
'https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md';

export const ADVANCE_SELECTORS_DOCUMENTATION_URL = 'https://kubeshop.github.io/tracetest/advanced-selectors/';
export const ADD_TEST_SPECS_DOCUMENTATION_URL = 'https://docs.tracetest.io/adding-assertions/';

export const SELECTOR_LANGUAGE_CHEAT_SHEET_URL = `${process.env.PUBLIC_URL}/SL_cheat_sheet.pdf`;

export enum HTTP_METHOD {
GET = 'GET',
Expand Down

0 comments on commit 278f33d

Please sign in to comment.