diff --git a/packages/core/i18n/core-i18n-browser-mocks/src/i18n_context_mock.test.tsx b/packages/core/i18n/core-i18n-browser-mocks/src/i18n_context_mock.test.tsx
new file mode 100644
index 0000000000000..840b7c1f5c226
--- /dev/null
+++ b/packages/core/i18n/core-i18n-browser-mocks/src/i18n_context_mock.test.tsx
@@ -0,0 +1,34 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import React from 'react';
+import { FormattedMessage } from '@kbn/i18n-react';
+import { I18nProviderMock } from './i18n_context_mock';
+import { shallow } from 'enzyme';
+
+describe('I18nProviderMock', () => {
+ it('interpolates to default message if present', () => {
+ expect(
+ shallow(
+
+
+
+ ).html()
+ ).toMatchInlineSnapshot(`"default message"`);
+ });
+
+ it('interpolates to id if default message is not present', () => {
+ expect(
+ shallow(
+
+
+
+ ).html()
+ ).toMatchInlineSnapshot(`"id"`);
+ });
+});
diff --git a/packages/core/i18n/core-i18n-browser-mocks/src/i18n_context_mock.tsx b/packages/core/i18n/core-i18n-browser-mocks/src/i18n_context_mock.tsx
new file mode 100644
index 0000000000000..44fa1645eae95
--- /dev/null
+++ b/packages/core/i18n/core-i18n-browser-mocks/src/i18n_context_mock.tsx
@@ -0,0 +1,28 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import React from 'react';
+// eslint-disable-next-line @kbn/eslint/module_migration
+import { IntlProvider } from 'react-intl';
+import { i18n } from '@kbn/i18n';
+
+const emptyMessages = {};
+
+export const I18nProviderMock: React.FC = ({ children }) => {
+ return (
+
+ {children}
+
+ );
+};
diff --git a/packages/core/i18n/core-i18n-browser-mocks/src/i18n_service.mock.ts b/packages/core/i18n/core-i18n-browser-mocks/src/i18n_service.mock.ts
index ed4e4891ff1d7..4716762d1624b 100644
--- a/packages/core/i18n/core-i18n-browser-mocks/src/i18n_service.mock.ts
+++ b/packages/core/i18n/core-i18n-browser-mocks/src/i18n_service.mock.ts
@@ -6,17 +6,15 @@
* Side Public License, v 1.
*/
-import React from 'react';
import type { PublicMethodsOf } from '@kbn/utility-types';
-import { I18nService } from '@kbn/core-i18n-browser-internal';
+import type { I18nService } from '@kbn/core-i18n-browser-internal';
import type { I18nStart } from '@kbn/core-i18n-browser';
-
-const PassThroughComponent = ({ children }: { children: React.ReactNode }) => children;
+import { I18nProviderMock } from './i18n_context_mock';
const createStartContractMock = () => {
const setupContract: jest.Mocked = {
- // By default mock the Context component so it simply renders all children
- Context: jest.fn().mockImplementation(PassThroughComponent),
+ // Stubbed provider returning the default message or id
+ Context: jest.fn().mockImplementation(I18nProviderMock),
};
return setupContract;
};
diff --git a/packages/core/i18n/core-i18n-browser-mocks/tsconfig.json b/packages/core/i18n/core-i18n-browser-mocks/tsconfig.json
index e7888be88e12d..6cf758c606349 100644
--- a/packages/core/i18n/core-i18n-browser-mocks/tsconfig.json
+++ b/packages/core/i18n/core-i18n-browser-mocks/tsconfig.json
@@ -8,12 +8,15 @@
]
},
"include": [
- "**/*.ts"
+ "**/*.ts",
+ "**/*.tsx"
],
"kbn_references": [
"@kbn/utility-types",
"@kbn/core-i18n-browser",
- "@kbn/core-i18n-browser-internal"
+ "@kbn/core-i18n-browser-internal",
+ "@kbn/i18n-react",
+ "@kbn/i18n"
],
"exclude": [
"target/**/*",
diff --git a/packages/core/overlays/core-overlays-browser-internal/src/flyout/__snapshots__/flyout_service.test.tsx.snap b/packages/core/overlays/core-overlays-browser-internal/src/flyout/__snapshots__/flyout_service.test.tsx.snap
index bb50e7397a729..fbf6c6dbf5d0b 100644
--- a/packages/core/overlays/core-overlays-browser-internal/src/flyout/__snapshots__/flyout_service.test.tsx.snap
+++ b/packages/core/overlays/core-overlays-browser-internal/src/flyout/__snapshots__/flyout_service.test.tsx.snap
@@ -114,33 +114,118 @@ Array [
"results": Array [
Object {
"type": "return",
- "value":
-
-
-
-
-
- ,
+
+
+
+
+
+
+
+ ,
},
],
},
@@ -222,33 +307,118 @@ Array [
"results": Array [
Object {
"type": "return",
- "value":
-
-
-
-
-
- ,
+
+
+
+
+
+
+
+ ,
},
],
},
diff --git a/packages/core/overlays/core-overlays-browser-internal/src/modal/__snapshots__/modal_service.test.tsx.snap b/packages/core/overlays/core-overlays-browser-internal/src/modal/__snapshots__/modal_service.test.tsx.snap
index ce53f3fbae63c..e9e13c83b92c5 100644
--- a/packages/core/overlays/core-overlays-browser-internal/src/modal/__snapshots__/modal_service.test.tsx.snap
+++ b/packages/core/overlays/core-overlays-browser-internal/src/modal/__snapshots__/modal_service.test.tsx.snap
@@ -66,33 +66,118 @@ Array [
"results": Array [
Object {
"type": "return",
- "value":
-
-
-
-
-
- ,
+
+
+
+
+
+
+
+ ,
},
],
},
@@ -297,66 +382,236 @@ Array [
"results": Array [
Object {
"type": "return",
- "value":
-
-
-
-
-
- ,
+
+
+
+
+
+
+
+ ,
},
Object {
"type": "return",
- "value":
-
-
-
-
-
- ,
+
+
+
+
+
+
+
+ ,
},
],
},
@@ -586,144 +841,91 @@ Array [
"results": Array [
Object {
"type": "return",
- "value":
-
-
-
-
-
- ,
- },
- Object {
- "type": "return",
- "value":
-
-
-
-
-
- ,
- },
- Object {
- "type": "return",
- "value":
-
-
- Some message
-
-
- ,
- },
- ],
- },
- }
- }
- theme={
- Object {
- "getTheme": [MockFunction],
- "theme$": Observable {
- "_subscribe": [Function],
- },
- }
- }
- >
-
- confirm 1
-
- ,
- ,
- ],
- Array [
-
- ,
- },
- Object {},
- ],
- Array [
- Object {
- "children":
+ ,
+ },
+ Object {
+ "type": "return",
+ "value":
+
- ,
- },
- Object {},
- ],
- Array [
- Object {
- "children":
+ ,
+ },
+ Object {
+ "type": "return",
+ "value":
+
- ,
- },
- Object {},
- ],
- ],
- "results": Array [
- Object {
- "type": "return",
- "value":
-
-
-
-
-
- ,
- },
- Object {
- "type": "return",
- "value":
-
-
-
-
-
- ,
- },
- Object {
- "type": "return",
- "value":
-
-
- Some message
-
-
- ,
+
+ ,
},
],
},
@@ -934,16 +1206,11 @@ Array [
onCancel={[Function]}
onConfirm={[Function]}
>
- some confirm
+ confirm 1
,
,
],
-]
-`;
-
-exports[`ModalService openConfirm() with a currently active modal replaces the current modal with the new confirm 1`] = `
-Array [
Array [
-
-
-
-
-
- ,
+
+
+
+
+
+
+
+ ,
},
Object {
"type": "return",
- "value":
-
-
-
-
-
- ,
+
+
+
+
+
+
+
+ ,
},
Object {
"type": "return",
- "value":
-
-
- Some message
-
-
- ,
+
+
+
+ Some message
+
+
+
+ ,
},
],
},
@@ -1171,17 +1693,22 @@ Array [
}
}
>
-
-
-
+ some confirm
+
,
,
],
+]
+`;
+
+exports[`ModalService openConfirm() with a currently active modal replaces the current modal with the new confirm 1`] = `
+Array [
Array [
- ,
- },
- Object {},
- ],
- Array [
- Object {
- "children": ,
+ },
+ Object {},
+ ],
+ Array [
+ Object {
+ "children":
+
+
+ Some message
+
+
+ ,
+ },
+ Object {},
+ ],
+ ],
+ "results": Array [
+ Object {
+ "type": "return",
+ "value":
+
+
+
+
+
+
+
+ ,
+ },
+ Object {
+ "type": "return",
+ "value":
+
+
+
+
+
+
+
+ ,
+ },
+ Object {
+ "type": "return",
+ "value":
+
+
+
+ Some message
+
+
+
+ ,
+ },
+ ],
+ },
+ }
+ }
+ theme={
+ Object {
+ "getTheme": [MockFunction],
+ "theme$": Observable {
+ "_subscribe": [Function],
+ },
+ }
+ }
+ >
+
+
+
+ ,
+ ,
+ ],
+ Array [
+
+
+
+
+
+
+ ,
+ },
+ Object {},
+ ],
+ Array [
+ Object {
+ "children":
+
+
+
+
+
+ ,
+ },
+ Object {},
+ ],
+ Array [
+ Object {
+ "children":
+
+
+ Some message
+
+
+ ,
+ },
+ Object {},
+ ],
+ ],
+ "results": Array [
+ Object {
+ "type": "return",
+ "value":
+
+
+
+
+
+
+
+ ,
+ },
+ Object {
+ "type": "return",
+ "value":
+
+
+
+
+
+
+
+ ,
+ },
+ Object {
+ "type": "return",
+ "value":
+
- ,
- },
- Object {},
- ],
- ],
- "results": Array [
- Object {
- "type": "return",
- "value":
-
-
-
-
-
- ,
- },
- Object {
- "type": "return",
- "value":
-
-
-
-
-
- ,
- },
- Object {
- "type": "return",
- "value":
-
-
- Some message
-
-
- ,
+
+ ,
},
],
},
@@ -1560,33 +2835,118 @@ Array [
"results": Array [
Object {
"type": "return",
- "value":
-
-
-
-
-
- ,
+
+
+
+
+
+
+
+ ,
},
],
},
@@ -1668,33 +3028,118 @@ Array [
"results": Array [
Object {
"type": "return",
- "value":
-
-
-
-
-
- ,
+
+
+
+
+
+
+
+ ,
},
],
},
@@ -1781,33 +3226,118 @@ Array [
"results": Array [
Object {
"type": "return",
- "value":
-
-
-
-
-
- ,
+
+
+
+
+
+
+
+ ,
},
],
},
@@ -1889,33 +3419,118 @@ Array [
"results": Array [
Object {
"type": "return",
- "value":
-
-
-
-
-
- ,
+
+
+
+
+
+
+
+ ,
},
],
},