diff --git a/src/plugins/home/public/application/components/__snapshots__/welcome.test.tsx.snap b/src/plugins/home/public/application/components/__snapshots__/welcome.test.tsx.snap index abe529b79889a..4e66fd9e14c81 100644 --- a/src/plugins/home/public/application/components/__snapshots__/welcome.test.tsx.snap +++ b/src/plugins/home/public/application/components/__snapshots__/welcome.test.tsx.snap @@ -125,7 +125,6 @@ exports[`should render a Welcome screen with the telemetry disclaimer 1`] = ` values={Object {}} /> @@ -224,7 +223,6 @@ exports[`should render a Welcome screen with the telemetry disclaimer when optIn values={Object {}} /> @@ -323,7 +321,6 @@ exports[`should render a Welcome screen with the telemetry disclaimer when optIn values={Object {}} /> diff --git a/src/plugins/home/public/application/components/welcome.test.tsx b/src/plugins/home/public/application/components/welcome.test.tsx index 1332e03ffdc81..701fab3af7539 100644 --- a/src/plugins/home/public/application/components/welcome.test.tsx +++ b/src/plugins/home/public/application/components/welcome.test.tsx @@ -30,56 +30,39 @@ jest.mock('../kibana_services', () => ({ })); test('should render a Welcome screen with the telemetry disclaimer', () => { - const telemetry = telemetryPluginMock.createSetupContract(); - const component = shallow( - // @ts-ignore - {}} telemetry={telemetry} /> - ); + const telemetry = telemetryPluginMock.createStartContract(); + const component = shallow( {}} telemetry={telemetry} />); expect(component).toMatchSnapshot(); }); test('should render a Welcome screen with the telemetry disclaimer when optIn is true', () => { - const telemetry = telemetryPluginMock.createSetupContract(); + const telemetry = telemetryPluginMock.createStartContract(); telemetry.telemetryService.getIsOptedIn = jest.fn().mockReturnValue(true); - const component = shallow( - // @ts-ignore - {}} telemetry={telemetry} /> - ); + const component = shallow( {}} telemetry={telemetry} />); expect(component).toMatchSnapshot(); }); test('should render a Welcome screen with the telemetry disclaimer when optIn is false', () => { - const telemetry = telemetryPluginMock.createSetupContract(); + const telemetry = telemetryPluginMock.createStartContract(); telemetry.telemetryService.getIsOptedIn = jest.fn().mockReturnValue(false); - const component = shallow( - // @ts-ignore - {}} telemetry={telemetry} /> - ); + const component = shallow( {}} telemetry={telemetry} />); expect(component).toMatchSnapshot(); }); test('should render a Welcome screen with no telemetry disclaimer', () => { - // @ts-ignore - const component = shallow( - // @ts-ignore - {}} telemetry={null} /> - ); + const component = shallow( {}} />); expect(component).toMatchSnapshot(); }); test('fires opt-in seen when mounted', () => { - const telemetry = telemetryPluginMock.createSetupContract(); + const telemetry = telemetryPluginMock.createStartContract(); const mockSetOptedInNoticeSeen = jest.fn(); - // @ts-ignore telemetry.telemetryNotifications.setOptedInNoticeSeen = mockSetOptedInNoticeSeen; - shallow( - // @ts-ignore - {}} telemetry={telemetry} /> - ); + shallow( {}} telemetry={telemetry} />); expect(mockSetOptedInNoticeSeen).toHaveBeenCalled(); }); diff --git a/src/plugins/home/public/application/components/welcome.tsx b/src/plugins/home/public/application/components/welcome.tsx index c3773f19a9a0c..cacb507009c70 100644 --- a/src/plugins/home/public/application/components/welcome.tsx +++ b/src/plugins/home/public/application/components/welcome.tsx @@ -38,7 +38,6 @@ import { METRIC_TYPE } from '@kbn/analytics'; import { FormattedMessage } from '@kbn/i18n/react'; import { getServices } from '../kibana_services'; import { TelemetryPluginStart } from '../../../../telemetry/public'; -import { PRIVACY_STATEMENT_URL } from '../../../../telemetry/common/constants'; import { SampleDataCard } from './sample_data'; interface Props { @@ -162,7 +161,11 @@ export class Welcome extends React.Component { id="home.dataManagementDisclaimerPrivacy" defaultMessage="To learn about how usage data helps us manage and improve our products and services, see our " /> - + ; +export type Setup = jest.Mocked; +export type Start = jest.Mocked; export const telemetryPluginMock = { createSetupContract, + createStartContract, }; function createSetupContract(): Setup { const telemetryService = mockTelemetryService(); - const telemetryNotifications = mockTelemetryNotifications({ telemetryService }); const setupContract: Setup = { telemetryService, - telemetryNotifications, }; return setupContract; } + +function createStartContract(): Start { + const telemetryService = mockTelemetryService(); + const telemetryNotifications = mockTelemetryNotifications({ telemetryService }); + + const startContract: Start = { + telemetryService, + telemetryNotifications, + telemetryConstants: { + getPrivacyStatementUrl: jest.fn(), + }, + }; + + return startContract; +} diff --git a/src/plugins/telemetry/public/plugin.ts b/src/plugins/telemetry/public/plugin.ts index a363953978d79..3846e7cb96a19 100644 --- a/src/plugins/telemetry/public/plugin.ts +++ b/src/plugins/telemetry/public/plugin.ts @@ -38,6 +38,7 @@ import { getTelemetrySendUsageFrom, } from '../common/telemetry_config'; import { getNotifyUserAboutOptInDefault } from '../common/telemetry_config/get_telemetry_notify_user_about_optin_default'; +import { PRIVACY_STATEMENT_URL } from '../common/constants'; export interface TelemetryPluginSetup { telemetryService: TelemetryService; @@ -46,6 +47,9 @@ export interface TelemetryPluginSetup { export interface TelemetryPluginStart { telemetryService: TelemetryService; telemetryNotifications: TelemetryNotifications; + telemetryConstants: { + getPrivacyStatementUrl: () => string; + }; } export interface TelemetryPluginConfig { @@ -115,6 +119,9 @@ export class TelemetryPlugin implements Plugin PRIVACY_STATEMENT_URL, + }, }; }