Skip to content

Commit

Permalink
Fix failing applications navigation test (elastic#168302)
Browse files Browse the repository at this point in the history
fix [elastic#166677 ](elastic#166677) 

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
2 people authored and dej611 committed Oct 17, 2023
1 parent 3a40191 commit 4d00760
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions test/plugin_functional/test_suites/core_plugins/applications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ import expect from '@kbn/expect';
import { PluginFunctionalProviderContext } from '../../services';

export default function ({ getService, getPageObjects }: PluginFunctionalProviderContext) {
const PageObjects = getPageObjects(['common']);

const PageObjects = getPageObjects(['common', 'header']);
const browser = getService('browser');
const appsMenu = getService('appsMenu');
const testSubjects = getService('testSubjects');
const find = getService('find');
const retry = getService('retry');
const deployment = getService('deployment');
const esArchiver = getService('esArchiver');
const log = getService('log');

function waitUntilLoadingIsDone() {
return PageObjects.header.waitUntilLoadingHasFinished();
}

const loadingScreenNotShown = async () =>
expect(await testSubjects.exists('kbnLoadingMessage')).to.be(false);
Expand All @@ -38,19 +42,28 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide
search,
});

async function navigateToAppFromAppsMenu(title: string) {
await retry.try(async () => {
await appsMenu.clickLink(title);
await waitUntilLoadingIsDone();
});
}

/** Use retry logic to make URL assertions less flaky */
const waitForUrlToBe = (pathname?: string, search?: string) => {
const expectedUrl = getKibanaUrl(pathname, search);
return retry.waitFor(`Url to be ${expectedUrl}`, async () => {
return (await browser.getCurrentUrl()) === expectedUrl;
const currentUrl = await browser.getCurrentUrl();
if (currentUrl !== expectedUrl)
log.debug(`expected url to be ${expectedUrl}, got ${currentUrl}`);
return currentUrl === expectedUrl;
});
};

const navigateTo = async (path: string) =>
await browser.navigateTo(`${deployment.getHostPort()}${path}`);

// Failing: See https://github.com/elastic/kibana/issues/166677
describe.skip('ui applications', function describeIndexTests() {
describe('ui applications', function describeIndexTests() {
before(async () => {
await esArchiver.emptyKibanaIndex();
await PageObjects.common.navigateToApp('foo');
Expand Down Expand Up @@ -92,9 +105,12 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide
});

it('navigates to app root when navlink is clicked', async () => {
await appsMenu.clickLink('Foo');
await testSubjects.click('fooNavHome');

navigateToAppFromAppsMenu('Foo');

await waitForUrlToBe('/app/foo/home');
// await loadingScreenNotShown();
await loadingScreenNotShown();
await testSubjects.existOrFail('fooAppHome');
});

Expand Down

0 comments on commit 4d00760

Please sign in to comment.