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] New Kibana deprecations page (elastic#110101)
- Loading branch information
1 parent
254784a
commit d562ef7
Showing
46 changed files
with
1,434 additions
and
1,643 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
132 changes: 132 additions & 0 deletions
132
...istant/__jest__/client_integration/kibana_deprecations/deprecation_details_flyout.test.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,132 @@ | ||
/* | ||
* 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 } from '../helpers'; | ||
import { KibanaTestBed, setupKibanaPage } from './kibana_deprecations.helpers'; | ||
import { kibanaDeprecationsMockResponse } from './mocked_responses'; | ||
|
||
describe('Kibana deprecation details flyout', () => { | ||
let testBed: KibanaTestBed; | ||
const { server } = setupEnvironment(); | ||
const deprecationService = deprecationsServiceMock.createStartContract(); | ||
|
||
afterAll(() => { | ||
server.restore(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
await act(async () => { | ||
deprecationService.getAllDeprecations = jest | ||
.fn() | ||
.mockReturnValue(kibanaDeprecationsMockResponse); | ||
|
||
testBed = await setupKibanaPage({ | ||
services: { | ||
core: { | ||
deprecations: deprecationService, | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
testBed.component.update(); | ||
}); | ||
|
||
describe('Deprecation with manual steps', () => { | ||
test('renders flyout with manual steps only', async () => { | ||
const { find, exists, actions } = testBed; | ||
const manualDeprecation = kibanaDeprecationsMockResponse[1]; | ||
|
||
await actions.table.clickDeprecationAt(1); | ||
|
||
expect(exists('kibanaDeprecationDetails')).toBe(true); | ||
expect(find('kibanaDeprecationDetails.flyoutTitle').text()).toBe(manualDeprecation.title); | ||
expect(find('manualStepsList').find('li').length).toEqual( | ||
manualDeprecation.correctiveActions.manualSteps.length | ||
); | ||
|
||
// Quick resolve callout and button should not display | ||
expect(exists('quickResolveCallout')).toBe(false); | ||
expect(exists('resolveButton')).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('Deprecation with automatic resolution', () => { | ||
test('resolves deprecation successfully', async () => { | ||
const { find, exists, actions } = testBed; | ||
const quickResolveDeprecation = kibanaDeprecationsMockResponse[0]; | ||
|
||
await actions.table.clickDeprecationAt(0); | ||
|
||
expect(exists('kibanaDeprecationDetails')).toBe(true); | ||
expect(find('kibanaDeprecationDetails.flyoutTitle').text()).toBe( | ||
quickResolveDeprecation.title | ||
); | ||
expect(find('manualStepsList').find('li').length).toEqual( | ||
quickResolveDeprecation.correctiveActions.manualSteps.length | ||
); | ||
|
||
// Quick resolve callout and button should display | ||
expect(exists('quickResolveCallout')).toBe(true); | ||
expect(exists('resolveButton')).toBe(true); | ||
|
||
await actions.flyout.clickResolveButton(); | ||
|
||
// Flyout should close after button click | ||
expect(exists('kibanaDeprecationDetails')).toBe(false); | ||
|
||
// Reopen the flyout | ||
await actions.table.clickDeprecationAt(0); | ||
|
||
// Resolve information should not display and Quick resolve button should be disabled | ||
expect(exists('resolveSection')).toBe(false); | ||
expect(find('resolveButton').props().disabled).toBe(true); | ||
expect(find('resolveButton').text()).toContain('Resolved'); | ||
}); | ||
|
||
test('handles resolve failure', async () => { | ||
const { find, exists, actions } = testBed; | ||
const quickResolveDeprecation = kibanaDeprecationsMockResponse[0]; | ||
|
||
deprecationService.resolveDeprecation.mockReturnValue( | ||
Promise.resolve({ | ||
status: 'fail', | ||
reason: 'resolve failed', | ||
}) | ||
); | ||
|
||
await actions.table.clickDeprecationAt(0); | ||
|
||
expect(exists('kibanaDeprecationDetails')).toBe(true); | ||
expect(find('kibanaDeprecationDetails.flyoutTitle').text()).toBe( | ||
quickResolveDeprecation.title | ||
); | ||
|
||
// Quick resolve callout and button should display | ||
expect(exists('quickResolveCallout')).toBe(true); | ||
expect(exists('resolveButton')).toBe(true); | ||
|
||
await actions.flyout.clickResolveButton(); | ||
|
||
// Flyout should close after button click | ||
expect(exists('kibanaDeprecationDetails')).toBe(false); | ||
|
||
// Reopen the flyout | ||
await actions.table.clickDeprecationAt(0); | ||
|
||
// Verify error displays | ||
expect(exists('quickResolveError')).toBe(true); | ||
// Resolve information should display and Quick resolve button should be enabled | ||
expect(exists('resolveSection')).toBe(true); | ||
expect(find('resolveButton').props().disabled).toBe(false); | ||
expect(find('resolveButton').text()).toContain('Try again'); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.