Skip to content

Commit

Permalink
draft search profiler accessibility tests (elastic#62357)
Browse files Browse the repository at this point in the history
* draft search profiler accessibility tests

* added the search profiler test , data test subjects

* unskipped the test

* added another test to open-close the shard details dropdown

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
rashmivkulkarni and elasticmachine committed May 7, 2020
1 parent ca05440 commit b1f35fc
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const ShardDetails = ({ index, shard, operations }: Props) => {
<EuiLink
className="prfDevTool__profileTree__shardDetails"
onClick={() => setShardVisibility(!shardVisibility)}
data-test-subj="openCloseShardDetails"
>
<EuiIcon type={shardVisibility ? 'arrowDown' : 'arrowRight'} />[{shard.id[0]}][
{shard.id[2]}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export const ShardDetailsTreeNode = ({ operation, index, shard }: Props) => {
</EuiCodeBlock>
<EuiLink
type="button"
data-test-subj="viewShardDetails"
onClick={() => highlight({ indexName: index.name, operation, shard })}
>
{i18n.translate('xpack.searchProfiler.profileTree.body.viewDetailsLabel', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const SearchProfilerTabs = ({ activeTab, activateTab, has }: Props) => {
return (
<EuiTabs>
<EuiTab
data-test-subj="queryProfileTab"
isSelected={activeTab === 'searches'}
disabled={!has.searches}
onClick={() => activateTab('searches')}
Expand All @@ -33,6 +34,7 @@ export const SearchProfilerTabs = ({ activeTab, activateTab, has }: Props) => {
})}
</EuiTab>
<EuiTab
data-test-subj="aggregationProfileTab"
isSelected={activeTab === 'aggregations'}
disabled={!has.aggregations}
onClick={() => activateTab('aggregations')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,12 @@ export const ProfileQueryEditor = memo(() => {
<EuiSpacer size="s" />
</EuiFlexItem>
<EuiFlexItem grow={5}>
<EuiButton fill disabled={!licenseEnabled} onClick={() => handleProfileClick()}>
<EuiButton
data-test-subj="profileButton"
fill
disabled={!licenseEnabled}
onClick={() => handleProfileClick()}
>
<EuiText>
{i18n.translate('xpack.searchProfiler.formProfileButtonLabel', {
defaultMessage: 'Profile',
Expand Down
93 changes: 93 additions & 0 deletions x-pack/test/accessibility/apps/search_profiler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../ftr_provider_context';

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

describe('Accessibility Search Profiler Editor', () => {
before(async () => {
await PageObjects.common.navigateToApp('searchProfiler');
await a11y.testAppSnapshot();
expect(await testSubjects.exists('searchProfilerEditor')).to.be(true);
});

it('input the JSON in the aceeditor', async () => {
const input = {
query: {
bool: {
should: [
{
match: {
name: 'fred',
},
},
{
terms: {
name: ['sue', 'sally'],
},
},
],
},
},
aggs: {
stats: {
stats: {
field: 'price',
},
},
},
};

await aceEditor.setValue('searchProfilerEditor', JSON.stringify(input));
await a11y.testAppSnapshot();
});

it('click on the profile button', async () => {
await testSubjects.click('profileButton');
await a11y.testAppSnapshot();
});

it('click on the dropdown link', async () => {
const viewShardDetailslink = await testSubjects.findAll('viewShardDetails');
await viewShardDetailslink[0].click();
await a11y.testAppSnapshot();
});

it('click on the open-close shard details link', async () => {
const openShardDetailslink = await testSubjects.findAll('openCloseShardDetails');
await openShardDetailslink[0].click();
await a11y.testAppSnapshot();
});

it('close the fly out', async () => {
await flyout.ensureAllClosed();
await a11y.testAppSnapshot();
});

it('click on the Aggregation Profile link', async () => {
await testSubjects.click('aggregationProfileTab');
await a11y.testAppSnapshot();
});

it('click on the view details link', async () => {
const viewShardDetailslink = await testSubjects.findAll('viewShardDetails');
await viewShardDetailslink[0].click();
await a11y.testAppSnapshot();
});

it('close the fly out', async () => {
await flyout.ensureAllClosed();
await a11y.testAppSnapshot();
});
});
}
2 changes: 2 additions & 0 deletions x-pack/test/accessibility/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ export default async function({ readConfigFile }: FtrConfigProviderContext) {

return {
...functionalConfig.getAll(),

testFiles: [
require.resolve('./apps/login_page'),
require.resolve('./apps/home'),
require.resolve('./apps/grok_debugger'),
require.resolve('./apps/search_profiler'),
],
pageObjects,
services,
Expand Down

0 comments on commit b1f35fc

Please sign in to comment.