-
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.
[Upgrade Assistant] Refactor CITs (#109536)
- Loading branch information
1 parent
ec3c28f
commit af6b908
Showing
19 changed files
with
279 additions
and
333 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
150 changes: 150 additions & 0 deletions
150
.../upgrade_assistant/__jest__/client_integration/es_deprecations/es_deprecations.helpers.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,150 @@ | ||
/* | ||
* 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, TestBedConfig } from '@kbn/test/jest'; | ||
import { EsDeprecations } from '../../../public/application/components/es_deprecations'; | ||
import { WithAppDependencies } from '../helpers'; | ||
|
||
const testBedConfig: TestBedConfig = { | ||
memoryRouter: { | ||
initialEntries: ['/es_deprecations'], | ||
componentRoutePath: '/es_deprecations', | ||
}, | ||
doMountAsync: true, | ||
}; | ||
|
||
export type ElasticsearchTestBed = TestBed & { | ||
actions: ReturnType<typeof createActions>; | ||
}; | ||
|
||
const createActions = (testBed: TestBed) => { | ||
const { component, find } = testBed; | ||
|
||
/** | ||
* User Actions | ||
*/ | ||
|
||
const table = { | ||
clickRefreshButton: async () => { | ||
await act(async () => { | ||
find('refreshButton').simulate('click'); | ||
}); | ||
|
||
component.update(); | ||
}, | ||
clickDeprecationRowAt: async ( | ||
deprecationType: 'mlSnapshot' | 'indexSetting' | 'reindex' | 'default', | ||
index: number | ||
) => { | ||
await act(async () => { | ||
find(`deprecation-${deprecationType}`).at(index).simulate('click'); | ||
}); | ||
|
||
component.update(); | ||
}, | ||
}; | ||
|
||
const searchBar = { | ||
clickTypeFilterDropdownAt: async (index: number) => { | ||
await act(async () => { | ||
// EUI doesn't support data-test-subj's on the filter buttons, so we must access via CSS selector | ||
find('searchBarContainer') | ||
.find('.euiPopover') | ||
.find('.euiFilterButton') | ||
.at(index) | ||
.simulate('click'); | ||
}); | ||
|
||
component.update(); | ||
}, | ||
setSearchInputValue: async (searchValue: string) => { | ||
await act(async () => { | ||
find('searchBarContainer') | ||
.find('input') | ||
.simulate('keyup', { target: { value: searchValue } }); | ||
}); | ||
|
||
component.update(); | ||
}, | ||
clickCriticalFilterButton: async () => { | ||
await act(async () => { | ||
// EUI doesn't support data-test-subj's on the filter buttons, so we must access via CSS selector | ||
find('searchBarContainer').find('.euiFilterButton').at(0).simulate('click'); | ||
}); | ||
|
||
component.update(); | ||
}, | ||
}; | ||
|
||
const pagination = { | ||
clickPaginationAt: async (index: number) => { | ||
await act(async () => { | ||
find(`pagination-button-${index}`).simulate('click'); | ||
}); | ||
|
||
component.update(); | ||
}, | ||
clickRowsPerPageDropdown: async () => { | ||
await act(async () => { | ||
find('tablePaginationPopoverButton').simulate('click'); | ||
}); | ||
|
||
component.update(); | ||
}, | ||
}; | ||
|
||
const mlDeprecationFlyout = { | ||
clickUpgradeSnapshot: async () => { | ||
await act(async () => { | ||
find('mlSnapshotDetails.upgradeSnapshotButton').simulate('click'); | ||
}); | ||
|
||
component.update(); | ||
}, | ||
clickDeleteSnapshot: async () => { | ||
await act(async () => { | ||
find('mlSnapshotDetails.deleteSnapshotButton').simulate('click'); | ||
}); | ||
|
||
component.update(); | ||
}, | ||
}; | ||
|
||
const indexSettingsDeprecationFlyout = { | ||
clickDeleteSettingsButton: async () => { | ||
await act(async () => { | ||
find('deleteSettingsButton').simulate('click'); | ||
}); | ||
|
||
component.update(); | ||
}, | ||
}; | ||
|
||
return { | ||
table, | ||
searchBar, | ||
pagination, | ||
mlDeprecationFlyout, | ||
indexSettingsDeprecationFlyout, | ||
}; | ||
}; | ||
|
||
export const setupElasticsearchPage = async ( | ||
overrides?: Record<string, unknown> | ||
): Promise<ElasticsearchTestBed> => { | ||
const initTestBed = registerTestBed( | ||
WithAppDependencies(EsDeprecations, overrides), | ||
testBedConfig | ||
); | ||
const testBed = await initTestBed(); | ||
|
||
return { | ||
...testBed, | ||
actions: createActions(testBed), | ||
}; | ||
}; |
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
Oops, something went wrong.