Skip to content

Commit

Permalink
fixes a skipped management x-pack test (#96178) (#96267)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
rashmivkulkarni and kibanamachine committed Apr 6, 2021
1 parent c35270d commit 47af727
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ export const UserForm: FunctionComponent<UserFormProps> = ({
>
<EuiFieldText
name="username"
data-test-subj={'userFormUserNameInput'}
icon="user"
value={form.values.username}
isLoading={form.isValidating}
Expand All @@ -278,6 +279,7 @@ export const UserForm: FunctionComponent<UserFormProps> = ({
>
<EuiFieldText
name="full_name"
data-test-subj={'userFormFullNameInput'}
value={form.values.full_name}
isInvalid={form.touched.full_name && !!form.errors.full_name}
onChange={eventHandlers.onChange}
Expand All @@ -293,6 +295,7 @@ export const UserForm: FunctionComponent<UserFormProps> = ({
>
<EuiFieldText
name="email"
data-test-subj={'userFormEmailInput'}
value={form.values.email}
isInvalid={form.touched.email && !!form.errors.email}
onChange={eventHandlers.onChange}
Expand Down Expand Up @@ -332,6 +335,7 @@ export const UserForm: FunctionComponent<UserFormProps> = ({
>
<EuiFieldPassword
name="password"
data-test-subj={'passwordInput'}
type="dual"
value={form.values.password}
isInvalid={form.touched.password && !!form.errors.password}
Expand All @@ -349,6 +353,7 @@ export const UserForm: FunctionComponent<UserFormProps> = ({
>
<EuiFieldPassword
name="confirm_password"
data-test-subj={'passwordConfirmationInput'}
type="dual"
value={form.values.confirm_password}
isInvalid={form.touched.confirm_password && !!form.errors.confirm_password}
Expand Down
29 changes: 16 additions & 13 deletions x-pack/test/functional/apps/security/management.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@ export default function ({ getService, getPageObjects }) {
const kibanaServer = getService('kibanaServer');
const testSubjects = getService('testSubjects');
const browser = getService('browser');
const find = getService('find');
const PageObjects = getPageObjects(['security', 'settings', 'common', 'header']);

const USERS_PATH = 'security/users';
const EDIT_USERS_PATH = `${USERS_PATH}/edit`;
const CREATE_USERS_PATH = `${USERS_PATH}/create`;

const ROLES_PATH = 'security/roles';
const EDIT_ROLES_PATH = `${ROLES_PATH}/edit`;
const CLONE_ROLES_PATH = `${ROLES_PATH}/clone`;
const security = getService('security');

// FLAKY: https://github.com/elastic/kibana/issues/61173
describe.skip('Management', function () {
describe('Management', function () {
this.tags(['skipFirefox']);

before(async () => {
// await PageObjects.security.login('elastic', 'changeme');
await PageObjects.security.initTests();
await kibanaServer.uiSettings.update({
defaultIndex: 'logstash-*',
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand Down Expand Up @@ -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);
});
Expand Down
5 changes: 5 additions & 0 deletions x-pack/test/functional/page_objects/security_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 47af727

Please sign in to comment.