-
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
[Endpoint] Can delete policies #68567
Conversation
@elasticmachine merge upstream |
Pinging @elastic/endpoint-app-team (Feature:Endpoint) |
Pinging @elastic/endpoint-management (Team:Endpoint Management) |
@@ -24,7 +24,7 @@ import { EuiTabProps } from '@elastic/eui/src/components/tabs/tab'; | |||
|
|||
const StyledEuiPage = styled(EuiPage)` | |||
&.endpoint--isListView { | |||
padding: 0; | |||
padding: 0 70px 0 24px; |
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.
updated for 2 reasons, to be more uniform with the rest of the security app and to allow functional tests to execute properly as the overlap with the timeline was blocking click events
@@ -79,12 +79,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { | |||
expect(relativeDate).to.match(RELATIVE_DATE_FORMAT); | |||
}); | |||
}); | |||
it('should show policy name as link', async () => { |
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.
removed since I check the link is formed correctly in a unit test now
|
||
const StyledEuiPage = styled(EuiPage)` | ||
&.endpoint--isListView { | ||
padding: 0; | ||
padding: 0 ${gutterTimeline} 0 ${(props) => props.theme.eui.euiSizeL}; |
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.
updated for 2 reasons, to be more uniform with the rest of the security app and to allow functional tests to execute properly as the overlap with the timeline was blocking click events.
We'll be looking to remove the timeline flyout, so we could remove the functional test and add it back in afterwards, but wouldn't we want the tables to look uniform with the rest of the app regardless?
Thoughts @paul-tavares @bfishel
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.
I think this is ok for now. In the future we will likely move way from <PageView>
and use SIEMs page and header components -- and/or -- as you said, remove/hide the timeline
expect(policyDeleteButton).not.toBeNull(); | ||
}); | ||
}); | ||
it('should display agent config action as link', async () => { |
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.
May be good to put spaces between the ITs
@elasticmachine merge upstream |
@elasticmachine merge upstream |
body: DeleteDatasourcesRequest, | ||
options?: HttpFetchOptions | ||
) => { | ||
return http.post<DeleteDatasourcesResponse>(`${INGEST_API_DELETE_DATASOURCE}`, { |
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.
optinal:
return http.post<DeleteDatasourcesResponse>(`${INGEST_API_DELETE_DATASOURCE}`, { | |
return http.post<DeleteDatasourcesResponse>(INGEST_API_DELETE_DATASOURCE, { |
@@ -47,6 +58,45 @@ export const policyListMiddlewareFactory: ImmutableMiddlewareFactory<PolicyListS | |||
total: response ? response.total : initialPolicyListState().total, | |||
}, | |||
}); | |||
} else if (action.type === 'userClickedPolicyListDeleteButton') { | |||
const { policyId } = action.payload; | |||
const datasourceIds: string[] = [policyId]; |
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.
should we use the DeleteDatatsourceRequest['body']['datasourceIds']
here case the interface is ever changed?
expect(policyActionsButton).not.toBeNull(); | ||
|
||
reactTestingLibrary.fireEvent.click(policyActionsButton); | ||
renderResult.findByTestId('agentConfigLink').then((agentConfigLink) => { |
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 and similar lines below that are using then()
I think are causing the it()
test to exit before running the expect
. I would one of two things: either use a variable assignment along with await
or create a Promise.all() and return that so that the test knows to wait.
await actionsButton.click(); | ||
const deleteAction = await testSubjects.find('policyDeleteButton'); | ||
await deleteAction.click(); | ||
return await testSubjects.find('policyListDeleteModal'); |
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.
FYI - thre are a few modal page objects in common
that might do some of this here. Example: below, I use pageObjects.common.clickConfirmOnModal()
to click on the modal's confirm button
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.
I actually am using that function in one of the tests itself - https://github.com/elastic/kibana/pull/68567/files#diff-c48c00cc17b949e71b8732594dc70734R98
This is more to go through the motions of actually launching the delete modal through the policy actions
This looks great @kevinlog . I checked out the branch and ran through 🌞 day scenario and 👍 . |
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
@@ -6,6 +6,7 @@ | |||
|
|||
import { PolicyData } from '../../../../../../common/endpoint/types'; | |||
import { ServerApiError } from '../../../../../common/types'; | |||
import { GetAgentStatusResponse } from '../../../../../../../ingest_manager/common/types/rest_spec'; |
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.
is this exposed at top level /common
? if so, use that path instead.
You can do this in a subsequent PR 😃
await (await pageObjects.policy.findFirstActionsButton()).click(); | ||
}); | ||
|
||
it('should delete a policy', async () => { |
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.
🔥
@@ -33,6 +33,16 @@ export function EndpointPageProvider({ getService, getPageObjects }: FtrProvider | |||
}); | |||
}, | |||
|
|||
async waitForTableToNotHaveData(dataTestSubj: string) { |
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 is a nice one and I can see us moving this to a page_utils page object in the future as a common way to wait for a table to empty out 👍
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.
Just a small comment: we should add JSDocs to this method. I think normally, the page objects can be reused by other tests (even outside of Endpoint) to integrate/interact with endpoint functionality
/** | ||
* ensures that the Policy Page is the currently display view | ||
*/ | ||
async ensureIsOnPolicyPage() { |
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.
rename suggestion: ensureIsOnPolicyListPage()
?
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.
Did not run locally again, but changes look good. Left some minor comments that are optional and can be incorporated in future PRs.
Great job on this 👍
🚀
Summary
Adds ability to delete Policies from the Endpoint management pages.
Checklist
Delete any items that are not applicable to this PR.
For maintainers