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

[Upgrade Assistant] Fix cits, a11y and functional tests #118778

1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -25561,7 +25561,6 @@
"xpack.upgradeAssistant.overview.deprecationLogs.reloadButtonLabel": "再試行",
"xpack.upgradeAssistant.overview.deprecationLogs.updateErrorMessage": "ログ状態を更新できませんでした。",
"xpack.upgradeAssistant.overview.documentationLinkText": "ドキュメント",
"xpack.upgradeAssistant.overview.identifyStepTitle": "廃止予定APIの使用を特定し、アプリケーションを更新",
"xpack.upgradeAssistant.overview.loadingLogsLabel": "ログ収集状態を読み込み中...",
"xpack.upgradeAssistant.overview.observe.discoveryDescription": "廃止予定ログを検索およびフィルターし、必要な変更のタイプを把握します。",
"xpack.upgradeAssistant.overview.observe.observabilityDescription": "使用中のAPIのうち廃止予定のAPIと、更新が必要なアプリケーションを特定できます。",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -25994,7 +25994,6 @@
"xpack.upgradeAssistant.overview.deprecationLogs.reloadButtonLabel": "重试",
"xpack.upgradeAssistant.overview.deprecationLogs.updateErrorMessage": "无法更新日志记录状态。",
"xpack.upgradeAssistant.overview.documentationLinkText": "文档",
"xpack.upgradeAssistant.overview.identifyStepTitle": "识别已弃用 API 的使用并更新您的应用程序",
"xpack.upgradeAssistant.overview.loadingLogsLabel": "正在加载日志收集状态……",
"xpack.upgradeAssistant.overview.observe.discoveryDescription": "搜索并筛选弃用日志以了解需要进行的更改类型。",
"xpack.upgradeAssistant.overview.observe.observabilityDescription": "深入了解正在使用哪些已弃用 API 以及需要更新哪些应用程序。",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('Cluster upgrade', () => {

describe('when cluster is in the process of a rolling upgrade', () => {
beforeEach(async () => {
httpRequestsMockHelpers.setLoadDeprecationLoggingResponse(undefined, {
httpRequestsMockHelpers.setLoadEsDeprecationsResponse(undefined, {
sabarasaba marked this conversation as resolved.
Show resolved Hide resolved
statusCode: 426,
message: '',
attributes: {
Expand All @@ -62,7 +62,7 @@ describe('Cluster upgrade', () => {

describe('when cluster has been upgraded', () => {
beforeEach(async () => {
httpRequestsMockHelpers.setLoadDeprecationLoggingResponse(undefined, {
httpRequestsMockHelpers.setLoadEsDeprecationsResponse(undefined, {
statusCode: 426,
message: '',
attributes: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* 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 { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test/jest';
import { EsDeprecationLogs } from '../../../public/application/components/es_deprecation_logs';
import { WithAppDependencies } from '../helpers';

const testBedConfig: AsyncTestBedConfig = {
memoryRouter: {
initialEntries: ['/es_deprecation_logs'],
componentRoutePath: '/es_deprecation_logs',
},
doMountAsync: true,
};

export type EsDeprecationLogsTestBed = TestBed & {
actions: ReturnType<typeof createActions>;
};

const createActions = (testBed: TestBed) => {
/**
* User Actions
*/

const clickDeprecationToggle = async () => {
const { find, component } = testBed;

await act(async () => {
find('deprecationLoggingToggle').simulate('click');
});

component.update();
};

const clickRetryButton = async () => {
const { find, component } = testBed;

await act(async () => {
find('retryButton').simulate('click');
});

component.update();
};

const clickResetButton = async () => {
const { find, component } = testBed;

await act(async () => {
find('resetLastStoredDate').simulate('click');
});

component.update();
};

return {
clickDeprecationToggle,
clickRetryButton,
clickResetButton,
};
};

export const setupESDeprecationLogsPage = async (
overrides?: Record<string, unknown>
): Promise<EsDeprecationLogsTestBed> => {
const initTestBed = registerTestBed(
WithAppDependencies(EsDeprecationLogs, overrides),
testBedConfig
);
const testBed = await initTestBed();

return {
...testBed,
actions: createActions(testBed),
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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 { setupEnvironment } from '../helpers';
import {
EsDeprecationLogsTestBed,
setupESDeprecationLogsPage,
} from './es_deprecation_logs.helpers';

describe('ES deprecation logs', () => {
let testBed: EsDeprecationLogsTestBed;
const { server } = setupEnvironment();

beforeEach(async () => {
testBed = await setupESDeprecationLogsPage();
testBed.component.update();
});

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

describe('Documentation link', () => {
test('Has a link for migration info api docs in page header', () => {
const { exists } = testBed;

expect(exists('documentationLink')).toBe(true);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ jest.mock('../../../../public/application/lib/logs_checkpoint', () => {
});

import { DeprecationLoggingStatus } from '../../../../common/types';
import { OverviewTestBed, setupOverviewPage } from '../overview.helpers';
import {
EsDeprecationLogsTestBed,
setupESDeprecationLogsPage,
} from '../es_deprecation_logs.helpers';
import { setupEnvironment, advanceTime } from '../../helpers';
import {
DEPRECATION_LOGS_INDEX,
Expand All @@ -35,13 +38,13 @@ const getLoggingResponse = (toggle: boolean): DeprecationLoggingStatus => ({
isDeprecationLoggingEnabled: toggle,
});

describe('Overview - Fix deprecation logs step', () => {
let testBed: OverviewTestBed;
describe('ES deprecation logs', () => {
sabarasaba marked this conversation as resolved.
Show resolved Hide resolved
let testBed: EsDeprecationLogsTestBed;
const { server, httpRequestsMockHelpers } = setupEnvironment();

beforeEach(async () => {
httpRequestsMockHelpers.setLoadDeprecationLoggingResponse(getLoggingResponse(true));
testBed = await setupOverviewPage();
testBed = await setupESDeprecationLogsPage();

const { component } = testBed;
component.update();
Expand All @@ -51,56 +54,6 @@ describe('Overview - Fix deprecation logs step', () => {
server.restore();
});

describe('Step status', () => {
test(`It's complete when there are no deprecation logs since last checkpoint`, async () => {
httpRequestsMockHelpers.setLoadDeprecationLogsCountResponse({ count: 0 });

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

const { exists, component } = testBed;

component.update();

expect(exists(`fixLogsStep-complete`)).toBe(true);
});

test(`It's incomplete when there are deprecation logs since last checkpoint`, async () => {
httpRequestsMockHelpers.setLoadDeprecationLogsCountResponse({ count: 5 });

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

const { exists, component } = testBed;

component.update();

expect(exists(`fixLogsStep-incomplete`)).toBe(true);
});

test(`It's incomplete when log collection is disabled `, async () => {
httpRequestsMockHelpers.setLoadDeprecationLogsCountResponse({ count: 0 });

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

const { actions, exists, component } = testBed;

component.update();

expect(exists(`fixLogsStep-complete`)).toBe(true);

httpRequestsMockHelpers.setUpdateDeprecationLoggingResponse(getLoggingResponse(false));

await actions.clickDeprecationToggle();

expect(exists(`fixLogsStep-incomplete`)).toBe(true);
});
});

describe('Step 1 - Toggle log writing and collecting', () => {
test('toggles deprecation logging', async () => {
const { find, actions } = testBed;
Expand All @@ -123,7 +76,7 @@ describe('Overview - Fix deprecation logs step', () => {
});

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

const { exists, component } = testBed;
Expand Down Expand Up @@ -159,7 +112,7 @@ describe('Overview - Fix deprecation logs step', () => {
httpRequestsMockHelpers.setLoadDeprecationLoggingResponse(undefined, error);

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

const { component, exists } = testBed;
Expand All @@ -176,7 +129,7 @@ describe('Overview - Fix deprecation logs step', () => {
});

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

const { exists, component } = testBed;
Expand All @@ -196,7 +149,7 @@ describe('Overview - Fix deprecation logs step', () => {

test('Has a link to see logs in observability app', async () => {
await act(async () => {
testBed = await setupOverviewPage({
testBed = await setupESDeprecationLogsPage({
http: {
basePath: {
prepend: (url: string) => url,
Expand Down Expand Up @@ -228,7 +181,7 @@ describe('Overview - Fix deprecation logs step', () => {

test('Has a link to see logs in discover app', async () => {
await act(async () => {
testBed = await setupOverviewPage();
testBed = await setupESDeprecationLogsPage();
});

const { exists, component, find } = testBed;
Expand Down Expand Up @@ -257,7 +210,7 @@ describe('Overview - Fix deprecation logs step', () => {
});

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

const { find, exists, component } = testBed;
Expand All @@ -274,7 +227,7 @@ describe('Overview - Fix deprecation logs step', () => {
});

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

const { find, exists, component } = testBed;
Expand All @@ -295,7 +248,7 @@ describe('Overview - Fix deprecation logs step', () => {
httpRequestsMockHelpers.setLoadDeprecationLogsCountResponse(undefined, error);

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

const { exists, actions, component } = testBed;
Expand All @@ -319,7 +272,7 @@ describe('Overview - Fix deprecation logs step', () => {
});

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

const { exists, actions, component } = testBed;
Expand Down Expand Up @@ -351,7 +304,7 @@ describe('Overview - Fix deprecation logs step', () => {

const addDanger = jest.fn();
await act(async () => {
testBed = await setupOverviewPage({
testBed = await setupESDeprecationLogsPage({
services: {
core: {
notifications: {
Expand Down Expand Up @@ -389,17 +342,17 @@ describe('Overview - Fix deprecation logs step', () => {
count: 0,
});

testBed = await setupOverviewPage();
testBed = await setupESDeprecationLogsPage();
});

afterEach(() => {
jest.useRealTimers();
});

test('renders step as incomplete when a success state is followed by an error state', async () => {
test('success state is followed by an error state', async () => {
const { exists } = testBed;

expect(exists('fixLogsStep-complete')).toBe(true);
expect(exists('resetLastStoredDate')).toBe(true);

// second request will error
const error = {
Expand All @@ -413,7 +366,7 @@ describe('Overview - Fix deprecation logs step', () => {
await advanceTime(DEPRECATION_LOGS_COUNT_POLL_INTERVAL_MS);
testBed.component.update();

expect(exists('fixLogsStep-incomplete')).toBe(true);
expect(exists('errorCallout')).toBe(true);
});
});
});
Expand All @@ -425,7 +378,7 @@ describe('Overview - Fix deprecation logs step', () => {

test('It shows copy with compatibility api header advice', async () => {
await act(async () => {
testBed = await setupOverviewPage();
testBed = await setupESDeprecationLogsPage();
});

const { exists, component } = testBed;
Expand All @@ -449,7 +402,7 @@ describe('Overview - Fix deprecation logs step', () => {

test(`doesn't show analyze and resolve logs if it doesn't have the right privileges`, async () => {
await act(async () => {
testBed = await setupOverviewPage({
testBed = await setupESDeprecationLogsPage({
privileges: {
hasAllPrivileges: false,
missingPrivileges: {
Expand Down
Loading