Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create common deprecation issues panel component in UA #111231

Merged
merged 9 commits into from
Sep 10, 2021
7 changes: 0 additions & 7 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -26073,17 +26073,10 @@
"xpack.upgradeAssistant.esDeprecations.mlSnapshots.flyout.upgradeSnapshotErrorTitle": "スナップショットのアップグレードエラー",
"xpack.upgradeAssistant.esDeprecations.pageDescription": "廃止予定のクラスターとインデックス設定をレビューします。アップグレード前に重要な問題を解決する必要があります。",
"xpack.upgradeAssistant.esDeprecations.pageTitle": "Elasticsearch",
"xpack.upgradeAssistant.esDeprecationStats.criticalDeprecationsTitle": "重大",
"xpack.upgradeAssistant.esDeprecationStats.statsTitle": "Elasticsearch",
"xpack.upgradeAssistant.esDeprecationStats.warningDeprecationsTitle": "警告",
"xpack.upgradeAssistant.kibanaDeprecations.deprecationLabel": "Kibana",
"xpack.upgradeAssistant.kibanaDeprecations.docLinkText": "ドキュメント",
"xpack.upgradeAssistant.kibanaDeprecations.loadingText": "廃止予定を読み込んでいます...",
"xpack.upgradeAssistant.kibanaDeprecations.pageTitle": "Kibana",
"xpack.upgradeAssistant.kibanaDeprecationStats.criticalDeprecationsTitle": "重大",
"xpack.upgradeAssistant.kibanaDeprecationStats.loadingErrorMessage": "Kibana廃止予定の取得中にエラーが発生しました。",
"xpack.upgradeAssistant.kibanaDeprecationStats.statsTitle": "Kibana",
"xpack.upgradeAssistant.kibanaDeprecationStats.warningDeprecationsTitle": "警告",
"xpack.upgradeAssistant.noDeprecationsPrompt.nextStepsDescription": "他のスタック廃止予定については、{overviewButton}を確認してください。",
"xpack.upgradeAssistant.noDeprecationsPrompt.overviewLinkText": "概要ページ",
"xpack.upgradeAssistant.overview.analyzeTitle": "廃止予定ログを分析",
Expand Down
7 changes: 0 additions & 7 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -26508,17 +26508,10 @@
"xpack.upgradeAssistant.esDeprecations.mlSnapshots.flyout.upgradeSnapshotErrorTitle": "升级快照时出错",
"xpack.upgradeAssistant.esDeprecations.pageDescription": "查看已弃用的群集和索引设置。在升级之前必须解决任何紧急问题。",
"xpack.upgradeAssistant.esDeprecations.pageTitle": "Elasticsearch",
"xpack.upgradeAssistant.esDeprecationStats.criticalDeprecationsTitle": "紧急",
"xpack.upgradeAssistant.esDeprecationStats.statsTitle": "Elasticsearch",
"xpack.upgradeAssistant.esDeprecationStats.warningDeprecationsTitle": "警告",
"xpack.upgradeAssistant.kibanaDeprecations.deprecationLabel": "Kibana",
"xpack.upgradeAssistant.kibanaDeprecations.docLinkText": "文档",
"xpack.upgradeAssistant.kibanaDeprecations.loadingText": "正在加载弃用……",
"xpack.upgradeAssistant.kibanaDeprecations.pageTitle": "Kibana",
"xpack.upgradeAssistant.kibanaDeprecationStats.criticalDeprecationsTitle": "紧急",
"xpack.upgradeAssistant.kibanaDeprecationStats.loadingErrorMessage": "检索 Kibana 弃用时发生错误。",
"xpack.upgradeAssistant.kibanaDeprecationStats.statsTitle": "Kibana",
"xpack.upgradeAssistant.kibanaDeprecationStats.warningDeprecationsTitle": "警告",
"xpack.upgradeAssistant.noDeprecationsPrompt.nextStepsDescription": "查看{overviewButton}以了解其他 Stack 弃用。",
"xpack.upgradeAssistant.noDeprecationsPrompt.overviewLinkText": "“概览”页面",
"xpack.upgradeAssistant.overview.analyzeTitle": "分析弃用日志",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import type { DeprecationsServiceStart, DomainDeprecationDetails } from 'kibana/public';

const kibanaDeprecations: DomainDeprecationDetails[] = [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { act } from 'react-dom/test-utils';
import { deprecationsServiceMock } from 'src/core/public/mocks';

import { setupEnvironment, kibanaDeprecationsServiceHelpers } from '../../helpers';
import { OverviewTestBed, setupOverviewPage } from '../overview.helpers';
import {
esCriticalAndWarningDeprecations,
esCriticalOnlyDeprecations,
esNoDeprecations,
} from './mock_es_issues';

describe('Overview - Fix deprecation issues step - Elasticsearch deprecations', () => {
let testBed: OverviewTestBed;
const { server, httpRequestsMockHelpers } = setupEnvironment();

afterAll(() => {
server.restore();
});

describe('When load succeeds', () => {
const setup = async () => {
// Set up with no Kibana deprecations.
await act(async () => {
const deprecationService = deprecationsServiceMock.createStartContract();
kibanaDeprecationsServiceHelpers.setLoadDeprecations({ deprecationService, response: [] });

testBed = await setupOverviewPage({
services: {
core: {
deprecations: deprecationService,
},
},
});
});

const { component } = testBed;
component.update();
};

describe('when there are critical and warning issues', () => {
beforeEach(async () => {
httpRequestsMockHelpers.setLoadEsDeprecationsResponse(esCriticalAndWarningDeprecations);
await setup();
});

test('renders counts for both', () => {
const { exists, find } = testBed;
expect(exists('esStatsPanel')).toBe(true);
expect(find('esStatsPanel.warningDeprecations').text()).toContain('1');
expect(find('esStatsPanel.criticalDeprecations').text()).toContain('1');
});

test('panel links to ES deprecations page', () => {
const { component, find } = testBed;
component.update();
expect(find('esStatsPanel').find('a').props().href).toBe('/es_deprecations');
});
});

describe('when there are critical but no warning issues', () => {
beforeEach(async () => {
httpRequestsMockHelpers.setLoadEsDeprecationsResponse(esCriticalOnlyDeprecations);
await setup();
});

test('renders a count for critical issues and success state for warning issues', () => {
const { exists, find } = testBed;
expect(exists('esStatsPanel')).toBe(true);
expect(find('esStatsPanel.criticalDeprecations').text()).toContain('1');
expect(exists('esStatsPanel.noWarningDeprecationIssues')).toBe(true);
});

test('panel links to ES deprecations page', () => {
const { component, find } = testBed;
component.update();
expect(find('esStatsPanel').find('a').props().href).toBe('/es_deprecations');
});
});

describe('when there no critical or warning issues', () => {
beforeEach(async () => {
httpRequestsMockHelpers.setLoadEsDeprecationsResponse(esNoDeprecations);
await setup();
});

test('renders a count for critical issues and success state for warning issues', () => {
const { exists } = testBed;
expect(exists('esStatsPanel')).toBe(true);
expect(exists('esStatsPanel.noDeprecationIssues')).toBe(true);
});

test(`panel doesn't link to ES deprecations page`, () => {
const { component, find } = testBed;
component.update();
expect(find('esStatsPanel').find('a').length).toBe(0);
});
});
});

describe(`When there's a load error`, () => {
test('handles network failure', async () => {
const error = {
statusCode: 500,
error: 'Internal server error',
message: 'Internal server error',
};

httpRequestsMockHelpers.setLoadEsDeprecationsResponse(undefined, error);

await act(async () => {
testBed = await setupOverviewPage();
});

const { component, exists } = testBed;
component.update();
expect(exists('esRequestErrorIconTip')).toBe(true);
});

test('handles unauthorized error', async () => {
const error = {
statusCode: 403,
error: 'Forbidden',
message: 'Forbidden',
};

httpRequestsMockHelpers.setLoadEsDeprecationsResponse(undefined, error);

await act(async () => {
testBed = await setupOverviewPage();
});

const { component, exists } = testBed;
component.update();
expect(exists('unauthorizedErrorIconTip')).toBe(true);
});

test('handles partially upgraded error', async () => {
const error = {
statusCode: 426,
error: 'Upgrade required',
message: 'There are some nodes running a different version of Elasticsearch',
attributes: {
allNodesUpgraded: false,
},
};

httpRequestsMockHelpers.setLoadEsDeprecationsResponse(undefined, error);

await act(async () => {
testBed = await setupOverviewPage({ isReadOnlyMode: false });
});

const { component, exists } = testBed;
component.update();
expect(exists('partiallyUpgradedErrorIconTip')).toBe(true);
});

test('handles upgrade error', async () => {
const error = {
statusCode: 426,
error: 'Upgrade required',
message: 'There are some nodes running a different version of Elasticsearch',
attributes: {
allNodesUpgraded: true,
},
};

httpRequestsMockHelpers.setLoadEsDeprecationsResponse(undefined, error);

await act(async () => {
testBed = await setupOverviewPage({ isReadOnlyMode: false });
});

const { component, exists } = testBed;
component.update();
expect(exists('upgradedErrorIconTip')).toBe(true);
});
});
});
Loading