Skip to content

Commit

Permalink
Refactor kibana deprecation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sabarasaba committed Oct 13, 2021
1 parent 6c34e15 commit 08474df
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@

export { setupEnvironment, WithAppDependencies } from './setup_environment';
export { advanceTime } from './time_manipulation';
export { kibanaDeprecationsServiceHelpers } from './kibana_deprecations_service.mock';
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
import { act } from 'react-dom/test-utils';
import { deprecationsServiceMock } from 'src/core/public/mocks';

import { setupEnvironment, kibanaDeprecationsServiceHelpers } from '../helpers';
import { KibanaTestBed, setupKibanaPage } from './kibana_deprecations.helpers';
import { setupEnvironment } from '../../helpers';
import { kibanaDeprecationsServiceHelpers } from '../service.mock';
import { KibanaTestBed, setupKibanaPage } from '../kibana_deprecations.helpers';

describe('Kibana deprecation details flyout', () => {
describe('Kibana deprecations - Deprecation details flyout', () => {
let testBed: KibanaTestBed;
const { server } = setupEnvironment();
const {
Expand Down Expand Up @@ -75,6 +76,17 @@ describe('Kibana deprecation details flyout', () => {
});
});

test('Shows documentationUrl when present', async () => {
const { find, actions } = testBed;
const deprecation = mockedKibanaDeprecations[1];

await actions.table.clickDeprecationAt(1);

expect(find('kibanaDeprecationDetails.documentationLink').props().href).toBe(
deprecation.documentationUrl
);
});

describe('Deprecation with automatic resolution', () => {
test('resolves deprecation successfully', async () => {
const { find, exists, actions } = testBed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import { act } from 'react-dom/test-utils';
import { deprecationsServiceMock } from 'src/core/public/mocks';
import type { DeprecationsServiceStart } from 'kibana/public';

import { setupEnvironment, kibanaDeprecationsServiceHelpers } from '../helpers';
import { KibanaTestBed, setupKibanaPage } from './kibana_deprecations.helpers';
import { setupEnvironment } from '../../helpers';
import { kibanaDeprecationsServiceHelpers } from '../service.mock';
import { KibanaTestBed, setupKibanaPage } from '../kibana_deprecations.helpers';

describe('Kibana deprecations table', () => {
describe('Kibana deprecations - Deprecations table', () => {
let testBed: KibanaTestBed;
let deprecationService: jest.Mocked<DeprecationsServiceStart>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
import { act } from 'react-dom/test-utils';
import { deprecationsServiceMock } from 'src/core/public/mocks';

import { setupEnvironment, kibanaDeprecationsServiceHelpers } from '../helpers';
import { KibanaTestBed, setupKibanaPage } from './kibana_deprecations.helpers';
import { setupEnvironment } from '../../helpers';
import { kibanaDeprecationsServiceHelpers } from '../service.mock';
import { KibanaTestBed, setupKibanaPage } from '../kibana_deprecations.helpers';

describe('Error handling', () => {
describe('Kibana deprecations - Deprecations table - Error handling', () => {
let testBed: KibanaTestBed;
const { server } = setupEnvironment();
const deprecationService = deprecationsServiceMock.createStartContract();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const kibanaDeprecations: DomainDeprecationDetails[] = [
domainId: 'test_domain_2',
level: 'warning',
title: 'Test deprecation title 1',
documentationUrl: 'https://',
message: 'Test deprecation message 2',
deprecationType: 'feature',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import { act } from 'react-dom/test-utils';
import { deprecationsServiceMock } from 'src/core/public/mocks';

import { setupEnvironment, kibanaDeprecationsServiceHelpers } from '../../helpers';
import { setupEnvironment } from '../../helpers';
import { kibanaDeprecationsServiceHelpers } from '../../kibana_deprecations/service.mock';
import { OverviewTestBed, setupOverviewPage } from '../overview.helpers';
import {
esCriticalAndWarningDeprecations,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import { act } from 'react-dom/test-utils';
import { deprecationsServiceMock } from 'src/core/public/mocks';

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { act } from 'react-dom/test-utils';
import { deprecationsServiceMock } from 'src/core/public/mocks';
import type { DomainDeprecationDetails } from 'kibana/public';

import { setupEnvironment, kibanaDeprecationsServiceHelpers } from '../../helpers';
import { setupEnvironment } from '../../helpers';
import { kibanaDeprecationsServiceHelpers } from '../../kibana_deprecations/service.mock';
import { OverviewTestBed, setupOverviewPage } from '../overview.helpers';
import { esNoDeprecations } from './mock_es_issues';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export const DeprecationDetailsFlyout = ({

{documentationUrl && (
<p>
<EuiLink target="_blank" href={documentationUrl}>
<EuiLink target="_blank" data-test-subj="documentationLink" href={documentationUrl}>
{i18nTexts.learnMoreLinkLabel}
</EuiLink>
</p>
Expand Down

0 comments on commit 08474df

Please sign in to comment.