[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 <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
06bc99d825
commit
14cf1875b5
|
@ -4,6 +4,7 @@
|
|||
* 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 upgradeAssistantFunctionalTests({
|
||||
|
@ -14,6 +15,7 @@ export default function upgradeAssistantFunctionalTests({
|
|||
const PageObjects = getPageObjects(['upgradeAssistant', 'common']);
|
||||
const security = getService('security');
|
||||
const log = getService('log');
|
||||
const retry = getService('retry');
|
||||
|
||||
describe('Upgrade Checkup', function () {
|
||||
this.tags('includeFirefox');
|
||||
|
@ -24,41 +26,52 @@ export default function upgradeAssistantFunctionalTests({
|
|||
});
|
||||
|
||||
after(async () => {
|
||||
await PageObjects.upgradeAssistant.expectTelemetryHasFinish();
|
||||
await PageObjects.upgradeAssistant.waitForTelemetryHidden();
|
||||
await esArchiver.unload('empty_kibana');
|
||||
await security.testUser.restoreDefaults();
|
||||
});
|
||||
|
||||
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();
|
||||
log.debug('expect initial state to be ON');
|
||||
await PageObjects.upgradeAssistant.expectDeprecationLoggingLabel('On');
|
||||
log.debug('Now toggle to off');
|
||||
await PageObjects.upgradeAssistant.toggleDeprecationLogging();
|
||||
await PageObjects.common.sleep(2000);
|
||||
log.debug('expect state to be OFF after toggle');
|
||||
await PageObjects.upgradeAssistant.expectDeprecationLoggingLabel('Off');
|
||||
await PageObjects.upgradeAssistant.toggleDeprecationLogging();
|
||||
await PageObjects.common.sleep(2000);
|
||||
log.debug('expect state to be ON after toggle');
|
||||
await PageObjects.upgradeAssistant.expectDeprecationLoggingLabel('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.'
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
* 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 function UpgradeAssistantPageProvider({ getPageObjects, getService }: FtrProviderContext) {
|
||||
|
@ -24,34 +23,32 @@ export function UpgradeAssistantPageProvider({ getPageObjects, getService }: Ftr
|
|||
return await retry.try(async () => {
|
||||
await common.navigateToApp('settings');
|
||||
await testSubjects.click('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`);
|
||||
retry.waitFor('url to contain /upgrade_assistant', async () => {
|
||||
const url = await browser.getCurrentUrl();
|
||||
return url.includes('/upgrade_assistant');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async toggleDeprecationLogging() {
|
||||
return await retry.try(async () => {
|
||||
log.debug('toggleDeprecationLogging()');
|
||||
await testSubjects.click('upgradeAssistantDeprecationToggle');
|
||||
});
|
||||
log.debug('toggleDeprecationLogging()');
|
||||
await testSubjects.click('upgradeAssistantDeprecationToggle');
|
||||
}
|
||||
|
||||
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 isDeprecationLoggingEnabled() {
|
||||
const isDeprecationEnabled = await testSubjects.getAttribute(
|
||||
'upgradeAssistantDeprecationToggle',
|
||||
'aria-checked'
|
||||
);
|
||||
log.debug(`Deprecation enabled == ${isDeprecationEnabled}`);
|
||||
return isDeprecationEnabled === 'true';
|
||||
}
|
||||
|
||||
async deprecationLoggingEnabledLabel() {
|
||||
const loggingEnabledLabel = await find.byCssSelector(
|
||||
'[data-test-subj="upgradeAssistantDeprecationToggle"] ~ span'
|
||||
);
|
||||
return await loggingEnabledLabel.getVisibleText();
|
||||
}
|
||||
|
||||
async clickTab(tabId: string) {
|
||||
|
@ -61,22 +58,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');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue