-
- You can use scripted fields in visualizations and display them in your documents. However, you cannot search scripted fields.
-
+ You can use scripted fields in visualizations and display them in your documents. However, you cannot search scripted fields.
@@ -38,9 +34,7 @@ exports[`Header should render normally 1`] = `
-
- Add scripted field
-
+ Add scripted field
diff --git a/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/header.test.tsx b/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/header.test.tsx
index 218225d3e364..6cd734d25993 100644
--- a/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/header.test.tsx
+++ b/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/components/header/header.test.tsx
@@ -31,16 +31,15 @@
*/
import React from 'react';
-import { render } from 'enzyme';
+import { renderWithIntl } from 'test_utils/enzyme_helpers';
import { RouteComponentProps } from 'react-router-dom';
import { ScopedHistory } from 'opensearch-dashboards/public';
import { scopedHistoryMock } from '../../../../../../../../core/public/mocks';
-
import { Header } from './header';
describe('Header', () => {
test('should render normally', () => {
- const component = render(
+ const component = renderWithIntl(
-
- }
+
-
+ }
>
+
-
- script fields
-
-
-
-
+
+
+ ,
+ "scriptsInAggregation":
-
+
+
-
-
-
- and with
-
- ,
+ }
+ }
+ >
+
+ Please familiarize yourself with
+
-
-
- scripts in aggregations
-
-
-
-
+
+ script fields
+
+
+
+
+
+
+
+
+ and with
+
+
-
-
-
-
- before using scripted fields.
-
-
-
-
-
-
- Scripted fields can be used to display and aggregate calculated values. As such, they can be very slow, and if done incorrectly, can cause OpenSearch Dashboards to be unusable. There's no safety net here. If you make a typo, unexpected exceptions will be thrown all over the place!
-
-
-
-
-
-
-
-
-
-
-
+
+
+ scripts in aggregations
+
+
+
+
+
+
+
+
+ before using scripted fields.
+
+
+
+
+
+
+ Scripted fields can be used to display and aggregate calculated values. As such, they can be very slow, and if done incorrectly, can cause OpenSearch Dashboards to be unusable. There's no safety net here. If you make a typo, unexpected exceptions will be thrown all over the place!
+
+
+
+
+
+
+
+
+
+
+
+
`;
exports[`ScriptingWarningCallOut should render nothing if not visible 1`] = `
-
+
+
+
`;
diff --git a/src/plugins/index_pattern_management/public/components/field_editor/components/scripting_call_outs/warning_call_out.test.tsx b/src/plugins/index_pattern_management/public/components/field_editor/components/scripting_call_outs/warning_call_out.test.tsx
index 68739f8f2154..326da8cd45d1 100644
--- a/src/plugins/index_pattern_management/public/components/field_editor/components/scripting_call_outs/warning_call_out.test.tsx
+++ b/src/plugins/index_pattern_management/public/components/field_editor/components/scripting_call_outs/warning_call_out.test.tsx
@@ -32,6 +32,7 @@
import React from 'react';
import { mount } from 'enzyme';
+import { wrapWithIntl } from 'test_utils/enzyme_helpers';
import { OpenSearchDashboardsContextProvider } from 'src/plugins/opensearch_dashboards_react/public';
import { mockManagementPlugin } from '../../../../mocks';
import { ScriptingWarningCallOut } from './warning_call_out';
@@ -40,7 +41,7 @@ describe('ScriptingWarningCallOut', () => {
const mockedContext = mockManagementPlugin.createIndexPatternManagmentContext();
it('should render normally', async () => {
- const component = mount(, {
+ const component = mount(wrapWithIntl(), {
wrappingComponent: OpenSearchDashboardsContextProvider,
wrappingComponentProps: {
services: mockedContext,
@@ -51,7 +52,7 @@ describe('ScriptingWarningCallOut', () => {
});
it('should render nothing if not visible', async () => {
- const component = mount(, {
+ const component = mount(wrapWithIntl(), {
wrappingComponent: OpenSearchDashboardsContextProvider,
wrappingComponentProps: {
services: mockedContext,
diff --git a/src/plugins/telemetry_management_section/public/components/telemetry_management_section.test.tsx b/src/plugins/telemetry_management_section/public/components/telemetry_management_section.test.tsx
index c741d5626458..bd12028737b9 100644
--- a/src/plugins/telemetry_management_section/public/components/telemetry_management_section.test.tsx
+++ b/src/plugins/telemetry_management_section/public/components/telemetry_management_section.test.tsx
@@ -30,7 +30,7 @@
* GitHub history for details.
*/
import React from 'react';
-import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers';
+import { mountWithIntl, shallowWithIntl, wrapWithIntl } from 'test_utils/enzyme_helpers';
import TelemetryManagementSection from './telemetry_management_section';
import { TelemetryService } from '../../../telemetry/public/services';
import { coreMock } from '../../../../core/public/mocks';
@@ -91,31 +91,35 @@ describe('TelemetryManagementSectionComponent', () => {
});
const component = render(
- Fallback}>
-
-
- );
-
- try {
- component.rerender(
+ wrapWithIntl(
Fallback}>
+ )
+ );
+
+ try {
+ component.rerender(
+ wrapWithIntl(
+ Fallback}>
+
+
+ )
);
expect(onQueryMatchChange).toHaveBeenCalledWith(false);
expect(onQueryMatchChange).toHaveBeenCalledTimes(1);
diff --git a/src/plugins/vis_default_editor/public/components/controls/percentiles.test.tsx b/src/plugins/vis_default_editor/public/components/controls/percentiles.test.tsx
index 7475421f33d5..dfc50fd4a10b 100644
--- a/src/plugins/vis_default_editor/public/components/controls/percentiles.test.tsx
+++ b/src/plugins/vis_default_editor/public/components/controls/percentiles.test.tsx
@@ -34,6 +34,7 @@ import React from 'react';
import { AggParamEditorProps } from '../agg_param_props';
import { IAggConfig } from 'src/plugins/data/public';
import { mount } from 'enzyme';
+import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { PercentilesEditor } from './percentiles';
import { EditorVisState } from '../sidebar/state/reducers';
@@ -66,13 +67,13 @@ describe('PercentilesEditor component', () => {
it('should set valid state to true after adding a unique percentile', () => {
defaultProps.value = [1, 5, 25, 50, 70];
- mount();
+ mountWithIntl();
expect(setValidity).lastCalledWith(true);
});
it('should set valid state to false after adding a duplicate percentile', () => {
defaultProps.value = [1, 5, 25, 50, 50];
- mount();
+ mountWithIntl();
expect(setValidity).lastCalledWith(false);
});
});
diff --git a/src/test_utils/public/enzyme_helpers.tsx b/src/test_utils/public/enzyme_helpers.tsx
index b981a18785a4..0441b0d7a818 100644
--- a/src/test_utils/public/enzyme_helpers.tsx
+++ b/src/test_utils/public/enzyme_helpers.tsx
@@ -40,6 +40,7 @@
import { I18nProvider, InjectedIntl, intlShape, __IntlProvider } from '@osd/i18n/react';
import { mount, ReactWrapper, render, shallow } from 'enzyme';
import React, { ReactElement, ValidationMap } from 'react';
+import { IntlProvider } from 'react-intl';
// Use fake component to extract `intl` property to use in tests.
const { intl } = (mount(
@@ -67,10 +68,22 @@ function getOptions(context = {}, childContextTypes: ValidationMap = {}, pr
/**
* When using @osd/i18n `injectI18n` on components, props.intl is required.
*/
-function nodeWithIntlProp(node: ReactElement): ReactElement {
+export function nodeWithIntlProp(
+ node: ReactElement
+): ReactElement {
return React.cloneElement(node, { intl });
}
+/**
+ * Creates the wrapped IntlProvider instance
+ *
+ * @param node The React element or cheerio wrapper
+ * @return The wrapped IntlProvider instance
+ */
+export function wrapWithIntl(node: ReactElement) {
+ return {node};
+}
+
/**
* Creates the wrapper instance using shallow with provided intl object into context
*