From 9bedf46a7970018c0ea9831718390f0379c5697f Mon Sep 17 00:00:00 2001 From: Luke Elmers Date: Mon, 1 Nov 2021 15:36:13 -0600 Subject: [PATCH] Don't show telemetry opt-in/out notice when it has been disabled via yml config. (#116867) --- .../__snapshots__/welcome.test.tsx.snap | 85 +++++++++++++++++++ .../application/components/welcome.test.tsx | 8 ++ .../public/application/components/welcome.tsx | 6 +- 3 files changed, 98 insertions(+), 1 deletion(-) 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 348f618805858..17f7d2520e862 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 @@ -358,3 +358,88 @@ exports[`should render a Welcome screen with the telemetry disclaimer when optIn `; + +exports[`should render a Welcome screen without the opt in/out link when user cannot change optIn status 1`] = ` + +
+
+
+ + + + + +

+ +

+
+ +
+
+
+ + + + + + + + + + + + + +
+
+
+`; diff --git a/src/plugins/home/public/application/components/welcome.test.tsx b/src/plugins/home/public/application/components/welcome.test.tsx index 440af1e0093b5..b042a91e58c9d 100644 --- a/src/plugins/home/public/application/components/welcome.test.tsx +++ b/src/plugins/home/public/application/components/welcome.test.tsx @@ -47,6 +47,14 @@ test('should render a Welcome screen with no telemetry disclaimer', () => { expect(component).toMatchSnapshot(); }); +test('should render a Welcome screen without the opt in/out link when user cannot change optIn status', () => { + const telemetry = telemetryPluginMock.createStartContract(); + telemetry.telemetryService.getCanChangeOptInStatus = jest.fn().mockReturnValue(false); + const component = shallow( {}} telemetry={telemetry} />); + + expect(component).toMatchSnapshot(); +}); + test('fires opt-in seen when mounted', () => { const telemetry = telemetryPluginMock.createStartContract(); const mockSetOptedInNoticeSeen = jest.fn(); diff --git a/src/plugins/home/public/application/components/welcome.tsx b/src/plugins/home/public/application/components/welcome.tsx index ca7e6874c75c2..de8708c855138 100644 --- a/src/plugins/home/public/application/components/welcome.tsx +++ b/src/plugins/home/public/application/components/welcome.tsx @@ -77,7 +77,11 @@ export class Welcome extends React.Component { private renderTelemetryEnabledOrDisabledText = () => { const { telemetry } = this.props; - if (!telemetry || !telemetry.telemetryService.userCanChangeSettings) { + if ( + !telemetry || + !telemetry.telemetryService.userCanChangeSettings || + !telemetry.telemetryService.getCanChangeOptInStatus() + ) { return null; }