Skip to content

Commit

Permalink
[Upgrade Assistant] Add a11y tests for es deprecation flyouts (elasti…
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonelizabeth authored and sabarasaba committed Oct 26, 2021
1 parent 54c295d commit 3581826
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export const DefaultDeprecationFlyout = ({
<>
<EuiFlyoutHeader hasBorder>
<EuiTitle size="s" data-test-subj="flyoutTitle">
<h2>{message}</h2>
<h2 id="defaultDeprecationDetailsFlyoutTitle" className="eui-textBreakWord">
{message}
</h2>
</EuiTitle>
{index && (
<EuiText data-test-subj="flyoutDescription">
Expand All @@ -74,7 +76,7 @@ export const DefaultDeprecationFlyout = ({
</EuiFlyoutHeader>
<EuiFlyoutBody>
<EuiText>
<p>{details}</p>
<p className="eui-textBreakWord">{details}</p>
<p>
<EuiLink target="_blank" href={url}>
{i18nTexts.learnMoreLinkLabel}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const RemoveIndexSettingsFlyout = ({
<>
<EuiFlyoutHeader hasBorder>
<EuiTitle size="s" data-test-subj="flyoutTitle">
<h2>{message}</h2>
<h2 id="indexSettingsDetailsFlyoutTitle">{message}</h2>
</EuiTitle>
<EuiText>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export const FixSnapshotsFlyout = ({
<>
<EuiFlyoutHeader hasBorder>
<EuiTitle size="s" data-test-subj="flyoutTitle">
<h2>{i18nTexts.flyoutTitle}</h2>
<h2 id="mlSnapshotDetailsFlyoutTitle">{i18nTexts.flyoutTitle}</h2>
</EuiTitle>
</EuiFlyoutHeader>
<EuiFlyoutBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export const ReindexFlyout: React.FunctionComponent<ReindexFlyoutProps> = ({
<>
<EuiFlyoutHeader hasBorder>
<EuiTitle size="s" data-test-subj="flyoutTitle">
<h2>
<h2 id="reindexDetailsFlyoutTitle">
<FormattedMessage
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.flyoutHeader"
defaultMessage="Reindex {index}"
Expand Down
86 changes: 68 additions & 18 deletions x-pack/test/accessibility/apps/upgrade_assistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,31 @@ const translogSettingsIndexDeprecation: IndicesCreateRequest = {
},
};

const multiFieldsIndexDeprecation: IndicesCreateRequest = {
index: 'nested_multi_fields',
body: {
mappings: {
properties: {
text: {
type: 'text',
fields: {
english: {
type: 'text',
analyzer: 'english',
fields: {
english: {
type: 'text',
analyzer: 'english',
},
},
},
},
},
},
},
},
};

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['upgradeAssistant', 'common']);
const a11y = getService('a11y');
Expand All @@ -31,21 +56,22 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
before(async () => {
await PageObjects.upgradeAssistant.navigateToPage();
try {
// Create an index that will trigger a deprecation warning to test the ES deprecations page
// Create two indices that will trigger deprecation warnings to test the ES deprecations page
await es.indices.create(multiFieldsIndexDeprecation);
await es.indices.create(translogSettingsIndexDeprecation);
} catch (e) {
log.debug('[Setup error] Error creating index');
log.debug('[Setup error] Error creating indices');
throw e;
}
});

after(async () => {
try {
await es.indices.delete({
index: [translogSettingsIndexDeprecation.index],
index: [multiFieldsIndexDeprecation.index, translogSettingsIndexDeprecation.index],
});
} catch (e) {
log.debug('[Cleanup error] Error deleting index');
log.debug('[Cleanup error] Error deleting indices');
throw e;
}
});
Expand All @@ -57,22 +83,46 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await a11y.testAppSnapshot();
});

it('Elasticsearch deprecations page', async () => {
await PageObjects.common.navigateToUrl(
'management',
'stack/upgrade_assistant/es_deprecations',
{
ensureCurrentUrl: false,
shouldLoginIfPrompted: false,
shouldUseHashForSubUrl: false,
}
);

await retry.waitFor('Elasticsearch deprecations table to be visible', async () => {
return testSubjects.exists('esDeprecationsTable');
describe('Elasticsearch deprecations page', () => {
beforeEach(async () => {
await PageObjects.common.navigateToUrl(
'management',
'stack/upgrade_assistant/es_deprecations',
{
ensureCurrentUrl: false,
shouldLoginIfPrompted: false,
shouldUseHashForSubUrl: false,
}
);

await retry.waitFor('Elasticsearch deprecations table to be visible', async () => {
return testSubjects.exists('esDeprecationsTable');
});
});

await a11y.testAppSnapshot();
it('Deprecations table', async () => {
await a11y.testAppSnapshot();
});

it('Index settings deprecation flyout', async () => {
await PageObjects.upgradeAssistant.clickEsDeprecation(
'indexSettings' // An index setting deprecation was added in the before() hook so should be guaranteed
);
await retry.waitFor('ES index settings deprecation flyout to be visible', async () => {
return testSubjects.exists('indexSettingsDetails');
});
await a11y.testAppSnapshot();
});

it('Default deprecation flyout', async () => {
await PageObjects.upgradeAssistant.clickEsDeprecation(
'default' // A default deprecation was added in the before() hook so should be guaranteed
);
await retry.waitFor('ES default deprecation flyout to be visible', async () => {
return testSubjects.exists('defaultDeprecationDetails');
});
await a11y.testAppSnapshot();
});
});

describe('Kibana deprecations page', () => {
Expand Down
13 changes: 13 additions & 0 deletions x-pack/test/functional/page_objects/upgrade_assistant_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,17 @@ export class UpgradeAssistantPageObject extends FtrService {
this.log.debug('Unable to find selected deprecation row');
}
}

async clickEsDeprecation(deprecationType: 'indexSettings' | 'default' | 'reindex' | 'ml') {
const table = await this.testSubjects.find('esDeprecationsTable');
const deprecationIssueLink = await (
await table.findByTestSubject(`${deprecationType}TableCell-message`)
).findByCssSelector('button');

if (deprecationIssueLink) {
await deprecationIssueLink.click();
} else {
this.log.debug('Unable to find selected deprecation');
}
}
}

0 comments on commit 3581826

Please sign in to comment.