Skip to content

Commit

Permalink
refactor a11y tests to group by data sets (#113876) (#114134)
Browse files Browse the repository at this point in the history
* test if 2s sleep fixes flakey test

* switch from sleep to retry.waitFor

* remove .only, add comments to config file about sample data add/remove

* refactor a11y tests for sample data load

* refactor a11y tests for sample data load

* cleanup comments

* cleanup comments

* fix eslint errors

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Lee Drengenberg <[email protected]>
  • Loading branch information
kibanamachine and Lee Drengenberg authored Oct 6, 2021
1 parent c65ef90 commit c9246ef
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 92 deletions.
15 changes: 0 additions & 15 deletions test/accessibility/apps/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const dashboardName = 'Dashboard Listing A11y';
const clonedDashboardName = 'Dashboard Listing A11y Copy';

before(async () => {
await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', {
useActualUrl: true,
});
await PageObjects.home.addSampleDataSet('flights');
});

after(async () => {
await PageObjects.common.navigateToApp('dashboard');
await listingTable.searchForItemWithName(dashboardName);
await listingTable.checkListingSelectAllCheckbox();
await listingTable.clickDeleteSelected();
await PageObjects.common.clickConfirmOnModal();
});

it('dashboard', async () => {
await PageObjects.common.navigateToApp('dashboard');
await a11y.testAppSnapshot();
Expand Down
5 changes: 0 additions & 5 deletions test/accessibility/apps/dashboard_panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
// FLAKY: https://github.com/elastic/kibana/issues/112920
describe.skip('Dashboard Panel', () => {
before(async () => {
await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', {
useActualUrl: true,
});

await PageObjects.home.addSampleDataSet('flights');
await PageObjects.common.navigateToApp('dashboard');
await testSubjects.click('dashboardListingTitleLink-[Flights]-Global-Flight-Dashboard');
});
Expand Down
17 changes: 2 additions & 15 deletions test/accessibility/apps/discover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,14 @@ import { FtrProviderContext } from '../ftr_provider_context';
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['common', 'discover', 'header', 'share', 'timePicker']);
const a11y = getService('a11y');
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const inspector = getService('inspector');
const testSubjects = getService('testSubjects');
const TEST_COLUMN_NAMES = ['extension', 'geo.src'];
const TEST_COLUMN_NAMES = ['dayOfWeek', 'DestWeather'];

describe('Discover a11y tests', () => {
before(async () => {
await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional');
await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover');
await kibanaServer.uiSettings.update({
defaultIndex: 'logstash-*',
'doc_table:legacy': true,
});
await PageObjects.common.navigateToApp('discover');
await PageObjects.timePicker.setDefaultAbsoluteRange();
});

after(async () => {
await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover');
await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional');
await PageObjects.timePicker.setCommonlyUsedTime('Last_7 days');
});

it('Discover main page', async () => {
Expand Down
4 changes: 0 additions & 4 deletions test/accessibility/apps/filter_panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

describe('Filter panel', () => {
before(async () => {
await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', {
useActualUrl: true,
});
await PageObjects.home.addSampleDataSet('flights');
await PageObjects.common.navigateToApp('discover');
await PageObjects.discover.selectIndexPattern('kibana_sample_data_flights');
});
Expand Down
5 changes: 0 additions & 5 deletions test/accessibility/apps/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,5 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
await a11y.testAppSnapshot();
});

it('Add flights sample data set', async () => {
await PageObjects.home.addSampleDataSet('flights');
await a11y.testAppSnapshot();
});
});
}
49 changes: 49 additions & 0 deletions test/accessibility/apps/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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 { FtrProviderContext } from '../ftr_provider_context';

export default function ({ getService, loadTestFile, getPageObjects }: FtrProviderContext) {
const kibanaServer = getService('kibanaServer');
const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'home', 'settings']);

describe('a11y tests', function () {
describe('using flights sample data', function () {
before(async () => {
await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', {
useActualUrl: true,
});
await PageObjects.home.addSampleDataSet('flights');
});

after(async () => {
await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', {
useActualUrl: true,
});
await PageObjects.home.removeSampleDataSet('flights');
await kibanaServer.savedObjects.clean({
types: ['search', 'index-pattern', 'visualization', 'dashboard'],
});
});

loadTestFile(require.resolve('./dashboard'));
loadTestFile(require.resolve('./dashboard_panel'));
loadTestFile(require.resolve('./filter_panel'));
loadTestFile(require.resolve('./home'));
loadTestFile(require.resolve('./discover'));
loadTestFile(require.resolve('./visualize'));
loadTestFile(require.resolve('./kibana_overview_with_data'));
});

describe('not using sample data', function () {
loadTestFile(require.resolve('./management'));
loadTestFile(require.resolve('./console'));
loadTestFile(require.resolve('./kibana_overview_without_data'));
});
});
}
21 changes: 21 additions & 0 deletions test/accessibility/apps/kibana_overview_with_data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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 { FtrProviderContext } from '../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['common', 'home']);
const a11y = getService('a11y');

describe('Kibana overview with data', () => {
it('Overview view', async () => {
await PageObjects.common.navigateToApp('kibanaOverview');
await a11y.testAppSnapshot();
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const a11y = getService('a11y');

describe('Kibana overview', () => {
const esArchiver = getService('esArchiver');

before(async () => {
await esArchiver.emptyKibanaIndex();
await PageObjects.common.navigateToApp('kibanaOverview');
});

after(async () => {
await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', {
useActualUrl: true,
});
await PageObjects.home.removeSampleDataSet('flights');
});

it('Getting started view', async () => {
await a11y.testAppSnapshot();
});

it('Overview view', async () => {
await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', {
useActualUrl: true,
});
await PageObjects.home.addSampleDataSet('flights');
await PageObjects.common.navigateToApp('kibanaOverview');
await a11y.testAppSnapshot();
});
Expand Down
10 changes: 0 additions & 10 deletions test/accessibility/apps/visualize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,8 @@ import { FtrProviderContext } from '../ftr_provider_context';
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['common', 'visualize', 'header']);
const a11y = getService('a11y');
const kibanaServer = getService('kibanaServer');

describe('Visualize', () => {
before(async () => {
await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover');
await PageObjects.common.navigateToApp('visualize');
});

after(async () => {
await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover');
});

it('visualize', async () => {
await a11y.testAppSnapshot();
});
Expand Down
17 changes: 1 addition & 16 deletions test/accessibility/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {

return {
...functionalConfig.getAll(),

testFiles: [
// these 5 tests all load addSampleDataSet('flights')
// only the last test does removeSampleDataSet('flights')
require.resolve('./apps/dashboard'),
require.resolve('./apps/dashboard_panel'),
require.resolve('./apps/filter_panel'),
require.resolve('./apps/home'),
require.resolve('./apps/kibana_overview'),

// next tests don't use sample data
require.resolve('./apps/discover'),
require.resolve('./apps/visualize'),
require.resolve('./apps/management'),
require.resolve('./apps/console'),
],
testFiles: [require.resolve('./apps')],
pageObjects,
services,

Expand Down

0 comments on commit c9246ef

Please sign in to comment.