From 47af727577efda8aabd5683714fa5638160aa377 Mon Sep 17 00:00:00 2001 From: Rashmi Kulkarni Date: Mon, 5 Apr 2021 17:29:27 -0700 Subject: [PATCH] fixes a skipped management x-pack test (#96178) (#96267) * fixes a skipped management x-pack test * modified the test to incoroporate the review comments Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../management/users/edit_user/user_form.tsx | 5 ++++ .../functional/apps/security/management.js | 29 ++++++++++--------- .../functional/page_objects/security_page.ts | 5 ++++ 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/x-pack/plugins/security/public/management/users/edit_user/user_form.tsx b/x-pack/plugins/security/public/management/users/edit_user/user_form.tsx index 10e9e86e10f3a..12297758503ad 100644 --- a/x-pack/plugins/security/public/management/users/edit_user/user_form.tsx +++ b/x-pack/plugins/security/public/management/users/edit_user/user_form.tsx @@ -257,6 +257,7 @@ export const UserForm: FunctionComponent = ({ > = ({ > = ({ > = ({ > = ({ > { - // await PageObjects.security.login('elastic', 'changeme'); await PageObjects.security.initTests(); await kibanaServer.uiSettings.update({ defaultIndex: 'logstash-*', @@ -43,20 +44,26 @@ export default function ({ getService, getPageObjects }) { await PageObjects.settings.navigateTo(); }); + after(async () => { + await security.role.delete('logstash-readonly'); + await security.user.delete('dashuser', 'new-user'); + await PageObjects.security.forceLogout(); + }); + describe('Security', () => { describe('navigation', () => { it('Can navigate to create user section', async () => { await PageObjects.security.clickElasticsearchUsers(); await PageObjects.security.clickCreateNewUser(); const currentUrl = await browser.getCurrentUrl(); - expect(currentUrl).to.contain(EDIT_USERS_PATH); + expect(currentUrl).to.contain(CREATE_USERS_PATH); }); it('Clicking cancel in create user section brings user back to listing', async () => { await PageObjects.security.clickCancelEditUser(); const currentUrl = await browser.getCurrentUrl(); expect(currentUrl).to.contain(USERS_PATH); - expect(currentUrl).to.not.contain(EDIT_USERS_PATH); + expect(currentUrl).to.not.contain(CREATE_USERS_PATH); }); it('Clicking save in create user section brings user back to listing', async () => { @@ -67,12 +74,11 @@ export default function ({ getService, getPageObjects }) { await testSubjects.setValue('passwordConfirmationInput', '123456'); await testSubjects.setValue('userFormFullNameInput', 'Full User Name'); await testSubjects.setValue('userFormEmailInput', 'example@example.com'); - - await PageObjects.security.clickSaveEditUser(); + await PageObjects.security.clickSaveCreateUser(); const currentUrl = await browser.getCurrentUrl(); expect(currentUrl).to.contain(USERS_PATH); - expect(currentUrl).to.not.contain(EDIT_USERS_PATH); + expect(currentUrl).to.not.contain(CREATE_USERS_PATH); }); it('Can navigate to edit user section', async () => { @@ -143,14 +149,11 @@ export default function ({ getService, getPageObjects }) { await testSubjects.setValue('passwordConfirmationInput', '123456'); await testSubjects.setValue('userFormFullNameInput', 'dashuser'); await testSubjects.setValue('userFormEmailInput', 'example@example.com'); - await PageObjects.security.assignRoleToUser('kibana_dashboard_only_user'); await PageObjects.security.assignRoleToUser('logstash-readonly'); - - await PageObjects.security.clickSaveEditUser(); - + await PageObjects.security.clickSaveCreateUser(); await PageObjects.settings.navigateTo(); await testSubjects.click('users'); - await PageObjects.settings.clickLinkText('kibana_dashboard_only_user'); + await find.clickByButtonText('logstash-readonly'); const currentUrl = await browser.getCurrentUrl(); expect(currentUrl).to.contain(EDIT_ROLES_PATH); }); diff --git a/x-pack/test/functional/page_objects/security_page.ts b/x-pack/test/functional/page_objects/security_page.ts index 3c0ef7348a4b3..6907e366d28c3 100644 --- a/x-pack/test/functional/page_objects/security_page.ts +++ b/x-pack/test/functional/page_objects/security_page.ts @@ -289,6 +289,11 @@ export function SecurityPageProvider({ getService, getPageObjects }: FtrProvider await PageObjects.header.waitUntilLoadingHasFinished(); } + async clickSaveCreateUser() { + await find.clickByButtonText('Create user'); + await PageObjects.header.waitUntilLoadingHasFinished(); + } + async clickSaveEditRole() { const saveButton = await retry.try(() => testSubjects.find('roleFormSaveButton')); await saveButton.moveMouseTo();