Skip to content

Commit

Permalink
[7.x] [Upgrade Assistant] Fixes to Upgrade Assistant Tests and Page O…
Browse files Browse the repository at this point in the history
…bjects To Stop CI Failures (#89942) (#90387)

* [Upgrade Assistant] Fixes to Upgrade Assistant Tests and Page Objects To Stop CI Failures (#89942)

* Updated test to use no hard coded waits which could be contributing to CI failures. Expect functions should be in the test file itself so I changed the page objects for page actions and extracted out the expect calls to the test files.

* Added retry within the test file to retry the assertion if it doesn't pass on the first attempt. Simplified the toggle function to just click the toggle.

* Fixed type check issue.

Co-authored-by: Kibana Machine <[email protected]>
# Conflicts:
#	x-pack/test/functional/apps/upgrade_assistant/upgrade_assistant.ts

* Removed an unused reference to security.
  • Loading branch information
John Dorlus authored Feb 5, 2021
1 parent 43591ca commit a22d189
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 44 deletions.
40 changes: 31 additions & 9 deletions x-pack/test/functional/apps/upgrade_assistant/upgrade_assistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,67 @@
* 2.0.
*/

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

export default function upgradeAssistantFunctionalTests({
getService,
getPageObjects,
}: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const PageObjects = getPageObjects(['upgradeAssistant']);
const PageObjects = getPageObjects(['upgradeAssistant', 'common']);
const log = getService('log');
const retry = getService('retry');

describe('Upgrade Checkup', function () {
this.tags('includeFirefox');
before(async () => await esArchiver.load('empty_kibana'));
after(async () => {
await PageObjects.upgradeAssistant.expectTelemetryHasFinish();
await PageObjects.upgradeAssistant.waitForTelemetryHidden();
await esArchiver.unload('empty_kibana');
});

it('allows user to navigate to upgrade checkup', async () => {
await PageObjects.upgradeAssistant.navigateToPage();
await PageObjects.upgradeAssistant.expectUpgradeAssistant();
});

it('allows user to toggle deprecation logging', async () => {
await PageObjects.upgradeAssistant.navigateToPage();
await PageObjects.upgradeAssistant.expectDeprecationLoggingLabel('On');
await PageObjects.upgradeAssistant.toggleDeprecationLogging();
await PageObjects.upgradeAssistant.expectDeprecationLoggingLabel('Off');
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');
});
});

it('allows user to open cluster tab', async () => {
await PageObjects.upgradeAssistant.navigateToPage();
await PageObjects.upgradeAssistant.clickTab('cluster');
await PageObjects.upgradeAssistant.expectIssueSummary('You have no cluster issues.');
expect(await PageObjects.upgradeAssistant.issueSummaryText()).to.be(
'You have no cluster issues.'
);
});

it('allows user to open indices tab', async () => {
await PageObjects.upgradeAssistant.navigateToPage();
await PageObjects.upgradeAssistant.clickTab('indices');
await PageObjects.upgradeAssistant.expectIssueSummary('You have no index issues.');
expect(await PageObjects.upgradeAssistant.issueSummaryText()).to.be(
'You have no index issues.'
);
});
});
}
65 changes: 30 additions & 35 deletions x-pack/test/functional/page_objects/upgrade_assistant_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* 2.0.
*/

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

export function UpgradeAssistantPageProvider({ getPageObjects, getService }: FtrProviderContext) {
Expand All @@ -25,34 +24,32 @@ export function UpgradeAssistantPageProvider({ getPageObjects, getService }: Ftr
return await retry.try(async () => {
await common.navigateToApp('settings');
await testSubjects.click('upgrade_assistant');
retry.waitFor('url to contain /upgrade_assistant', async () => {
const url = await browser.getCurrentUrl();
return url.includes('/upgrade_assistant');
});
});
}

async expectUpgradeAssistant() {
return await retry.try(async () => {
log.debug(`expectUpgradeAssistant()`);
expect(await testSubjects.exists('upgradeAssistantRoot')).to.equal(true);
const url = await browser.getCurrentUrl();
expect(url).to.contain(`/upgrade_assistant`);
});
async toggleDeprecationLogging() {
log.debug('toggleDeprecationLogging()');
await testSubjects.click('upgradeAssistantDeprecationToggle');
}

async toggleDeprecationLogging() {
return await retry.try(async () => {
log.debug('toggleDeprecationLogging()');
await testSubjects.click('upgradeAssistantDeprecationToggle');
});
async isDeprecationLoggingEnabled() {
const isDeprecationEnabled = await testSubjects.getAttribute(
'upgradeAssistantDeprecationToggle',
'aria-checked'
);
log.debug(`Deprecation enabled == ${isDeprecationEnabled}`);
return isDeprecationEnabled === 'true';
}

async expectDeprecationLoggingLabel(labelText: string) {
return await retry.try(async () => {
log.debug('expectDeprecationLoggingLabel()');
const label = await find.byCssSelector(
'[data-test-subj="upgradeAssistantDeprecationToggle"] ~ span'
);
const value = await label.getVisibleText();
expect(value).to.equal(labelText);
});
async deprecationLoggingEnabledLabel() {
const loggingEnabledLabel = await find.byCssSelector(
'[data-test-subj="upgradeAssistantDeprecationToggle"] ~ span'
);
return await loggingEnabledLabel.getVisibleText();
}

async clickTab(tabId: string) {
Expand All @@ -62,22 +59,20 @@ export function UpgradeAssistantPageProvider({ getPageObjects, getService }: Ftr
});
}

async expectIssueSummary(summary: string) {
return await retry.try(async () => {
log.debug('expectIssueSummary()');
const summaryElText = await testSubjects.getVisibleText('upgradeAssistantIssueSummary');
expect(summaryElText).to.eql(summary);
async waitForTelemetryHidden() {
const self = this;
retry.waitFor('Telemetry to disappear.', async () => {
return (await self.isTelemetryExists()) === false;
});
}

async expectTelemetryHasFinish() {
return await retry.try(async () => {
log.debug('expectTelemetryHasFinish');
const isTelemetryFinished = !(await testSubjects.exists(
'upgradeAssistantTelemetryRunning'
));
expect(isTelemetryFinished).to.equal(true);
});
async issueSummaryText() {
log.debug('expectIssueSummary()');
return await testSubjects.getVisibleText('upgradeAssistantIssueSummary');
}

async isTelemetryExists() {
return await testSubjects.exists('upgradeAssistantTelemetryRunning');
}
}

Expand Down

0 comments on commit a22d189

Please sign in to comment.