From 0b215621f70f870f6ca08e038c249dd5f48b7dc6 Mon Sep 17 00:00:00 2001 From: Anan Zhuang Date: Fri, 25 Jun 2021 01:02:11 +0000 Subject: [PATCH] [Test] Enable unit test suite: telemetry_service.test.ts (#499) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All the unit tests related to unused telemetry are temporarily skipped after the fork. Unit tests of the disabled telemetry functions should also be modified correspondingly. To build a clean unit test, we decide to modify and enable all the working unit tests. This PR modifies and enables telemetry_service.test.ts. There is one test case left: calls expected URL with 20 minutes This test case is skipped due to function fetchTelemetry is disabled. We should enable this test when fetchTelemtry function is restored. Partially solved issue: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/499 Signed-off-by: Anan Zhuang --- .../public/services/telemetry_service.test.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/plugins/telemetry/public/services/telemetry_service.test.ts b/src/plugins/telemetry/public/services/telemetry_service.test.ts index c97d3035bc0b..65ab78efe27a 100644 --- a/src/plugins/telemetry/public/services/telemetry_service.test.ts +++ b/src/plugins/telemetry/public/services/telemetry_service.test.ts @@ -57,7 +57,8 @@ jest.mock('moment', () => { }); }); -describe.skip('TelemetryService', () => { +describe('TelemetryService', () => { + // TODO: enable this unit test when fetchTelemtry function is restored describe.skip('fetchTelemetry', () => { it('calls expected URL with 20 minutes - now', async () => { const telemetryService = mockTelemetryService(); @@ -70,7 +71,7 @@ describe.skip('TelemetryService', () => { }); }); - describe.skip('fetchExample', () => { + describe('fetchExample', () => { it('calls fetchTelemetry with unencrupted: true', async () => { const telemetryService = mockTelemetryService(); telemetryService.fetchTelemetry = jest.fn(); @@ -79,7 +80,7 @@ describe.skip('TelemetryService', () => { }); }); - describe.skip('setOptIn', () => { + describe('setOptIn', () => { it('does not call the api if canChangeOptInStatus==false', async () => { const telemetryService = mockTelemetryService({ reportOptInStatusChange: false, @@ -183,7 +184,7 @@ describe.skip('TelemetryService', () => { }); }); - describe.skip('getTelemetryUrl', () => { + describe('getTelemetryUrl', () => { it('should return the config.url parameter', async () => { const url = 'http://test.com'; const telemetryService = mockTelemetryService({ @@ -194,7 +195,7 @@ describe.skip('TelemetryService', () => { }); }); - describe.skip('setUserHasSeenNotice', () => { + describe('setUserHasSeenNotice', () => { it('should hit the API and change the config', async () => { const telemetryService = mockTelemetryService({ config: { telemetryNotifyUserAboutOptInDefault: undefined, userCanChangeSettings: true }, @@ -229,7 +230,7 @@ describe.skip('TelemetryService', () => { }); }); - describe.skip('getUserShouldSeeOptInNotice', () => { + describe('getUserShouldSeeOptInNotice', () => { it('returns whether the user can update the telemetry config (has SavedObjects access)', () => { const telemetryService = mockTelemetryService({ config: { userCanChangeSettings: undefined },