Skip to content

Commit 67af869

Browse files
committed
Fix flaky combobox tests on role management screen
1 parent dfea483 commit 67af869

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

x-pack/test/functional/apps/security/doc_level_security_roles.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
1919
const PageObjects = getPageObjects(['security', 'common', 'header', 'discover', 'settings']);
2020
const kibanaServer = getService('kibanaServer');
2121

22-
// Failing: See https://github.com/elastic/kibana/issues/155447
23-
describe.skip('dls', function () {
22+
describe('dls', function () {
2423
before('initialize tests', async () => {
2524
await kibanaServer.savedObjects.cleanStandardList();
2625
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/security/dlstest');

x-pack/test/functional/page_objects/security_page.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import { adminTestUser } from '@kbn/test';
99
import { AuthenticatedUser, Role } from '@kbn/security-plugin/common/model';
1010
import type { UserFormValues } from '@kbn/security-plugin/public/management/users/edit_user/user_form';
11+
import { Key } from 'selenium-webdriver';
1112
import { FtrService } from '../ftr_provider_context';
1213

1314
interface LoginOptions {
@@ -359,14 +360,12 @@ export class SecurityPageObject extends FtrService {
359360
}
360361

361362
async addPrivilegeToRole(privilege: string) {
362-
this.log.debug(`Adding privilege ${privilege} to role`);
363-
const privilegeInput = await this.retry.try(() =>
364-
this.find.byCssSelector('[data-test-subj="privilegesInput0"] input')
365-
);
366-
await privilegeInput.type(privilege);
367-
368-
const btn = await this.find.byButtonText(privilege);
369-
await btn.click();
363+
this.log.debug(`Adding privilege "${privilege}" to role`);
364+
const privilegesField = await this.testSubjects.find('privilegesInput0');
365+
const privilegesInput = await privilegesField.findByTagName('input');
366+
await privilegesInput.type(privilege);
367+
await privilegesInput.pressKeys(Key.ENTER); // Add typed privilege to combo box
368+
await privilegesInput.pressKeys(Key.ESCAPE); // Close dropdown menu to avoid hiding elements from test runner
370369
}
371370

372371
async assignRoleToUser(role: string) {
@@ -586,23 +585,27 @@ export class SecurityPageObject extends FtrService {
586585
}
587586

588587
await this.testSubjects.click('addSpacePrivilegeButton');
589-
await this.testSubjects.click('spaceSelectorComboBox');
588+
const spaceSelectorComboBox = await this.testSubjects.find('spaceSelectorComboBox');
589+
await spaceSelectorComboBox.click();
590590

591591
const globalSpaceOption = await this.find.byCssSelector(`#spaceOption_\\*`);
592592
await globalSpaceOption.click();
593593

594+
// Close dropdown menu to avoid hiding elements from test runner
595+
const spaceSelectorInput = await spaceSelectorComboBox.findByTagName('input');
596+
await spaceSelectorInput.pressKeys(Key.ESCAPE);
597+
594598
await this.testSubjects.click('basePrivilege_all');
595599
await this.testSubjects.click('createSpacePrivilegeButton');
596600

597-
const addPrivilege = (privileges: string[]) => {
601+
const addPrivileges = (privileges: string[]) => {
598602
return privileges.reduce((promise: Promise<any>, privilegeName: string) => {
599603
return promise
600604
.then(() => self.addPrivilegeToRole(privilegeName))
601605
.then(() => this.common.sleep(250));
602606
}, Promise.resolve());
603607
};
604-
605-
await addPrivilege(roleObj.elasticsearch.indices[0].privileges);
608+
await addPrivileges(roleObj.elasticsearch.indices[0].privileges);
606609

607610
const addGrantedField = async (fields: string[]) => {
608611
for (const entry of fields) {

0 commit comments

Comments
 (0)