-
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.
hide readonly action if downsample enabled
- Loading branch information
Showing
9 changed files
with
160 additions
and
10 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
...fecycle_management/__jest__/client_integration/edit_policy/features/downsample.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,52 @@ | ||
/* | ||
* 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 { HttpSetup } from '@kbn/core/public'; | ||
import { | ||
createDownsampleActions, | ||
createReadonlyActions, | ||
createRolloverActions, | ||
createSavePolicyAction, | ||
createTogglePhaseAction, | ||
} from '../../helpers'; | ||
import { initTestBed } from '../init_test_bed'; | ||
import { AppServicesContext } from '../../../../public/types'; | ||
|
||
type SetupReturn = ReturnType<typeof setupDownsampleTestBed>; | ||
|
||
export type DownsampleTestBed = SetupReturn extends Promise<infer U> ? U : SetupReturn; | ||
|
||
export const setupDownsampleTestBed = async ( | ||
httpSetup: HttpSetup, | ||
args?: { | ||
appServicesContext?: Partial<AppServicesContext>; | ||
} | ||
) => { | ||
const testBed = await initTestBed(httpSetup, args); | ||
|
||
return { | ||
...testBed, | ||
actions: { | ||
togglePhase: createTogglePhaseAction(testBed), | ||
savePolicy: createSavePolicyAction(testBed), | ||
...createRolloverActions(testBed), | ||
hot: { | ||
...createReadonlyActions(testBed, 'hot'), | ||
...createDownsampleActions(testBed, 'hot'), | ||
}, | ||
warm: { | ||
...createReadonlyActions(testBed, 'warm'), | ||
...createDownsampleActions(testBed, 'warm'), | ||
}, | ||
cold: { | ||
...createReadonlyActions(testBed, 'cold'), | ||
...createDownsampleActions(testBed, 'cold'), | ||
}, | ||
frozen: {}, | ||
}, | ||
}; | ||
}; |
54 changes: 54 additions & 0 deletions
54
..._lifecycle_management/__jest__/client_integration/edit_policy/features/downsample.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,54 @@ | ||
/* | ||
* 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 { setupEnvironment } from '../../helpers'; | ||
import { DownsampleTestBed, setupDownsampleTestBed } from './downsample.helpers'; | ||
|
||
describe('<EditPolicy /> downsample', () => { | ||
let testBed: DownsampleTestBed; | ||
const { httpSetup, httpRequestsMockHelpers } = setupEnvironment(); | ||
|
||
beforeEach(async () => { | ||
httpRequestsMockHelpers.setDefaultResponses(); | ||
|
||
await act(async () => { | ||
testBed = await setupDownsampleTestBed(httpSetup); | ||
}); | ||
|
||
const { component } = testBed; | ||
component.update(); | ||
}); | ||
|
||
test('enabling downsample in warm should hide readonly in warm and cold', async () => { | ||
const { actions } = testBed; | ||
|
||
await actions.togglePhase('warm'); | ||
await actions.togglePhase('cold'); | ||
|
||
expect(actions.warm.downsample.exists()).toBeTruthy(); | ||
expect(actions.warm.readonlyExists()).toBeTruthy(); | ||
expect(actions.cold.downsample.exists()).toBeTruthy(); | ||
expect(actions.cold.readonlyExists()).toBeTruthy(); | ||
|
||
await actions.warm.downsample.toggle(); | ||
|
||
expect(actions.warm.readonlyExists()).toBeFalsy(); | ||
expect(actions.cold.readonlyExists()).toBeFalsy(); | ||
}); | ||
|
||
test('enabling downsample in hot should hide readonly in hot', async () => { | ||
const { actions } = testBed; | ||
await actions.rollover.toggleDefault(); | ||
|
||
expect(actions.hot.downsample.exists()).toBeTruthy(); | ||
expect(actions.hot.readonlyExists()).toBeTruthy(); | ||
|
||
await actions.hot.downsample.toggle(); | ||
expect(actions.hot.readonlyExists()).toBeFalsy(); | ||
}); | ||
}); |
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
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
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