-
Notifications
You must be signed in to change notification settings - Fork 8k
/
flyout.ts
47 lines (42 loc) · 1.84 KB
/
flyout.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { FtrService } from '../ftr_provider_context';
export class FlyoutService extends FtrService {
private readonly testSubjects = this.ctx.getService('testSubjects');
private readonly find = this.ctx.getService('find');
private readonly log = this.ctx.getService('log');
private readonly retry = this.ctx.getService('retry');
public async close(dataTestSubj: string): Promise<void> {
this.log.debug('Closing flyout', dataTestSubj);
const flyoutElement = await this.testSubjects.find(dataTestSubj);
await this.retry.try(async () => {
const closeBtn = await flyoutElement.findByCssSelector('[aria-label*="Close"]');
await closeBtn.click();
await this.testSubjects.missingOrFail(dataTestSubj);
});
}
public async ensureClosed(dataTestSubj: string): Promise<void> {
if (await this.testSubjects.exists(dataTestSubj, { timeout: 1000 })) {
await this.close(dataTestSubj);
}
}
public async ensureAllClosed(): Promise<void> {
await this.retry.waitFor('all flyouts to be closed', async () => {
let flyoutElements = await this.find.allByCssSelector('.euiFlyout', 2500);
if (!flyoutElements.length) {
return true;
}
for (let i = 0; i < flyoutElements.length; i++) {
const closeBtn = await flyoutElements[i].findByCssSelector('[aria-label*="Close"]');
await closeBtn.click();
}
flyoutElements = await this.find.allByCssSelector('.euiFlyout', 500);
return flyoutElements.length === 0;
});
}
}