Skip to content

Commit 2c963b4

Browse files
authored
Merge branch 'main' into event-driven-triggers_testing-modal_telemetry
2 parents 7757ab4 + 3790a2e commit 2c963b4

201 files changed

Lines changed: 4131 additions & 2239 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/core/test/scout/.meta/api/standard.json

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"sha1": "2b70f3fcb59bf151aebaba39638cabf81e58deca",
2+
"sha1": "67a81345ddcbff97602a970df9c912ec77780659",
33
"tests": [
44
{
55
"id": "686afb1e43c1702-93eb078795ca679",
@@ -325,6 +325,32 @@
325325
"column": 10
326326
}
327327
},
328+
{
329+
"id": "6054c2de485a042-eec0454c4331f2c",
330+
"title": "translations serves a non-default locale file with the locale field intact",
331+
"expectedStatus": "passed",
332+
"tags": [
333+
"@local-stateful-classic",
334+
"@cloud-stateful-classic",
335+
"@local-stateful-search",
336+
"@cloud-stateful-search",
337+
"@local-stateful-observability_complete",
338+
"@cloud-stateful-observability_complete",
339+
"@local-stateful-security_complete",
340+
"@cloud-stateful-security_complete",
341+
"@local-serverless-search",
342+
"@cloud-serverless-search",
343+
"@local-serverless-observability_complete",
344+
"@cloud-serverless-observability_complete",
345+
"@local-serverless-security_complete",
346+
"@cloud-serverless-security_complete"
347+
],
348+
"location": {
349+
"file": "src/core/test/scout/api/tests/translations.spec.ts",
350+
"line": 45,
351+
"column": 10
352+
}
353+
},
328354
{
329355
"id": "6054c2de485a042-7c1b7d0f5a752d1",
330356
"title": "translations returns a 404 when not using the correct locale",
@@ -347,7 +373,7 @@
347373
],
348374
"location": {
349375
"file": "src/core/test/scout/api/tests/translations.spec.ts",
350-
"line": 45,
376+
"line": 71,
351377
"column": 10
352378
}
353379
},

src/platform/packages/shared/kbn-react-hooks/src/use_stable_callback/use_stable_callback.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
import { useEffect, useRef } from 'react';
10+
import { useState } from 'react';
11+
import useLatest from 'react-use/lib/useLatest';
1112

1213
/**
1314
* Accepts a callback and returns a function with a stable identity
1415
* that will always call the latest version of the callback when invoked
1516
*/
16-
export const useStableCallback = <T extends (...args: never[]) => unknown>(fn: T | undefined) => {
17-
const ref = useRef(fn);
17+
export const useStableCallback = <T extends (...args: Parameters<T>) => ReturnType<T>>(fn: T) => {
18+
const latestFn = useLatest(fn);
19+
const [stableFn] = useState(() => {
20+
return ((...args: Parameters<T>) => latestFn.current(...args)) as T;
21+
});
1822

19-
useEffect(() => {
20-
ref.current = fn;
21-
}, [fn]);
22-
23-
return useRef((...args: Parameters<T>) => ref.current?.(...args)).current;
23+
return stableFn;
2424
};

src/platform/plugins/private/interactive_setup/public/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const App: FunctionComponent<AppProps> = ({ onSuccess }) => {
7676
${euiShadowM};
7777
`}
7878
>
79-
<EuiIcon type="logoElastic" size="xxl" />
79+
<EuiIcon type="logoElastic" size="xxl" aria-hidden={true} />
8080
</span>
8181
<EuiTitle size="m">
8282
<h1>

src/platform/plugins/private/interactive_setup/public/cluster_configuration_form.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ export const CertificatePanel: FunctionComponent<CertificatePanelProps> = ({
330330
<EuiPanel color={compressed ? 'subdued' : undefined} hasBorder={!compressed}>
331331
<EuiFlexGroup responsive={false} alignItems="center" gutterSize="m">
332332
<EuiFlexItem grow={false}>
333-
<EuiIcon type="document" size="l" />
333+
<EuiIcon type="document" size="l" aria-hidden={true} />
334334
</EuiFlexItem>
335335
<EuiFlexItem>
336336
<EuiFlexGroup responsive={false} gutterSize="none" justifyContent="spaceBetween">
@@ -453,7 +453,7 @@ const CertificateChain: FunctionComponent<CertificateChainProps> = ({ certificat
453453
<EuiSpacer size="s" />
454454
<EuiFlexGroup responsive={false} justifyContent="center">
455455
<EuiFlexItem grow={false}>
456-
<EuiIcon type="sortDown" color="subdued" />
456+
<EuiIcon type="sortDown" color="subdued" aria-hidden={true} />
457457
</EuiFlexItem>
458458
</EuiFlexGroup>
459459
<EuiSpacer size="s" />

src/platform/plugins/shared/dashboard/test/scout/.meta/ui/parallel.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"sha1": "62d916926b7f9a09aa1e5dd32e8562a1509b305a",
2+
"sha1": "7a294509cbff1cd5aea7b058f64e8462738d117c",
33
"tests": [
44
{
55
"id": "98600d12651f127-aa69b48f5334963",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"sha1": "f837afe9443012a45a6eb6ac3d5f4f0117c0aa1f",
3+
"tests": [
4+
{
5+
"id": "a86ab1ab968d807-0bb82867e148f1f",
6+
"title": "Create Data View wizard data stream is accepted as an index pattern source and wizard auto-detects the timestamp field",
7+
"expectedStatus": "passed",
8+
"tags": [
9+
"@local-stateful-classic",
10+
"@cloud-stateful-classic"
11+
],
12+
"location": {
13+
"file": "src/platform/plugins/shared/data_view_editor/test/scout/ui/tests/create_data_view_wizard.spec.ts",
14+
"line": 41,
15+
"column": 7
16+
}
17+
}
18+
]
19+
}

src/platform/plugins/shared/data_view_management/test/scout/.meta/ui/standard.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"sha1": "4d6b16666a495f40bc282f255d398cd3d0726717",
2+
"sha1": "e62501d0bfed5ec7e2269cc6b3f211a9fa39dde2",
33
"tests": [
44
{
55
"id": "be66c17a1888746-11e36bad76c85ff",

src/platform/plugins/shared/discover/moon.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ dependsOn:
150150
- '@kbn/reporting-public'
151151
- '@kbn/logging'
152152
- '@kbn/logging-mocks'
153+
- '@kbn/react-hooks'
153154
tags:
154155
- plugin
155156
- prod

src/platform/plugins/shared/discover/public/__mocks__/test_provider.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
DiscoverCustomizationProvider,
2323
type DiscoverCustomizationService,
2424
} from '../customizations';
25-
import { type ScopedProfilesManager } from '../context_awareness';
25+
import { EMPTY_CONTEXT_AWARENESS_TOOLKIT, type ScopedProfilesManager } from '../context_awareness';
2626
import type { DiscoverServices } from '../build_services';
2727
import { createDiscoverServicesMock } from './services';
2828
import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';
@@ -121,7 +121,10 @@ export const DiscoverTestProvider = ({
121121
const scopedProfilesManager = useMemo(
122122
() =>
123123
originalScopedProfilesManager ??
124-
services.profilesManager.createScopedProfilesManager({ scopedEbtManager }),
124+
services.profilesManager.createScopedProfilesManager({
125+
scopedEbtManager,
126+
toolkit: EMPTY_CONTEXT_AWARENESS_TOOLKIT,
127+
}),
125128
[originalScopedProfilesManager, scopedEbtManager, services.profilesManager]
126129
);
127130

src/platform/plugins/shared/discover/public/application/context/context_app.test.tsx

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import userEvent from '@testing-library/user-event';
1414
import { dataViewMock } from '@kbn/discover-utils/src/__mocks__';
1515
import { setUnifiedDocViewerServices } from '@kbn/unified-doc-viewer-plugin/public/plugin';
1616
import { mockUnifiedDocViewerServices } from '@kbn/unified-doc-viewer-plugin/public/__mocks__';
17-
import { DocViewsRegistry } from '@kbn/unified-doc-viewer';
17+
import { DocViewsRegistry, type DocViewerApi } from '@kbn/unified-doc-viewer';
1818
import { ContextApp, type ContextAppProps } from './context_app';
1919
import { createDiscoverServicesMock } from '../../__mocks__/services';
2020
import { DiscoverTestProvider } from '../../__mocks__/test_provider';
@@ -30,8 +30,6 @@ jest.mock('./hooks/use_context_app_fetch');
3030
jest.mock('./hooks/use_context_app_state');
3131

3232
const services = createDiscoverServicesMock();
33-
const addFiltersMock = jest.spyOn(services.filterManager, 'addFilters');
34-
const updateSavedObjectMock = jest.spyOn(services.dataViews, 'updateSavedObject');
3533
const mockUseContextAppFetch = jest.mocked(useContextAppFetch);
3634
const mockUseContextAppState = jest.mocked(useContextAppState);
3735

@@ -91,15 +89,44 @@ const setDocViewerRegistry = (render: (props: DocViewRenderProps) => React.React
9189
};
9290

9391
describe('ContextApp test', () => {
92+
const addFilterMock = jest.fn();
93+
const setExpandedDocMock = jest.fn();
94+
const docViewerRef = React.createRef<DocViewerApi>();
9495
const defaultProps: ContextAppProps = {
9596
dataView: dataViewMock,
9697
anchorId: 'mocked_anchor_id',
98+
addFilter: addFilterMock,
99+
expandedDoc: undefined,
100+
initialDocViewerTabId: undefined,
101+
docViewerRef,
102+
setExpandedDoc: setExpandedDocMock,
97103
};
98104

99105
const renderComponent = () => {
106+
const StatefulContextApp = () => {
107+
const [expandedDoc, setExpandedDocState] = React.useState(defaultProps.expandedDoc);
108+
const [initialDocViewerTabId, setInitialDocViewerTabId] = React.useState(
109+
defaultProps.initialDocViewerTabId
110+
);
111+
const setExpandedDoc: ContextAppProps['setExpandedDoc'] = (doc, options) => {
112+
setExpandedDocMock(doc, options);
113+
setExpandedDocState(doc);
114+
setInitialDocViewerTabId(options?.initialTabId);
115+
};
116+
117+
return (
118+
<ContextApp
119+
{...defaultProps}
120+
expandedDoc={expandedDoc}
121+
initialDocViewerTabId={initialDocViewerTabId}
122+
setExpandedDoc={setExpandedDoc}
123+
/>
124+
);
125+
};
126+
100127
renderWithKibanaRenderContext(
101128
<DiscoverTestProvider services={services}>
102-
<ContextApp {...defaultProps} />
129+
<StatefulContextApp />
103130
</DiscoverTestProvider>
104131
);
105132
};
@@ -148,7 +175,7 @@ describe('ContextApp test', () => {
148175
);
149176
});
150177

151-
it('should set filters correctly', async () => {
178+
it('should call addFilter from the doc viewer', async () => {
152179
const user = userEvent.setup();
153180

154181
setDocViewerRegistry(({ filter }) => (
@@ -168,15 +195,7 @@ describe('ContextApp test', () => {
168195

169196
await user.click(await screen.findByTestId('docViewFilterButton'));
170197

171-
expect(addFiltersMock).toHaveBeenCalledTimes(1);
172-
expect(addFiltersMock).toHaveBeenCalledWith([
173-
{
174-
$state: { store: 'appState' },
175-
meta: { alias: null, disabled: false, index: 'the-data-view-id', negate: false },
176-
query: { match_phrase: { extension: 'jpg' } },
177-
},
178-
]);
179-
expect(updateSavedObjectMock).toHaveBeenCalledTimes(1);
180-
expect(updateSavedObjectMock).toHaveBeenCalledWith(dataViewMock, 0, true);
198+
expect(addFilterMock).toHaveBeenCalledTimes(1);
199+
expect(addFilterMock).toHaveBeenCalledWith('extension', 'jpg', '+');
181200
});
182201
});

0 commit comments

Comments
 (0)