forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Upgrade Assistant] Add deprecation logging as step on overview page (e…
- Loading branch information
1 parent
634ae6e
commit 1c43626
Showing
10 changed files
with
425 additions
and
60 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
159 changes: 159 additions & 0 deletions
159
...ugins/upgrade_assistant/__jest__/client_integration/overview/logs_step/logs_step.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,159 @@ | ||
/* | ||
* 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 { DEPRECATION_LOGS_INDEX } from '../../../../common/constants'; | ||
import { setupEnvironment } from '../../helpers'; | ||
import { OverviewTestBed, setupOverviewPage } from '../overview.helpers'; | ||
|
||
describe('Overview - Logs Step', () => { | ||
let testBed: OverviewTestBed; | ||
|
||
const { server, httpRequestsMockHelpers } = setupEnvironment(); | ||
|
||
afterAll(() => { | ||
server.restore(); | ||
}); | ||
|
||
describe('error state', () => { | ||
beforeEach(async () => { | ||
const error = { | ||
statusCode: 500, | ||
error: 'Internal server error', | ||
message: 'Internal server error', | ||
}; | ||
|
||
httpRequestsMockHelpers.setLoadDeprecationLogsCountResponse(undefined, error); | ||
|
||
await act(async () => { | ||
testBed = await setupOverviewPage(); | ||
}); | ||
|
||
testBed.component.update(); | ||
}); | ||
|
||
test('is rendered', () => { | ||
const { exists } = testBed; | ||
expect(exists('deprecationLogsErrorCallout')).toBe(true); | ||
expect(exists('deprecationLogsRetryButton')).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('success state', () => { | ||
describe('logging enabled', () => { | ||
beforeEach(() => { | ||
httpRequestsMockHelpers.setLoadDeprecationLoggingResponse({ | ||
isDeprecationLogIndexingEnabled: true, | ||
isDeprecationLoggingEnabled: true, | ||
}); | ||
}); | ||
|
||
test('renders step as complete when a user has 0 logs', async () => { | ||
httpRequestsMockHelpers.setLoadDeprecationLogsCountResponse({ | ||
count: 0, | ||
}); | ||
|
||
await act(async () => { | ||
testBed = await setupOverviewPage(); | ||
}); | ||
|
||
const { component, exists } = testBed; | ||
|
||
component.update(); | ||
|
||
expect(exists('logsStep-complete')).toBe(true); | ||
}); | ||
|
||
test('renders step as incomplete when a user has >0 logs', async () => { | ||
httpRequestsMockHelpers.setLoadDeprecationLogsCountResponse({ | ||
count: 10, | ||
}); | ||
|
||
await act(async () => { | ||
testBed = await setupOverviewPage(); | ||
}); | ||
|
||
const { component, exists } = testBed; | ||
|
||
component.update(); | ||
|
||
expect(exists('logsStep-incomplete')).toBe(true); | ||
}); | ||
|
||
test('renders deprecation issue count and button to view logs', async () => { | ||
httpRequestsMockHelpers.setLoadDeprecationLogsCountResponse({ | ||
count: 10, | ||
}); | ||
|
||
await act(async () => { | ||
testBed = await setupOverviewPage(); | ||
}); | ||
|
||
const { component, find } = testBed; | ||
|
||
component.update(); | ||
|
||
expect(find('logsCountDescription').text()).toContain('You have 10 deprecation issues'); | ||
expect(find('viewLogsLink').text()).toContain('View logs'); | ||
}); | ||
}); | ||
|
||
describe('logging disabled', () => { | ||
beforeEach(async () => { | ||
httpRequestsMockHelpers.setLoadDeprecationLoggingResponse({ | ||
isDeprecationLogIndexingEnabled: false, | ||
isDeprecationLoggingEnabled: true, | ||
}); | ||
|
||
await act(async () => { | ||
testBed = await setupOverviewPage(); | ||
}); | ||
|
||
const { component } = testBed; | ||
|
||
component.update(); | ||
}); | ||
|
||
test('renders button to enable logs', () => { | ||
const { find, exists } = testBed; | ||
|
||
expect(exists('logsCountDescription')).toBe(false); | ||
expect(find('enableLogsLink').text()).toContain('Enable logging'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('privileges', () => { | ||
beforeEach(async () => { | ||
httpRequestsMockHelpers.setLoadDeprecationLoggingResponse({ | ||
isDeprecationLogIndexingEnabled: true, | ||
isDeprecationLoggingEnabled: true, | ||
}); | ||
|
||
await act(async () => { | ||
testBed = await setupOverviewPage({ | ||
privileges: { | ||
hasAllPrivileges: true, | ||
missingPrivileges: { | ||
index: [DEPRECATION_LOGS_INDEX], | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
const { component } = testBed; | ||
|
||
component.update(); | ||
}); | ||
|
||
test('warns the user of missing index privileges', () => { | ||
const { exists } = testBed; | ||
|
||
expect(exists('missingPrivilegesCallout')).toBe(true); | ||
}); | ||
}); | ||
}); |
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
8 changes: 8 additions & 0 deletions
8
x-pack/plugins/upgrade_assistant/public/application/components/overview/logs_step/index.ts
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,8 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { getLogsStep } from './logs_step'; |
Oops, something went wrong.