Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draft search profiler accessibility tests #62357

Merged
merged 11 commits into from
May 7, 2020
Merged
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();
});

rashmivkulkarni marked this conversation as resolved.
Show resolved Hide resolved
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