From a42c75a880b4f79a53d47b342b905dc1128b6093 Mon Sep 17 00:00:00 2001 From: Alison Goryachev Date: Mon, 13 Sep 2021 08:43:03 -0400 Subject: [PATCH] [Upgrade Assistant] Fix Kibana deprecations warning message --- .../error_handling.test.ts | 24 ++++++++++++++++--- .../kibana_deprecations.tsx | 9 +++++-- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/kibana_deprecations/error_handling.test.ts b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/kibana_deprecations/error_handling.test.ts index dbe49dfb714b9..83e0a884a3119 100644 --- a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/kibana_deprecations/error_handling.test.ts +++ b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/kibana_deprecations/error_handling.test.ts @@ -20,14 +20,32 @@ describe('Error handling', () => { server.restore(); }); - test('handles plugin error', async () => { + test('handles plugin errors', async () => { await act(async () => { kibanaDeprecationsServiceHelpers.setLoadDeprecations({ deprecationService, response: [ ...kibanaDeprecationsServiceHelpers.defaultMockedResponses.mockedKibanaDeprecations, { - domainId: 'failed_plugin_id', + domainId: 'failed_plugin_id_1', + title: 'Failed to fetch deprecations for "failed_plugin_id"', + message: `Failed to get deprecations info for plugin "failed_plugin_id".`, + level: 'fetch_error', + correctiveActions: { + manualSteps: ['Check Kibana server logs for error message.'], + }, + }, + { + domainId: 'failed_plugin_id_1', + title: 'Failed to fetch deprecations for "failed_plugin_id"', + message: `Failed to get deprecations info for plugin "failed_plugin_id".`, + level: 'fetch_error', + correctiveActions: { + manualSteps: ['Check Kibana server logs for error message.'], + }, + }, + { + domainId: 'failed_plugin_id_2', title: 'Failed to fetch deprecations for "failed_plugin_id"', message: `Failed to get deprecations info for plugin "failed_plugin_id".`, level: 'fetch_error', @@ -53,7 +71,7 @@ describe('Error handling', () => { expect(exists('kibanaDeprecationErrors')).toBe(true); expect(find('kibanaDeprecationErrors').text()).toContain( - 'List of deprecation issues might be incomplete' + 'Failed to get deprecation issues for these plugins: failed_plugin_id_1, failed_plugin_id_2.' ); }); diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/kibana_deprecations.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/kibana_deprecations.tsx index eec233b7fda6a..aac563aa8d0bb 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/kibana_deprecations.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/kibana_deprecations.tsx @@ -144,9 +144,14 @@ export const KibanaDeprecations = withRouter(({ history }: RouteComponentProps) const deprecationErrors: string[] = []; allDeprecations.forEach((deprecation) => { - // Keep track of any deprecations that failed to fetch to show warning in UI + // Keep track of any plugin deprecations that failed to fetch to show warning in UI if (deprecation.level === 'fetch_error') { - deprecationErrors.push(deprecation.domainId); + // It's possible that a plugin registered more than one deprecation that could fail + // We only want to keep track of the unique plugin failures + const pluginErrorExists = deprecationErrors.includes(deprecation.domainId); + if (pluginErrorExists === false) { + deprecationErrors.push(deprecation.domainId); + } return; }