Skip to content

Commit

Permalink
Merge branch 'main' into 137988-category-field-api
Browse files Browse the repository at this point in the history
  • Loading branch information
jcger authored Sep 12, 2022
2 parents f9ba067 + 01d2851 commit f10c273
Show file tree
Hide file tree
Showing 183 changed files with 6,485 additions and 1,428 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
/src/plugins/saved_search/ @elastic/kibana-data-discovery
/x-pack/plugins/discover_enhanced/ @elastic/kibana-data-discovery
/test/functional/apps/discover/ @elastic/kibana-data-discovery
/test/functional/apps/context/ @elastic/kibana-data-discovery
/test/api_integration/apis/unified_field_list/ @elastic/kibana-data-discovery
/x-pack/plugins/graph/ @elastic/kibana-data-discovery
/x-pack/test/functional/apps/graph @elastic/kibana-data-discovery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

import { shallow } from 'enzyme';
import React from 'react';
import { UserProfile } from './user_profile';

import { UserProfilesPopover } from './user_profiles_popover';

const userProfiles = [
const userProfiles: UserProfile[] = [
{
uid: 'u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0',
enabled: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

import { mount } from 'enzyme';
import React from 'react';
import { UserProfile } from './user_profile';

import { UserProfilesSelectable } from './user_profiles_selectable';

const userProfiles = [
const userProfiles: UserProfile[] = [
{
uid: 'u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0',
enabled: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,8 @@ export class SavedSearchEmbeddable
ReactDOM.unmountComponentAtNode(this.node);
}
this.node = domNode;

this.renderReactComponent(this.node, this.searchProps!);
}

private renderReactComponent(domNode: HTMLElement, searchProps: SearchProps) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,13 @@ export const TableActions = ({
},
];

const testSubject = `openFieldActionsButton-${field}`;

if (mode === 'inline') {
return (
<EuiFlexGroup
responsive={false}
gutterSize="xs"
className="kbnDocViewer__buttons"
data-test-subj={testSubject}
data-test-subj={`fieldActionsGroup-${field}`}
>
{panels[0].items.map((item) => (
<EuiFlexItem key={item.icon} grow={false}>
Expand All @@ -210,7 +208,7 @@ export const TableActions = ({
<EuiPopover
button={
<EuiButtonIcon
data-test-subj={testSubject}
data-test-subj={`openFieldActionsButton-${field}`}
aria-label={openActionsLabel}
onClick={toggleOpenPopover}
iconType="boxesHorizontal"
Expand Down
12 changes: 10 additions & 2 deletions test/accessibility/apps/discover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

it('a11y test for actions on a field', async () => {
await PageObjects.discover.clickDocViewerTab(0);
await testSubjects.click('openFieldActionsButton-Cancelled');
if (await testSubjects.exists('openFieldActionsButton-Cancelled')) {
await testSubjects.click('openFieldActionsButton-Cancelled');
} else {
await testSubjects.existOrFail('fieldActionsGroup-Cancelled');
}
await a11y.testAppSnapshot();
});

it('a11y test for data-grid table with columns', async () => {
await testSubjects.click('toggleColumnButton-Cancelled');
await testSubjects.click('openFieldActionsButton-Carrier');
if (await testSubjects.exists('openFieldActionsButton-Carrier')) {
await testSubjects.click('openFieldActionsButton-Carrier');
} else {
await testSubjects.existOrFail('fieldActionsGroup-Carrier');
}
await testSubjects.click('toggleColumnButton-Carrier');
await testSubjects.click('euiFlyoutCloseButton');
await toasts.dismissAllToasts();
Expand Down
13 changes: 8 additions & 5 deletions test/functional/apps/context/_filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const TEST_COLUMN_NAMES = ['extension', 'geo.src'];
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const dataGrid = getService('dataGrid');
const filterBar = getService('filterBar');
const testSubjects = getService('testSubjects');
const retry = getService('retry');
const browser = getService('browser');

Expand All @@ -34,12 +33,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('inclusive filter should be addable via expanded data grid rows', async function () {
await retry.waitFor(`filter ${TEST_ANCHOR_FILTER_FIELD} in filterbar`, async () => {
await dataGrid.clickRowToggle({ isAnchorRow: true, renderMoreRows: true });
await testSubjects.click(`openFieldActionsButton-${TEST_ANCHOR_FILTER_FIELD}`);
await testSubjects.click(`addFilterForValueButton-${TEST_ANCHOR_FILTER_FIELD}`);
await dataGrid.clickFieldActionInFlyout(
TEST_ANCHOR_FILTER_FIELD,
'addFilterForValueButton'
);
await PageObjects.context.waitUntilContextLoadingHasFinished();

return await filterBar.hasFilter(TEST_ANCHOR_FILTER_FIELD, TEST_ANCHOR_FILTER_VALUE, true);
});

await dataGrid.closeFlyout();

await retry.waitFor(`filter matching docs in data grid`, async () => {
const fields = await dataGrid.getFields();
return fields
Expand Down Expand Up @@ -71,8 +75,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('filter for presence should be addable via expanded data grid rows', async function () {
await retry.waitFor('an exists filter in the filterbar', async () => {
await dataGrid.clickRowToggle({ isAnchorRow: true, renderMoreRows: true });
await testSubjects.click(`openFieldActionsButton-${TEST_ANCHOR_FILTER_FIELD}`);
await testSubjects.click(`addExistsFilterButton-${TEST_ANCHOR_FILTER_FIELD}`);
await dataGrid.clickFieldActionInFlyout(TEST_ANCHOR_FILTER_FIELD, 'addExistsFilterButton');
await PageObjects.context.waitUntilContextLoadingHasFinished();
return await filterBar.hasFilter(TEST_ANCHOR_FILTER_FIELD, 'exists', true);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

await dataGrid.checkCurrentRowsPerPageToBe(10);
});

it('should render duplicate saved search embeddables', async () => {
await PageObjects.dashboard.switchToEditMode();
await addSearchEmbeddableToDashboard();
const [firstGridCell, secondGridCell] = await dataGrid.getAllCellElements();
const firstGridCellContent = await firstGridCell.getVisibleText();
const secondGridCellContent = await secondGridCell.getVisibleText();

expect(firstGridCellContent).to.be.equal(secondGridCellContent);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.discover.waitUntilSearchingHasFinished();

await dataGrid.clickRowToggle({ rowIndex: 0 });

await testSubjects.click('openFieldActionsButton-@timestamp');
await testSubjects.click('addExistsFilterButton-@timestamp');
await dataGrid.clickFieldActionInFlyout('@timestamp', 'addExistsFilterButton');

const hasExistsFilter = await filterBar.hasFilter('@timestamp', 'exists', true, false, false);
expect(hasExistsFilter).to.be(true);
Expand Down
6 changes: 2 additions & 4 deletions test/functional/apps/discover/group2/_data_grid_doc_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,17 +197,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
// add columns
const fields = ['_id', '_index', 'agent'];
for (const field of fields) {
await testSubjects.click(`openFieldActionsButton-${field}`);
await testSubjects.click(`toggleColumnButton-${field}`);
await dataGrid.clickFieldActionInFlyout(field, 'toggleColumnButton');
}

const headerWithFields = await dataGrid.getHeaderFields();
expect(headerWithFields.join(' ')).to.contain(fields.join(' '));

// remove columns
for (const field of fields) {
await testSubjects.click(`openFieldActionsButton-${field}`);
await testSubjects.click(`toggleColumnButton-${field}`);
await dataGrid.clickFieldActionInFlyout(field, 'toggleColumnButton');
}

const headerWithoutFields = await dataGrid.getHeaderFields();
Expand Down
26 changes: 23 additions & 3 deletions test/functional/services/data_grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,24 @@ export class DataGridService extends FtrService {
.map((cell) => $(cell).text());
}

private getCellElementSelector(rowIndex: number = 0, columnIndex: number = 0) {
return `[data-test-subj="euiDataGridBody"] [data-test-subj="dataGridRowCell"][data-gridcell-column-index="${columnIndex}"][data-gridcell-row-index="${rowIndex}"]`;
}

/**
* Returns a grid cell element by row & column indexes.
* @param rowIndex data row index starting from 0 (0 means 1st row)
* @param columnIndex column index starting from 0 (0 means 1st column)
*/
public async getCellElement(rowIndex: number = 0, columnIndex: number = 0) {
return await this.find.byCssSelector(
`[data-test-subj="euiDataGridBody"] [data-test-subj="dataGridRowCell"][data-gridcell-column-index="${columnIndex}"][data-gridcell-row-index="${rowIndex}"]`
);
return await this.find.byCssSelector(this.getCellElementSelector(rowIndex, columnIndex));
}

/**
* The same as getCellElement, but useful when multiple data grids are on the page.
*/
public async getAllCellElements(rowIndex: number = 0, columnIndex: number = 0) {
return await this.find.allByCssSelector(this.getCellElementSelector(rowIndex, columnIndex));
}

public async getDocCount(): Promise<number> {
Expand Down Expand Up @@ -312,6 +321,17 @@ export class DataGridService extends FtrService {
return await tableDocViewRow.findByTestSubject(`~removeInclusiveFilterButton`);
}

public async clickFieldActionInFlyout(fieldName: string, actionName: string): Promise<void> {
const openPopoverButtonSelector = `openFieldActionsButton-${fieldName}`;
const inlineButtonsGroupSelector = `fieldActionsGroup-${fieldName}`;
if (await this.testSubjects.exists(openPopoverButtonSelector)) {
await this.testSubjects.click(openPopoverButtonSelector);
} else {
await this.testSubjects.existOrFail(inlineButtonsGroupSelector);
}
await this.testSubjects.click(`${actionName}-${fieldName}`);
}

public async removeInclusiveFilter(
detailsRow: WebElementWrapper,
fieldName: string
Expand Down
30 changes: 26 additions & 4 deletions x-pack/packages/ml/aiops_utils/src/stream_factory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ describe('streamFactory', () => {
streamResult += chunk.toString('utf8');
}

expect(responseWithHeaders.headers).toBe(undefined);
expect(responseWithHeaders.headers).toStrictEqual({
'Cache-Control': 'no-cache',
Connection: 'keep-alive',
'Transfer-Encoding': 'chunked',
'X-Accel-Buffering': 'no',
});
expect(streamResult).toBe('push1push2');
});

Expand All @@ -65,7 +70,12 @@ describe('streamFactory', () => {

const parsedItems = streamItems.map((d) => JSON.parse(d));

expect(responseWithHeaders.headers).toBe(undefined);
expect(responseWithHeaders.headers).toStrictEqual({
'Cache-Control': 'no-cache',
Connection: 'keep-alive',
'Transfer-Encoding': 'chunked',
'X-Accel-Buffering': 'no',
});
expect(parsedItems).toHaveLength(2);
expect(parsedItems[0]).toStrictEqual(mockItem1);
expect(parsedItems[1]).toStrictEqual(mockItem2);
Expand Down Expand Up @@ -105,7 +115,13 @@ describe('streamFactory', () => {

const streamResult = decoded.toString('utf8');

expect(responseWithHeaders.headers).toStrictEqual({ 'content-encoding': 'gzip' });
expect(responseWithHeaders.headers).toStrictEqual({
'Cache-Control': 'no-cache',
Connection: 'keep-alive',
'content-encoding': 'gzip',
'Transfer-Encoding': 'chunked',
'X-Accel-Buffering': 'no',
});
expect(streamResult).toBe('push1push2');

done();
Expand Down Expand Up @@ -143,7 +159,13 @@ describe('streamFactory', () => {

const parsedItems = streamItems.map((d) => JSON.parse(d));

expect(responseWithHeaders.headers).toStrictEqual({ 'content-encoding': 'gzip' });
expect(responseWithHeaders.headers).toStrictEqual({
'Cache-Control': 'no-cache',
Connection: 'keep-alive',
'content-encoding': 'gzip',
'Transfer-Encoding': 'chunked',
'X-Accel-Buffering': 'no',
});
expect(parsedItems).toHaveLength(2);
expect(parsedItems[0]).toStrictEqual(mockItem1);
expect(parsedItems[1]).toStrictEqual(mockItem2);
Expand Down
17 changes: 10 additions & 7 deletions x-pack/packages/ml/aiops_utils/src/stream_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,16 @@ export function streamFactory<T = unknown>(

const responseWithHeaders: StreamFactoryReturnType['responseWithHeaders'] = {
body: stream,
...(isCompressed
? {
headers: {
'content-encoding': 'gzip',
},
}
: {}),
headers: {
...(isCompressed ? { 'content-encoding': 'gzip' } : {}),

// This disables response buffering on proxy servers (Nginx, uwsgi, fastcgi, etc.)
// Otherwise, those proxies buffer responses up to 4/8 KiB.
'X-Accel-Buffering': 'no',
'Cache-Control': 'no-cache',
Connection: 'keep-alive',
'Transfer-Encoding': 'chunked',
},
};

return { DELIMITER, end, push, responseWithHeaders };
Expand Down
18 changes: 0 additions & 18 deletions x-pack/plugins/cases/common/api/cases/suggest_user_profiles.ts

This file was deleted.

13 changes: 8 additions & 5 deletions x-pack/plugins/cases/common/api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@

import * as rt from 'io-ts';

export const UserRT = rt.type({
email: rt.union([rt.undefined, rt.null, rt.string]),
full_name: rt.union([rt.undefined, rt.null, rt.string]),
username: rt.union([rt.undefined, rt.null, rt.string]),
});
export const UserRT = rt.intersection([
rt.type({
email: rt.union([rt.undefined, rt.null, rt.string]),
full_name: rt.union([rt.undefined, rt.null, rt.string]),
username: rt.union([rt.undefined, rt.null, rt.string]),
}),
rt.partial({ profile_uid: rt.string }),
]);

export const UsersRt = rt.array(UserRT);

Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/cases/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,8 @@ export const PUSH_CASES_CAPABILITY = 'push_cases' as const;
*/

export const DEFAULT_USER_SIZE = 10;

/**
* Delays
*/
export const SEARCH_DEBOUNCE_MS = 500;
3 changes: 2 additions & 1 deletion x-pack/plugins/cases/common/ui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export interface FilterOptions {
severity: CaseSeverityWithAll;
status: CaseStatusWithAllStatus;
tags: string[];
assignees: string[];
reporters: User[];
owner: string[];
}
Expand Down Expand Up @@ -162,7 +163,7 @@ export interface FieldMappings {

export type UpdateKey = keyof Pick<
CasePatchRequest,
'connector' | 'description' | 'status' | 'tags' | 'title' | 'settings' | 'severity'
'connector' | 'description' | 'status' | 'tags' | 'title' | 'settings' | 'severity' | 'assignees'
>;

export interface UpdateByKey {
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/cases/public/common/mock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
*/

export * from './test_providers';
export * from './permissions';
Loading

0 comments on commit f10c273

Please sign in to comment.