Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Upgrade assistant] Filter Kibana deprecations issues by status #211900

Merged
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 @@ -81,12 +81,14 @@ describe('Kibana deprecations - Deprecations table', () => {
const { actions, table } = testBed;

// Show only critical deprecations
await actions.searchBar.clickCriticalFilterButton();
await actions.searchBar.openStatusFilterDropdown();
await actions.searchBar.filterByTitle('Critical');
const { rows: criticalRows } = table.getMetaData('kibanaDeprecationsTable');
expect(criticalRows.length).toEqual(mockedCriticalKibanaDeprecations.length);

// Show all deprecations
await actions.searchBar.clickCriticalFilterButton();
await actions.searchBar.openStatusFilterDropdown();
await actions.searchBar.filterByTitle('Critical');
const { rows: allRows } = table.getMetaData('kibanaDeprecationsTable');
expect(allRows.length).toEqual(mockedKibanaDeprecations.length);
});
Expand All @@ -95,7 +97,7 @@ describe('Kibana deprecations - Deprecations table', () => {
const { table, actions } = testBed;

await actions.searchBar.openTypeFilterDropdown();
await actions.searchBar.filterByConfigType();
await actions.searchBar.filterByTitle('Config');

const { rows: configRows } = table.getMetaData('kibanaDeprecationsTable');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,44 +57,43 @@ const createActions = (testBed: TestBed) => {
},
};

const openFilterByIndex = async (index: number) => {
await act(async () => {
// EUI doesn't support data-test-subj's on the filter buttons, so we must access via CSS selector
find('kibanaDeprecations')
.find('.euiSearchBar__filtersHolder')
.find('.euiPopover')
.find('button.euiFilterButton')
.at(index)
.simulate('click');
});

component.update();

// Wait for the filter dropdown to be displayed
await new Promise(requestAnimationFrame);
};

const searchBarActions = {
openTypeFilterDropdown: async () => {
await act(async () => {
// EUI doesn't support data-test-subj's on the filter buttons, so we must access via CSS selector
find('kibanaDeprecations')
.find('.euiSearchBar__filtersHolder')
.find('.euiPopover')
.find('button.euiFilterButton')
.at(0)
.simulate('click');
});

component.update();
await openFilterByIndex(1);
},

clickCriticalFilterButton: async () => {
await act(async () => {
// EUI doesn't support data-test-subj's on the filter buttons, so we must access via CSS selector
find('kibanaDeprecations')
.find('.euiSearchBar__filtersHolder')
.find('button.euiFilterButton')
.at(0)
.simulate('click');
});

component.update();
openStatusFilterDropdown: async () => {
await openFilterByIndex(0);
},

filterByConfigType: async () => {
filterByTitle: async (title: string) => {
// We need to read the document "body" as the filter dropdown (an EuiSelectable)
// is added in a portalled popover and not inside the component DOM tree.
// The "Config" option is expected to be the first item.
const configTypeFilterButton: HTMLButtonElement | null = document.body.querySelector(
'.euiSelectableList .euiSelectableListItem'
const filterButton: HTMLButtonElement | null = document.body.querySelector(
`.euiSelectableListItem[title=${title}]`
);

expect(filterButton).not.toBeNull();

await act(async () => {
configTypeFilterButton!.click();
filterButton!.click();
});

component.update();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,24 @@ const i18nTexts = {
defaultMessage: 'Type',
}
),
statusFilterLabel: i18n.translate(
'xpack.upgradeAssistant.kibanaDeprecations.table.statusFilterLabel',
{
defaultMessage: 'Status',
}
),
criticalFilterLabel: i18n.translate(
'xpack.upgradeAssistant.kibanaDeprecations.table.criticalFilterLabel',
{
defaultMessage: 'Critical',
}
),
warningFilterLabel: i18n.translate(
'xpack.upgradeAssistant.kibanaDeprecations.table.warningFilterLabel',
{
defaultMessage: 'Warning',
}
),
searchPlaceholderLabel: i18n.translate(
'xpack.upgradeAssistant.kibanaDeprecations.table.searchPlaceholderLabel',
{
Expand Down Expand Up @@ -181,10 +193,20 @@ export const KibanaDeprecationsTable: React.FunctionComponent<Props> = ({
const searchConfig: Search = {
filters: [
{
type: 'field_value_toggle',
name: i18nTexts.criticalFilterLabel,
type: 'field_value_selection',
field: 'level',
value: 'critical',
name: i18nTexts.statusFilterLabel,
multiSelect: false,
options: [
{
value: 'critical',
name: i18nTexts.criticalFilterLabel,
},
{
value: 'warning',
name: i18nTexts.warningFilterLabel,
},
],
},
{
type: 'field_value_selection',
Expand Down