From d3266dc998a05ec3a438fad7683dad53ba511f15 Mon Sep 17 00:00:00 2001 From: WangQianliang Date: Thu, 29 Aug 2019 15:47:55 +0800 Subject: [PATCH] [Code] fix flaky functional test (#43563) (#44354) * fix(code/frontend): fix flaky functional test --- .../apps/code/explore_repository.ts | 9 +++++-- x-pack/test/functional/apps/code/file_tree.ts | 9 ++++--- x-pack/test/functional/apps/code/history.ts | 24 ++++++++++++------- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/x-pack/test/functional/apps/code/explore_repository.ts b/x-pack/test/functional/apps/code/explore_repository.ts index 2277e8e36fa36..2efdda94438ca 100644 --- a/x-pack/test/functional/apps/code/explore_repository.ts +++ b/x-pack/test/functional/apps/code/explore_repository.ts @@ -24,8 +24,7 @@ export default function exploreRepositoryFunctionalTests({ const FIND_TIME = config.get('timeouts.find'); - // FLAKY: https://github.com/elastic/kibana/issues/43557 - describe.skip('Explore Repository', function() { + describe('Explore Repository', function() { this.tags('smoke'); describe('Explore a repository', () => { const repositoryListSelector = 'codeRepositoryList codeRepositoryItem'; @@ -95,6 +94,8 @@ export default function exploreRepositoryFunctionalTests({ // open a file that does not exists const url = `${PageObjects.common.getHostPort()}/app/code#/github.com/elastic/TypeScript-Node-Starter/tree/master/I_DO_NOT_EXIST`; await browser.get(url); + await PageObjects.header.awaitKibanaChrome(); + await retry.try(async () => { const currentUrl: string = await browser.getCurrentUrl(); expect( @@ -222,6 +223,8 @@ export default function exploreRepositoryFunctionalTests({ log.debug('it goes to a deep node of file tree'); const url = `${PageObjects.common.getHostPort()}/app/code#/github.com/elastic/TypeScript-Node-Starter/blob/master/src/models/User.ts`; await browser.get(url); + await PageObjects.header.awaitKibanaChrome(); + // Click breadcrumb does not affect file tree await retry.try(async () => { expect(await exists('codeFileBreadcrumb-src')).ok(); @@ -305,6 +308,8 @@ export default function exploreRepositoryFunctionalTests({ const notExistRepoUri = 'github.com/I_DO_NOT_EXIST/I_DO_NOT_EXIST'; const url = `${PageObjects.common.getHostPort()}/app/code#/${notExistRepoUri}`; await browser.get(url); + await PageObjects.header.awaitKibanaChrome(); + await retry.try(async () => { const currentUrl: string = await browser.getCurrentUrl(); // should redirect to main page diff --git a/x-pack/test/functional/apps/code/file_tree.ts b/x-pack/test/functional/apps/code/file_tree.ts index 7c6dcac90074f..f290289c43aab 100644 --- a/x-pack/test/functional/apps/code/file_tree.ts +++ b/x-pack/test/functional/apps/code/file_tree.ts @@ -18,8 +18,7 @@ export default function exploreRepositoryFunctionalTests({ const PageObjects = getPageObjects(['common', 'header', 'security', 'code', 'home']); const exists = async (selector: string) => testSubjects.exists(selector, { allowHidden: true }); - // FLAKY: https://github.com/elastic/kibana/issues/43492 - describe.skip('File Tree', function() { + describe('File Tree', function() { this.tags('smoke'); const repositoryListSelector = 'codeRepositoryList codeRepositoryItem'; @@ -98,7 +97,11 @@ export default function exploreRepositoryFunctionalTests({ await browser.refresh(); - await retry.tryForTime(15000, async () => { + await PageObjects.header.awaitKibanaChrome(); + + await testSubjects.waitForDeleted('.euiLoadingSpinner'); + + await retry.tryForTime(30000, async () => { // should only open one folder at this time expect(await exists('codeFileTreeNode-Directory-Icon-elastic/src/code-open')).ok(); expect(await exists('codeFileTreeNode-Directory-Icon-kibana/src/code-closed')).ok(); diff --git a/x-pack/test/functional/apps/code/history.ts b/x-pack/test/functional/apps/code/history.ts index 3c97b976a33d3..8dfde5a0aaad2 100644 --- a/x-pack/test/functional/apps/code/history.ts +++ b/x-pack/test/functional/apps/code/history.ts @@ -22,8 +22,10 @@ export default function manageRepositoriesFunctionalTests({ const find = getService('find'); const PageObjects = getPageObjects(['common', 'header', 'security', 'code', 'home']); - // FLAKY: https://github.com/elastic/kibana/issues/37859 - describe.skip('History', function() { + const existsInvisible = async (selector: string) => + await testSubjects.exists(selector, { allowHidden: true }); + + describe('History', function() { this.tags('smoke'); const repositoryListSelector = 'codeRepositoryList codeRepositoryItem'; @@ -130,13 +132,14 @@ export default function manageRepositoriesFunctionalTests({ }); }); - // FLAKY: https://github.com/elastic/kibana/issues/39163 - it.skip('in search page, change language filters can go back and forward', async () => { + it('in search page, change language filters can go back and forward', async () => { log.debug('it select typescript language filter'); - const url = `${PageObjects.common.getHostPort()}/app/code#/search?q=string&p=&langs=typescript`; + const url = `${PageObjects.common.getHostPort()}/app/code#/search?q=string&langs=typescript`; await browser.get(url); - await retry.try(async () => { + await PageObjects.header.awaitKibanaChrome(); + + await retry.tryForTime(300000, async () => { const language = await (await find.byCssSelector( '.euiFacetButton--isSelected' )).getVisibleText(); @@ -180,14 +183,16 @@ export default function manageRepositoriesFunctionalTests({ log.debug('it goes back after line number changed'); const url = `${PageObjects.common.getHostPort()}/app/code#/github.com/elastic/TypeScript-Node-Starter`; await browser.get(url); + await PageObjects.header.awaitKibanaChrome(); + const lineNumber = 20; await retry.try(async () => { - const existence = await testSubjects.exists('codeFileTreeNode-File-tsconfig.json'); + const existence = await existsInvisible('codeFileTreeNode-File-tsconfig.json'); expect(existence).to.be(true); }); await testSubjects.click('codeFileTreeNode-File-tsconfig.json'); await retry.try(async () => { - const existence = await testSubjects.exists('codeFileTreeNode-File-package.json'); + const existence = await existsInvisible('codeFileTreeNode-File-package.json'); expect(existence).to.be(true); }); await testSubjects.click('codeFileTreeNode-File-package.json'); @@ -227,6 +232,9 @@ export default function manageRepositoriesFunctionalTests({ await browser.get(url); // refresh so language server will be initialized. await browser.refresh(); + + await PageObjects.header.awaitKibanaChrome(); + // wait for tab is not disabled await PageObjects.common.sleep(5000); await testSubjects.click('codeStructureTreeTab');