Skip to content

Commit

Permalink
Fix flaky user activation/deactivation tests (#132465)
Browse files Browse the repository at this point in the history
  • Loading branch information
legrego authored May 19, 2022
1 parent 5d5603a commit 895e425
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
3 changes: 1 addition & 2 deletions x-pack/test/functional/apps/security/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
});

// FLAKY: https://github.com/elastic/kibana/issues/118728
describe.skip('Deactivate/Activate user', () => {
describe('Deactivate/Activate user', () => {
it('deactivates user when confirming', async () => {
await PageObjects.security.deactivatesUser(optionalUser);
const users = keyBy(await PageObjects.security.getElasticsearchUsers(), 'username');
Expand Down
22 changes: 15 additions & 7 deletions x-pack/test/functional/page_objects/security_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class SecurityPageObject extends FtrService {
private readonly common = this.ctx.getPageObject('common');
private readonly header = this.ctx.getPageObject('header');
private readonly monacoEditor = this.ctx.getService('monacoEditor');
private readonly es = this.ctx.getService('es');

public loginPage = Object.freeze({
login: async (username?: string, password?: string, options: LoginOptions = {}) => {
Expand Down Expand Up @@ -350,13 +351,6 @@ export class SecurityPageObject extends FtrService {

const btn = await this.find.byButtonText(privilege);
await btn.click();

// const options = await this.find.byCssSelector(`.euiFilterSelectItem`);
// Object.entries(options).forEach(([key, prop]) => {
// console.log({ key, proto: prop.__proto__ });
// });

// await options.click();
}

async assignRoleToUser(role: string) {
Expand Down Expand Up @@ -516,13 +510,27 @@ export class SecurityPageObject extends FtrService {
await this.clickUserByUserName(user.username ?? '');
await this.testSubjects.click('editUserDisableUserButton');
await this.testSubjects.click('confirmModalConfirmButton');
await this.testSubjects.missingOrFail('confirmModalConfirmButton');
if (user.username) {
await this.retry.waitForWithTimeout('ES to acknowledge deactivation', 15000, async () => {
const userResponse = await this.es.security.getUser({ username: user.username });
return userResponse[user.username!].enabled === false;
});
}
await this.submitUpdateUserForm();
}

async activatesUser(user: UserFormValues) {
await this.clickUserByUserName(user.username ?? '');
await this.testSubjects.click('editUserEnableUserButton');
await this.testSubjects.click('confirmModalConfirmButton');
await this.testSubjects.missingOrFail('confirmModalConfirmButton');
if (user.username) {
await this.retry.waitForWithTimeout('ES to acknowledge activation', 15000, async () => {
const userResponse = await this.es.security.getUser({ username: user.username });
return userResponse[user.username!].enabled === true;
});
}
await this.submitUpdateUserForm();
}

Expand Down

0 comments on commit 895e425

Please sign in to comment.