-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refine success state behavior and add tests.
* Refactor components into a components directory. * Refactor SCSS to colocate styles with their components. * Refactor tests to reduce boilerplate and clarify conditions under test.
- Loading branch information
Showing
22 changed files
with
776 additions
and
562 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
186 changes: 186 additions & 0 deletions
186
...t__/client_integration/overview/fix_issues_step/elasticsearch_deprecation_issues.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.