-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ILM] Refactor component tests #91657
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,8 +25,6 @@ import { | |
getDefaultHotPhasePolicy, | ||
} from './constants'; | ||
|
||
window.scrollTo = jest.fn(); | ||
|
||
describe('<EditPolicy />', () => { | ||
let testBed: EditPolicyTestBed; | ||
const { server, httpRequestsMockHelpers } = setupEnvironment(); | ||
|
@@ -127,7 +125,7 @@ describe('<EditPolicy />', () => { | |
await actions.hot.setBestCompression(true); | ||
await actions.hot.toggleShrink(true); | ||
await actions.hot.setShrink('2'); | ||
await actions.hot.setReadonly(true); | ||
await actions.hot.toggleReadonly(true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've realised that these toggle/set functions do not actually set the boolean value, they just toggle whatever the toggle state is relative to what it was before. Not something to action, just observing since I introduced the boolean arg here. Might just need some slight investigation to fix, @sebelga have you encountered this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for pointing this out @jloleysens! It's worth investigating for sure, I'll put it in an issue. |
||
await actions.hot.toggleIndexPriority(true); | ||
await actions.hot.setIndexPriority('123'); | ||
|
||
|
@@ -271,7 +269,7 @@ describe('<EditPolicy />', () => { | |
await actions.warm.toggleForceMerge(true); | ||
await actions.warm.setForcemergeSegmentsCount('123'); | ||
await actions.warm.setBestCompression(true); | ||
await actions.warm.setReadonly(true); | ||
await actions.warm.toggleReadonly(true); | ||
await actions.warm.setIndexPriority('123'); | ||
await actions.savePolicy(); | ||
const latestRequest = server.requests[server.requests.length - 1]; | ||
|
@@ -918,13 +916,15 @@ describe('<EditPolicy />', () => { | |
}); | ||
|
||
describe('policy error notifications', () => { | ||
let runTimers: () => void; | ||
beforeAll(() => { | ||
jest.useFakeTimers(); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.useRealTimers(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
httpRequestsMockHelpers.setLoadPolicies([getDefaultHotPhasePolicy('my_policy')]); | ||
httpRequestsMockHelpers.setListNodes({ | ||
|
@@ -940,19 +940,9 @@ describe('<EditPolicy />', () => { | |
|
||
const { component } = testBed; | ||
component.update(); | ||
}); | ||
|
||
// For new we rely on a setTimeout to ensure that error messages have time to populate | ||
// the form object before we look at the form object. See: | ||
// x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/form_errors_context.tsx | ||
// for where this logic lives. | ||
const runTimers = () => { | ||
const { component } = testBed; | ||
act(() => { | ||
jest.runAllTimers(); | ||
}); | ||
component.update(); | ||
}; | ||
({ runTimers } = testBed); | ||
}); | ||
|
||
test('shows phase error indicators correctly', async () => { | ||
// This test simulates a user configuring a policy phase by phase. The flow is the following: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should no longer be necessary, if it is then we probably need to remove this from the code because AFAIK this is used to scroll to the first visible error on form submission. It's nice behaviour, but has not been mapped onto the new UI with collapsible settings in phases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still use a scroll to 0,0 for when the policy has loaded (edit_policy.tsx#L66). It doesn't affect the tests results though, but I prefer to keep it there for now to avoid unnecessary errors in output.