-
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
Fix ilm navigation #81664
Merged
Merged
Fix ilm navigation #81664
Changes from 5 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
85ae4c3
Fix edit policy page navigation
yuliacech 0577f4a
Fix edit policy page navigation
yuliacech 36349b9
Add links to PR for explanation
yuliacech 5bd83e7
Merge branch 'upstream_master' into fix_ilm_navigation
yuliacech 2d557aa
Merge branch 'master' into fix_ilm_navigation
kibanamachine 2798750
Merge branch 'master' into fix_ilm_navigation
yuliacech 0e98681
Added more tests and linked to a github issue about navigation issues
yuliacech f4015fc
Fix decoding function for undefined values
yuliacech 9acc687
Fix type check issues
yuliacech 05459f2
Renamed dollar sign to percent sign, added a method for (double) enco…
yuliacech c51af34
Merge branch 'master' into fix_ilm_navigation
kibanamachine 21338cf
Merge branch 'master' into fix_ilm_navigation
yuliacech 0c16d97
Merge branch 'master' into fix_ilm_navigation
kibanamachine 0baccad
Merge branch 'master' into fix_ilm_navigation
kibanamachine cc29641
Merge branch 'master' into fix_ilm_navigation
kibanamachine 42adcb2
Merge branch 'master' into fix_ilm_navigation
yuliacech 5a735df
Deleted Index Management from required bundles in ILM
yuliacech a0a4aaf
Fixed merge conflicts
yuliacech ab1c1d9
Revert "Deleted Index Management from required bundles in ILM"
yuliacech File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.helpers.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,55 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { act } from 'react-dom/test-utils'; | ||
import { registerTestBed, TestBed, TestBedConfig } from '../../../../../test_utils'; | ||
import { App } from '../../../public/application/app'; | ||
import { TestSubjects } from '../helpers'; | ||
|
||
const getTestBedConfig = (initialEntries: string[]): TestBedConfig => ({ | ||
memoryRouter: { | ||
initialEntries, | ||
}, | ||
defaultProps: { | ||
getUrlForApp: () => {}, | ||
navigateToApp: () => {}, | ||
}, | ||
}); | ||
|
||
const initTestBed = (initialEntries: string[]) => | ||
registerTestBed(App, getTestBedConfig(initialEntries))(); | ||
|
||
export interface AppTestBed extends TestBed<TestSubjects> { | ||
actions: { | ||
clickPolicyNameLink: () => void; | ||
clickCreatePolicyButton: () => void; | ||
}; | ||
} | ||
|
||
export const setup = async (initialEntries: string[]): Promise<AppTestBed> => { | ||
const testBed = await initTestBed(initialEntries); | ||
|
||
const clickPolicyNameLink = async () => { | ||
const { component, find } = testBed; | ||
await act(async () => { | ||
find('policyTablePolicyNameLink').simulate('click', { button: 0 }); | ||
}); | ||
component.update(); | ||
}; | ||
|
||
const clickCreatePolicyButton = async () => { | ||
const { component, find } = testBed; | ||
await act(async () => { | ||
find('createPolicyButton').simulate('click', { button: 0 }); | ||
}); | ||
component.update(); | ||
}; | ||
|
||
return { | ||
...testBed, | ||
actions: { clickPolicyNameLink, clickCreatePolicyButton }, | ||
}; | ||
}; |
84 changes: 84 additions & 0 deletions
84
x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.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,84 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { AppTestBed, setup } from './app.helpers'; | ||
import { setupEnvironment } from '../helpers/setup_environment'; | ||
import { SPECIAL_CHARS_NAME, getDefaultHotPhasePolicy } from '../edit_policy/constants'; | ||
import { act } from 'react-dom/test-utils'; | ||
|
||
window.scrollTo = jest.fn(); | ||
|
||
describe('<App />', () => { | ||
let testBed: AppTestBed; | ||
const { server, httpRequestsMockHelpers } = setupEnvironment(); | ||
afterAll(() => { | ||
server.restore(); | ||
}); | ||
|
||
describe('navigation with special characters', () => { | ||
beforeAll(async () => { | ||
httpRequestsMockHelpers.setLoadPolicies([getDefaultHotPhasePolicy(SPECIAL_CHARS_NAME)]); | ||
}); | ||
|
||
test('when clicked on policy name in table', async () => { | ||
await act(async () => { | ||
testBed = await setup(['/']); | ||
}); | ||
|
||
const { component, actions } = testBed; | ||
component.update(); | ||
|
||
await actions.clickPolicyNameLink(); | ||
component.update(); | ||
|
||
expect(testBed.find('policyTitle').text()).toBe( | ||
`Edit index lifecycle policy ${SPECIAL_CHARS_NAME}` | ||
); | ||
}); | ||
|
||
test('when creating a new policy', async () => { | ||
await act(async () => { | ||
testBed = await setup(['/']); | ||
}); | ||
|
||
const { component, actions } = testBed; | ||
component.update(); | ||
|
||
await actions.clickCreatePolicyButton(); | ||
component.update(); | ||
|
||
expect(testBed.find('policyTitle').text()).toBe(`Create an index lifecycle policy`); | ||
}); | ||
|
||
test('when loading edit policy page url', async () => { | ||
await act(async () => { | ||
testBed = await setup([`/policies/edit/${encodeURIComponent(SPECIAL_CHARS_NAME)}`]); | ||
}); | ||
|
||
const { component } = testBed; | ||
component.update(); | ||
|
||
expect(testBed.find('policyTitle').text()).toBe( | ||
`Edit index lifecycle policy ${SPECIAL_CHARS_NAME}` | ||
); | ||
}); | ||
|
||
test('when loading edit policy page url with double encoding', async () => { | ||
await act(async () => { | ||
testBed = await setup([ | ||
encodeURI(`/policies/edit/${encodeURIComponent(SPECIAL_CHARS_NAME)}`), | ||
]); | ||
}); | ||
|
||
const { component } = testBed; | ||
component.update(); | ||
|
||
expect(testBed.find('policyTitle').text()).toBe( | ||
`Edit index lifecycle policy ${SPECIAL_CHARS_NAME}` | ||
); | ||
}); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,12 +76,22 @@ export const EditPolicy: React.FunctionComponent<Props & RouteComponentProps<Rou | |
); | ||
} | ||
|
||
let decodedPolicyName = policyName; | ||
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. Can we add a comment here that this code can be removed if we upgrade to react-router 6 and history 5? |
||
if (policyName) { | ||
try { | ||
decodedPolicyName = decodeURIComponent(policyName); | ||
} catch (e) { | ||
// %25 is automatically decoded to %, so decoding it again will throw an error | ||
// that have to be ignored (https://github.com/elastic/kibana/pull/81664) | ||
} | ||
} | ||
|
||
return ( | ||
<PresentationComponent | ||
policies={policies} | ||
history={history} | ||
getUrlForApp={getUrlForApp} | ||
policyName={policyName} | ||
policyName={decodedPolicyName} | ||
/> | ||
); | ||
}; |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 file is only consumed in
app.test.ts
, and I find it's a bit easier to understand the tests if this value is colocated with the code that consumes it. Can we define it there until it needs to be used in multiple files, at which point we can extract it to a common location like this file?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.
Also, what do you think of using the full set of reserved characters that the API allows?