Unskip download csv permissions test (#173660)

## Summary


close https://github.com/elastic/kibana/issues/172599


I couldn't reproduce the failure, looks like it is very rare. But when
reviewing the code I noticed possible race conditions and refactored.
Suggest we merge the refactor and observe.

Before fix
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4647
100x passed - means flakiness hard to reproduce
After fix
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4649
50x passed - still stable
This commit is contained in:
Anton Dosov 2023-12-21 11:44:05 +01:00 committed by GitHub
parent 4f186d0cc5
commit 7fe9faea3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 30 deletions

View file

@ -44,12 +44,10 @@ export class ReportingCsvPanelAction implements ActionDefinition<ActionContext>
private isDownloading: boolean;
public readonly type = '';
public readonly id = CSV_REPORTING_ACTION;
private licenseHasDownloadCsv: boolean = false;
private capabilityHasDownloadCsv: boolean = false;
private notifications: NotificationsSetup;
private apiClient: ReportingAPIClient;
private startServices$: Params['startServices$'];
private usesUiCapabilities: any;
private readonly notifications: NotificationsSetup;
private readonly apiClient: ReportingAPIClient;
private readonly startServices$: Params['startServices$'];
private readonly usesUiCapabilities: boolean;
constructor({ core, apiClient, startServices$, usesUiCapabilities }: Params) {
this.isDownloading = false;
@ -78,34 +76,23 @@ export class ReportingCsvPanelAction implements ActionDefinition<ActionContext>
}
public isCompatible = async (context: ActionContext) => {
await new Promise<void>((resolve) => {
this.startServices$.subscribe(([{ application }, { licensing }]) => {
licensing.license$.subscribe((license) => {
const results = license.check('reporting', 'basic');
const { showLinks } = checkLicense(results);
this.licenseHasDownloadCsv = showLinks;
});
if (this.usesUiCapabilities) {
this.capabilityHasDownloadCsv = application.capabilities.dashboard?.downloadCsv === true;
} else {
this.capabilityHasDownloadCsv = true; // deprecated
}
resolve();
});
});
if (!this.licenseHasDownloadCsv || !this.capabilityHasDownloadCsv) {
return false;
}
const { embeddable } = context;
if (embeddable.type !== 'search') {
return false;
}
const [{ application }, { licensing }] = await firstValueFrom(this.startServices$);
const license = await firstValueFrom(licensing.license$);
const licenseHasDownloadCsv = checkLicense(license.check('reporting', 'basic')).showLinks;
const capabilityHasDownloadCsv = this.usesUiCapabilities
? application.capabilities.dashboard?.downloadCsv === true
: true; // deprecated
if (!licenseHasDownloadCsv || !capabilityHasDownloadCsv) {
return false;
}
const savedSearch = embeddable.getSavedSearch();
const query = savedSearch?.searchSource.getField('query');

View file

@ -16,8 +16,7 @@ const CANVAS_TITLE = 'The Very Cool Workpad for PDF Tests';
export default function ({ getService }: FtrProviderContext) {
const reportingFunctional = getService('reportingFunctional');
// FLAKY: https://github.com/elastic/kibana/issues/172599
describe.skip('Security with `reporting_user` built-in role', () => {
describe('Security with `reporting_user` built-in role', () => {
before(async () => {
await reportingFunctional.initEcommerce();
});