Skip to content

Commit

Permalink
chore(Filters): fix visual tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagostn committed Sep 12, 2023
1 parent 849fb0c commit 00ec13f
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/Filters/Filters.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export interface Filter {
isApplied: boolean;
isLoading: boolean;
isCanceled: boolean;
value?: string | string[] | Date | BaseDateRange;
value?: string | string[] | Date | BaseDateRange | Record<string, unknown>;
}

export interface FiltersProps {
Expand Down
54 changes: 54 additions & 0 deletions src/components/Filters/mocks/MockObjectFilter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React, { useState } from 'react';
import { always } from 'ramda';

import { SpaceSizes } from '../../../theme';
import { Inline, Padbox } from '../../layout';
import { InputFilter, SelectFilter } from '../components';

type MockObject = {
inputValue: string;
includeAssets: string[];
};

interface MockObjectFilterProps {
value: MockObject;
}

const MockObjectFilter: React.FC<MockObjectFilterProps> = ({ value }) => {
const [ipValue, setIpValue] = useState(value?.inputValue);
const options = [
{
label: 'Include associated subdomains',
value: 'include_domains',
},
{
label: 'Include associated IPs',
value: 'include_ips',
},
];

const handleOnChange = (event) => {
const { target } = event;
setIpValue(target.value);
};
const validate = always(false);
const handleOnError = () => {
// do nothing
};

return (
<Padbox>
<Inline gap={SpaceSizes.sm} stretch="all">
<InputFilter
placeholder="IP"
value={ipValue}
onChange={handleOnChange}
onError={handleOnError}
onValidate={validate}
/>
<SelectFilter options={options} isMulti />
</Inline>
</Padbox>
);
};
export default MockObjectFilter;
22 changes: 22 additions & 0 deletions src/components/Filters/mocks/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { Field, Filter } from '../Filters.types';
import { Operators } from '../Filters.enums';
import { patterns, validateDomains, validateIPs } from './validations';
import MockObjectFilter from './MockObjectFilter';

export const mockTestFields: Field[] = [
{
Expand Down Expand Up @@ -324,6 +325,18 @@ export const fields: Field[] = [
value: 'detection method',
label: 'Detection Method',
},
{
conditions: [
{ component: MockObjectFilter, value: 'is', label: 'is' },
{
component: MockObjectFilter,
value: 'is not',
label: 'is not',
},
],
value: 'ip and assets',
label: 'IP and Assets',
},
];

export const state: Filter[] = [
Expand Down Expand Up @@ -404,6 +417,15 @@ export const state: Filter[] = [
isLoading: false,
isCanceled: false,
},
{
operator: Operators.and,
field: 'ip and assets',
condition: 'is',
value: { inputValue: '1.1.1.1', includeAsset: ['include_domains'] },
isApplied: true,
isLoading: false,
isCanceled: false,
},
];

export const stateWithUnappliedFilters: Filter[] = [
Expand Down

0 comments on commit 00ec13f

Please sign in to comment.