Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export interface ExploreQuickFilterField {
hideSearchBar?: boolean;
searchIndex?: SearchIndex;
searchKey?: string;
sourceFields?: string;
dropdownClassName?: string;
singleSelect?: boolean;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ describe('ExploreQuickFilters component', () => {
false,
undefined,
false,
'pets'
'pets',
undefined
);
});
});
Expand All @@ -341,7 +342,8 @@ describe('ExploreQuickFilters component', () => {
false,
undefined,
false,
''
'',
undefined
);
});
});
Expand Down Expand Up @@ -371,7 +373,8 @@ describe('ExploreQuickFilters component', () => {
false,
undefined,
false,
''
'',
undefined
);
});
});
Expand Down Expand Up @@ -407,7 +410,8 @@ describe('ExploreQuickFilters component', () => {
false,
50,
false,
''
'',
undefined
);
});
});
Expand Down Expand Up @@ -437,7 +441,8 @@ describe('ExploreQuickFilters component', () => {
false,
undefined,
false,
''
'',
undefined
);
});
});
Expand Down Expand Up @@ -475,11 +480,113 @@ describe('ExploreQuickFilters component', () => {
false,
undefined,
false,
''
'',
undefined
);
});
});

it('should pass mapped sourceFields for owners quick filter', async () => {
mockGetAggregationOptions.mockResolvedValue({
data: {
aggregations: {
'sterms#ownerDisplayName': {
buckets: [
{
key: 'data-team',
doc_count: 2,
'top_hits#top': {
hits: {
hits: [
{
_source: {
ownerDisplayName: ['Data Team'],
},
},
],
},
},
},
],
},
},
},
});

const ownerFields: ExploreQuickFilterField[] = [
{ label: 'Owner', key: EntityFields.OWNERS, value: undefined },
];

render(<ExploreQuickFilters {...mockProps} fields={ownerFields} />);

await act(async () => {
userEvent.click(screen.getByTestId(`onSearch-${EntityFields.OWNERS}`));
});

await waitFor(() => {
expect(getAggregationOptions).toHaveBeenCalledWith(
SearchIndex.TABLE,
EntityFields.OWNERS,
'test',
expect.any(String),
false,
false,
undefined,
false,
'',
'ownerDisplayName'
);
});
});

it('should format entity type option labels with proper casing', async () => {
const entityTypeFields: ExploreQuickFilterField[] = [
{
label: 'Entity Type',
key: EntityFields.ENTITY_TYPE_KEYWORD,
value: undefined,
},
];
const entityTypeAggregations = {
[EntityFields.ENTITY_TYPE_KEYWORD]: {
buckets: [
{
key: 'dashboarddatamodel',
doc_count: 2,
},
{
key: 'apiendpoint',
doc_count: 1,
},
],
},
};

render(
<ExploreQuickFilters
{...mockProps}
aggregations={entityTypeAggregations}
fields={entityTypeFields}
/>
);

await act(async () => {
userEvent.click(
screen.getByTestId(
`onGetInitialOptions-${EntityFields.ENTITY_TYPE_KEYWORD}`
)
);
});

await waitFor(() => {
expect(
screen.getByText('Dashboard Data Model - 2')
).toBeInTheDocument();
});

expect(screen.getByText('Api Endpoint - 1')).toBeInTheDocument();
});

it('should call getInitialOptions when search value is empty', async () => {
mockGetAggregationOptions.mockResolvedValue(
mockAdvancedFieldDefaultOptions
Expand Down Expand Up @@ -523,7 +630,8 @@ describe('ExploreQuickFilters component', () => {
false,
undefined,
false,
''
'',
undefined
);
});
});
Expand Down Expand Up @@ -552,7 +660,8 @@ describe('ExploreQuickFilters component', () => {
false,
undefined,
true,
''
'',
undefined
);
});
});
Expand Down Expand Up @@ -679,7 +788,8 @@ describe('ExploreQuickFilters component', () => {
expect.anything(),
undefined,
expect.anything(),
expect.any(String)
expect.any(String),
undefined
);
});
});
Expand Down Expand Up @@ -714,7 +824,8 @@ describe('ExploreQuickFilters component', () => {
false,
undefined,
false,
''
'',
undefined
);
});
});
Expand Down
Loading
Loading