From 0f451a577b268c3f65eda235713bec3978400b91 Mon Sep 17 00:00:00 2001 From: Alison Goryachev Date: Tue, 31 Aug 2021 12:01:00 -0400 Subject: [PATCH] [Upgrade Assistant] Enable functional and a11y tests (#109909) --- .../es_deprecations/es_deprecations_table.tsx | 2 +- .../components/overview/overview.tsx | 2 +- .../accessibility/apps/upgrade_assistant.ts | 124 +++++++++--------- .../upgrade_assistant_security.ts | 6 - .../apps/upgrade_assistant/index.ts | 2 +- .../upgrade_assistant/upgrade_assistant.ts | 114 +++++++++------- x-pack/test/functional/config.js | 6 + .../page_objects/upgrade_assistant_page.ts | 43 +----- 8 files changed, 148 insertions(+), 151 deletions(-) diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/es_deprecations_table.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/es_deprecations_table.tsx index ac92f288230f65..09105fadef2d33 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/es_deprecations_table.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/es_deprecations_table.tsx @@ -262,7 +262,7 @@ export const EsDeprecationsTable: React.FunctionComponent = ({ - + {Object.entries(cellToLabelMap).map(([fieldName, cell]) => { return ( diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/overview.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/overview/overview.tsx index 4ab5109bd996c3..1c11bc165d931c 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/overview/overview.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/overview/overview.tsx @@ -58,7 +58,7 @@ export const Overview: FunctionComponent = () => { } return ( - + { + describe('Upgrade Assistant', () => { before(async () => { await PageObjects.upgradeAssistant.navigateToPage(); - }); - it('Coming soon prompt', async () => { - await retry.waitFor('Upgrade Assistant coming soon prompt to be visible', async () => { - return testSubjects.exists('comingSoonPrompt'); - }); - await a11y.testAppSnapshot(); + try { + // Create an index that will trigger a deprecation warning to test the ES deprecations page + await es.indices.create(translogSettingsIndexDeprecation); + } catch (e) { + log.debug('[Setup error] Error creating index'); + throw e; + } }); - // These tests will be skipped until the last minor of the next major release - describe.skip('Upgrade Assistant content', () => { - it('Overview page', async () => { - await retry.waitFor('Upgrade Assistant overview page to be visible', async () => { - return testSubjects.exists('overviewPageContent'); - }); - await a11y.testAppSnapshot(); - }); - - it('Elasticsearch cluster deprecations', async () => { - await PageObjects.common.navigateToUrl( - 'management', - 'stack/upgrade_assistant/es_deprecations/cluster', - { - ensureCurrentUrl: false, - shouldLoginIfPrompted: false, - shouldUseHashForSubUrl: false, - } - ); - - await retry.waitFor('Cluster tab to be visible', async () => { - return testSubjects.exists('clusterTabContent'); + after(async () => { + try { + await es.indices.delete({ + index: [translogSettingsIndexDeprecation.index], }); + } catch (e) { + log.debug('[Cleanup error] Error deleting index'); + throw e; + } + }); - await a11y.testAppSnapshot(); + it('Overview page', async () => { + await retry.waitFor('Upgrade Assistant overview page to be visible', async () => { + return testSubjects.exists('overview'); }); + await a11y.testAppSnapshot(); + }); - it('Elasticsearch index deprecations', async () => { - await PageObjects.common.navigateToUrl( - 'management', - 'stack/upgrade_assistant/es_deprecations/indices', - { - ensureCurrentUrl: false, - shouldLoginIfPrompted: false, - shouldUseHashForSubUrl: false, - } - ); + it('Elasticsearch deprecations page', async () => { + await PageObjects.common.navigateToUrl( + 'management', + 'stack/upgrade_assistant/es_deprecations', + { + ensureCurrentUrl: false, + shouldLoginIfPrompted: false, + shouldUseHashForSubUrl: false, + } + ); - await retry.waitFor('Indices tab to be visible', async () => { - return testSubjects.exists('indexTabContent'); - }); - - await a11y.testAppSnapshot(); + await retry.waitFor('Elasticsearch deprecations table to be visible', async () => { + return testSubjects.exists('esDeprecationsTable'); }); - it('Kibana deprecations', async () => { - await PageObjects.common.navigateToUrl( - 'management', - 'stack/upgrade_assistant/kibana_deprecations', - { - ensureCurrentUrl: false, - shouldLoginIfPrompted: false, - shouldUseHashForSubUrl: false, - } - ); + await a11y.testAppSnapshot(); + }); - await retry.waitFor('Kibana deprecations to be visible', async () => { - return testSubjects.exists('kibanaDeprecationsContent'); - }); + it('Kibana deprecations page', async () => { + await PageObjects.common.navigateToUrl( + 'management', + 'stack/upgrade_assistant/kibana_deprecations', + { + ensureCurrentUrl: false, + shouldLoginIfPrompted: false, + shouldUseHashForSubUrl: false, + } + ); - await a11y.testAppSnapshot(); + await retry.waitFor('Kibana deprecations to be visible', async () => { + return testSubjects.exists('kibanaDeprecationsContent'); }); + + await a11y.testAppSnapshot(); }); }); } diff --git a/x-pack/test/functional/apps/upgrade_assistant/feature_controls/upgrade_assistant_security.ts b/x-pack/test/functional/apps/upgrade_assistant/feature_controls/upgrade_assistant_security.ts index 3de9e252e032a6..bd5e321a1bd225 100644 --- a/x-pack/test/functional/apps/upgrade_assistant/feature_controls/upgrade_assistant_security.ts +++ b/x-pack/test/functional/apps/upgrade_assistant/feature_controls/upgrade_assistant_security.ts @@ -9,7 +9,6 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { - const esArchiver = getService('esArchiver'); const security = getService('security'); const PageObjects = getPageObjects(['common', 'settings', 'security']); const appsMenu = getService('appsMenu'); @@ -17,14 +16,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('security', function () { before(async () => { - await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await PageObjects.common.navigateToApp('home'); }); - after(async () => { - await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); - }); - describe('global all privileges (aka kibana_admin)', () => { before(async () => { await security.testUser.setRoles(['kibana_admin'], true); diff --git a/x-pack/test/functional/apps/upgrade_assistant/index.ts b/x-pack/test/functional/apps/upgrade_assistant/index.ts index c25e0af4143971..cacf55c58dce26 100644 --- a/x-pack/test/functional/apps/upgrade_assistant/index.ts +++ b/x-pack/test/functional/apps/upgrade_assistant/index.ts @@ -8,7 +8,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function upgradeCheckup({ loadTestFile }: FtrProviderContext) { - describe('Upgrade checkup ', function upgradeAssistantTestSuite() { + describe('Upgrade Assistant', function upgradeAssistantTestSuite() { this.tags('ciGroup4'); loadTestFile(require.resolve('./feature_controls')); diff --git a/x-pack/test/functional/apps/upgrade_assistant/upgrade_assistant.ts b/x-pack/test/functional/apps/upgrade_assistant/upgrade_assistant.ts index aff9ac692dabf1..4e552b6f889f63 100644 --- a/x-pack/test/functional/apps/upgrade_assistant/upgrade_assistant.ts +++ b/x-pack/test/functional/apps/upgrade_assistant/upgrade_assistant.ts @@ -5,82 +5,108 @@ * 2.0. */ -import expect from '@kbn/expect'; +import { IndicesCreateRequest } from '@elastic/elasticsearch/api/types'; import { FtrProviderContext } from '../../ftr_provider_context'; +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', + }, + }, + }, + }, + }, + }, + }, + }, +}; + +const translogSettingsIndexDeprecation: IndicesCreateRequest = { + index: 'deprecated_settings', + body: { + settings: { + 'translog.retention.size': '1b', + 'translog.retention.age': '5m', + 'index.soft_deletes.enabled': true, + }, + }, +}; + export default function upgradeAssistantFunctionalTests({ getService, getPageObjects, }: FtrProviderContext) { - const esArchiver = getService('esArchiver'); const PageObjects = getPageObjects(['upgradeAssistant', 'common']); - const log = getService('log'); const retry = getService('retry'); const security = getService('security'); const testSubjects = getService('testSubjects'); + const es = getService('es'); + const log = getService('log'); - // These tests need to be completely refactored to account for new UI - describe.skip('Upgrade Checkup', function () { + describe('Upgrade Assistant', function () { this.tags('skipFirefox'); before(async () => { - await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); await security.testUser.setRoles(['global_upgrade_assistant_role']); + + try { + // 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 indices'); + throw e; + } }); after(async () => { - await PageObjects.upgradeAssistant.waitForTelemetryHidden(); - await esArchiver.unload('x-pack/test/functional/es_archives/empty_kibana'); + try { + await es.indices.delete({ + index: [multiFieldsIndexDeprecation.index, translogSettingsIndexDeprecation.index], + }); + } catch (e) { + log.debug('[Cleanup error] Error deleting indices'); + throw e; + } + + await security.testUser.restoreDefaults(); }); - it('Overview page', async () => { + it('renders the Overview page', async () => { await PageObjects.upgradeAssistant.navigateToPage(); await retry.waitFor('Upgrade Assistant overview page to be visible', async () => { - return testSubjects.exists('comingSoonPrompt'); + return testSubjects.exists('overview'); }); }); - it.skip('allows user to navigate to upgrade checkup', async () => { + it('renders the Elasticsearch deprecations page', async () => { await PageObjects.upgradeAssistant.navigateToPage(); - }); + await PageObjects.upgradeAssistant.clickEsDeprecationsPanel(); - it.skip('allows user to toggle deprecation logging', async () => { - log.debug('expect initial state to be ON'); - expect(await PageObjects.upgradeAssistant.deprecationLoggingEnabledLabel()).to.be('On'); - expect(await PageObjects.upgradeAssistant.isDeprecationLoggingEnabled()).to.be(true); - - await retry.try(async () => { - log.debug('Now toggle to off'); - await PageObjects.upgradeAssistant.toggleDeprecationLogging(); - - log.debug('expect state to be OFF after toggle'); - expect(await PageObjects.upgradeAssistant.isDeprecationLoggingEnabled()).to.be(false); - expect(await PageObjects.upgradeAssistant.deprecationLoggingEnabledLabel()).to.be('Off'); - }); - - log.debug('Now toggle back on.'); - await retry.try(async () => { - await PageObjects.upgradeAssistant.toggleDeprecationLogging(); - log.debug('expect state to be ON after toggle'); - expect(await PageObjects.upgradeAssistant.isDeprecationLoggingEnabled()).to.be(true); - expect(await PageObjects.upgradeAssistant.deprecationLoggingEnabledLabel()).to.be('On'); + await retry.waitFor('Elasticsearch deprecations table to be visible', async () => { + return testSubjects.exists('esDeprecationsTable'); }); }); - it.skip('allows user to open cluster tab', async () => { + it('renders the Kibana deprecations page', async () => { await PageObjects.upgradeAssistant.navigateToPage(); - await PageObjects.upgradeAssistant.clickTab('cluster'); - expect(await PageObjects.upgradeAssistant.issueSummaryText()).to.be( - 'You have no cluster issues.' - ); - }); + await PageObjects.upgradeAssistant.clickKibanaDeprecationsPanel(); - it.skip('allows user to open indices tab', async () => { - await PageObjects.upgradeAssistant.navigateToPage(); - await PageObjects.upgradeAssistant.clickTab('indices'); - expect(await PageObjects.upgradeAssistant.issueSummaryText()).to.be( - 'You have no index issues.' - ); + await retry.waitFor('Kibana deprecations table to be visible', async () => { + return testSubjects.exists('kibanaDeprecationsContent'); + }); }); }); } diff --git a/x-pack/test/functional/config.js b/x-pack/test/functional/config.js index 02b492418e4fc7..1c0e4f9c2d50d2 100644 --- a/x-pack/test/functional/config.js +++ b/x-pack/test/functional/config.js @@ -448,6 +448,12 @@ export default async function ({ readConfigFile }) { global_upgrade_assistant_role: { elasticsearch: { cluster: ['manage'], + indices: [ + { + names: ['*'], + privileges: ['view_index_metadata'], + }, + ], }, kibana: [ { diff --git a/x-pack/test/functional/page_objects/upgrade_assistant_page.ts b/x-pack/test/functional/page_objects/upgrade_assistant_page.ts index 211bcbbd592190..32332620ffc595 100644 --- a/x-pack/test/functional/page_objects/upgrade_assistant_page.ts +++ b/x-pack/test/functional/page_objects/upgrade_assistant_page.ts @@ -11,7 +11,6 @@ export class UpgradeAssistantPageObject extends FtrService { private readonly retry = this.ctx.getService('retry'); private readonly log = this.ctx.getService('log'); private readonly browser = this.ctx.getService('browser'); - private readonly find = this.ctx.getService('find'); private readonly testSubjects = this.ctx.getService('testSubjects'); private readonly common = this.ctx.getPageObject('common'); @@ -30,47 +29,15 @@ export class UpgradeAssistantPageObject extends FtrService { }); } - async toggleDeprecationLogging() { - this.log.debug('toggleDeprecationLogging()'); - await this.testSubjects.click('upgradeAssistantDeprecationToggle'); - } - - async isDeprecationLoggingEnabled() { - const isDeprecationEnabled = await this.testSubjects.getAttribute( - 'upgradeAssistantDeprecationToggle', - 'aria-checked' - ); - this.log.debug(`Deprecation enabled == ${isDeprecationEnabled}`); - return isDeprecationEnabled === 'true'; - } - - async deprecationLoggingEnabledLabel() { - const loggingEnabledLabel = await this.find.byCssSelector( - '[data-test-subj="upgradeAssistantDeprecationToggle"] ~ span' - ); - return await loggingEnabledLabel.getVisibleText(); - } - - async clickTab(tabId: string) { + async clickEsDeprecationsPanel() { return await this.retry.try(async () => { - this.log.debug('clickTab()'); - await this.find.clickByCssSelector(`.euiTabs .euiTab#${tabId}`); + await this.testSubjects.click('esStatsPanel'); }); } - async waitForTelemetryHidden() { - const self = this; - await this.retry.waitFor('Telemetry to disappear.', async () => { - return (await self.isTelemetryExists()) === false; + async clickKibanaDeprecationsPanel() { + return await this.retry.try(async () => { + await this.testSubjects.click('kibanaStatsPanel'); }); } - - async issueSummaryText() { - this.log.debug('expectIssueSummary()'); - return await this.testSubjects.getVisibleText('upgradeAssistantIssueSummary'); - } - - async isTelemetryExists() { - return await this.testSubjects.exists('upgradeAssistantTelemetryRunning'); - } }