Skip to content

Commit

Permalink
[Reporting] First accessibility test (elastic#104410)
Browse files Browse the repository at this point in the history
* makeAllReportingPoliciesUnmanaged -> makeAllReportingIndicesUnmanaged

* expose the reporting services on the functional services object shared with a11y

* added data-test-subjs for a11y test

* added reporting a11y test

* updated jest test

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
jloleysens and kibanamachine committed Jul 9, 2021
1 parent 889ef64 commit 537eaeb
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 6 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class ReportListingUi extends Component<Props, State> {
return (
<>
<EuiPageHeader
data-test-subj="reportingPageHeader"
bottomBorder
pageTitle={
<FormattedMessage id="xpack.reporting.listing.reportstitle" defaultMessage="Reports" />
Expand Down Expand Up @@ -375,7 +376,7 @@ class ReportListingUi extends Component<Props, State> {
}),
render: (objectTitle: string, record: Job) => {
return (
<div>
<div data-test-subj="reportingListItemObjectTitle">
<div>{objectTitle}</div>
<EuiText size="s">
<EuiTextColor color="subdued">{record.object_type}</EuiTextColor>
Expand Down
76 changes: 76 additions & 0 deletions x-pack/test/accessibility/apps/reporting.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../ftr_provider_context';

import { JOB_PARAMS_RISON_CSV_DEPRECATED } from '../../reporting_api_integration/services/fixtures';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const { common } = getPageObjects(['common']);
const retry = getService('retry');
const a11y = getService('a11y');
const testSubjects = getService('testSubjects');
const supertestWithoutAuth = getService('supertestWithoutAuth');
const reporting = getService('reporting');
const esArchiver = getService('esArchiver');
const security = getService('security');

describe('Reporting', () => {
const createReportingUser = async () => {
await security.user.create(reporting.REPORTING_USER_USERNAME, {
password: reporting.REPORTING_USER_PASSWORD,
roles: ['reporting_user', 'data_analyst', 'kibana_user'], // Deprecated: using built-in `reporting_user` role grants all Reporting privileges
full_name: 'a reporting user',
});
};

const deleteReportingUser = async () => {
await security.user.delete(reporting.REPORTING_USER_USERNAME);
};

before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/reporting/logs');
await esArchiver.load('x-pack/test/functional/es_archives/logstash_functional');

await createReportingUser();
await reporting.loginReportingUser();
});

after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/reporting/logs');
await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional');

await deleteReportingUser();
});

beforeEach(async () => {
// Add one report
await supertestWithoutAuth
.post(`/api/reporting/generate/csv`)
.auth(reporting.REPORTING_USER_USERNAME, reporting.REPORTING_USER_PASSWORD)
.set('kbn-xsrf', 'xxx')
.send({ jobParams: JOB_PARAMS_RISON_CSV_DEPRECATED })
.expect(200);

await retry.waitFor('Reporting app', async () => {
await common.navigateToApp('reporting');
return testSubjects.exists('reportingPageHeader');
});
});

afterEach(async () => {
await reporting.deleteAllReports();
});

it('List reports view', async () => {
await retry.waitForWithTimeout('A reporting list item', 5000, () => {
return testSubjects.exists('reportingListItemObjectTitle');
});
await a11y.testAppSnapshot();
});
});
}
1 change: 1 addition & 0 deletions x-pack/test/accessibility/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
require.resolve('./apps/security_solution'),
require.resolve('./apps/ml_embeddables_in_dashboard'),
require.resolve('./apps/remote_clusters'),
require.resolve('./apps/reporting'),
],

pageObjects,
Expand Down
2 changes: 2 additions & 0 deletions x-pack/test/functional/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { services as kibanaFunctionalServices } from '../../../../test/functiona
import { services as kibanaApiIntegrationServices } from '../../../../test/api_integration/services';
import { services as kibanaXPackApiIntegrationServices } from '../../api_integration/services';
import { services as commonServices } from '../../common/services';
import { ReportingFunctionalProvider } from '../../reporting_functional/services';

import {
MonitoringNoDataProvider,
Expand Down Expand Up @@ -107,5 +108,6 @@ export const services = {
dashboardDrilldownPanelActions: DashboardDrilldownPanelActionsProvider,
dashboardDrilldownsManage: DashboardDrilldownsManageProvider,
dashboardPanelTimeRange: DashboardPanelTimeRangeProvider,
reporting: ReportingFunctionalProvider,
searchSessions: SearchSessionsService,
};
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function ({ getService }: FtrProviderContext) {
});

it('detects when reporting indices should be migrated due to missing ILM policy', async () => {
await reportingAPI.makeAllReportingPoliciesUnmanaged();
await reportingAPI.makeAllReportingIndicesUnmanaged();
// TODO: Remove "any" when no longer through type issue "policy_id" missing
await es.ilm.deleteLifecycle({ policy: ILM_POLICY_NAME } as any);

Expand All @@ -63,7 +63,7 @@ export default function ({ getService }: FtrProviderContext) {
});

it('detects when reporting indices should be migrated due to unmanaged indices', async () => {
await reportingAPI.makeAllReportingPoliciesUnmanaged();
await reportingAPI.makeAllReportingIndicesUnmanaged();
await supertestNoAuth
.post(`/api/reporting/generate/csv`)
.set('kbn-xsrf', 'xxx')
Expand Down
6 changes: 3 additions & 3 deletions x-pack/test/reporting_api_integration/services/scenarios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ export function createScenarios({ getService }: Pick<FtrProviderContext, 'getSer
.expect(200);
};

const makeAllReportingPoliciesUnmanaged = async () => {
log.debug('ReportingAPI.makeAllReportingPoliciesUnmanaged');
const makeAllReportingIndicesUnmanaged = async () => {
log.debug('ReportingAPI.makeAllReportingIndicesUnmanaged');
const settings: any = {
'index.lifecycle.name': null,
};
Expand Down Expand Up @@ -214,6 +214,6 @@ export function createScenarios({ getService }: Pick<FtrProviderContext, 'getSer
deleteAllReports,
checkIlmMigrationStatus,
migrateReportingIndices,
makeAllReportingPoliciesUnmanaged,
makeAllReportingIndicesUnmanaged,
};
}

0 comments on commit 537eaeb

Please sign in to comment.