diff --git a/x-pack/plugins/code/public/components/main/side_tabs.tsx b/x-pack/plugins/code/public/components/main/side_tabs.tsx index dcc4e5e11d0b6..16e1a17d22a10 100644 --- a/x-pack/plugins/code/public/components/main/side_tabs.tsx +++ b/x-pack/plugins/code/public/components/main/side_tabs.tsx @@ -71,7 +71,7 @@ class CodeSideTabs extends React.PureComponent { id: Tabs.file, name: 'File', content: fileTabContent, - 'data-test-subj': 'codeFileTreeTab', + 'data-test-subj': `codeFileTreeTab${this.sideTab === Tabs.file ? 'Active' : ''}`, }, { id: Tabs.structure, diff --git a/x-pack/test/functional/apps/code/explore_repository.ts b/x-pack/test/functional/apps/code/explore_repository.ts index 3fb2ffa9dc22f..1a387e1769b71 100644 --- a/x-pack/test/functional/apps/code/explore_repository.ts +++ b/x-pack/test/functional/apps/code/explore_repository.ts @@ -229,71 +229,71 @@ export default function exploreRepositoryFunctonalTests({ }); // TODO(qianliang): blocked by https://github.com/elastic/code/issues/1163 - // it('Click file/directory on the right panel', async () => { - // log.debug('Click file/directory on the right panel'); - - // // Wait the file tree to be rendered and click the 'src' folder on the file tree. - // await retry.try(async () => { - // expect(await testSubjects.exists('codeFileExplorerNode-src')).to.be(true); - // }); - - // await testSubjects.click('codeFileExplorerNode-src'); - // await retry.try(async () => { - // expect(await testSubjects.exists('codeFileExplorerNode-models')).to.be(true); - // }); - - // await testSubjects.click('codeFileExplorerNode-models'); - // // Then the 'models' folder on the file tree. - // await retry.try(async () => { - // expect(await testSubjects.exists('codeFileExplorerNode-User.ts')).to.be(true); - // }); - - // await testSubjects.click('codeFileExplorerNode-User.ts'); - // // Then the 'User.ts' file on the file tree. - // await retry.try(async () => { - // expect(await testSubjects.exists('codeSourceViewer')).to.be(true); - // }); - // }); + it('Click file/directory on the right panel', async () => { + log.debug('Click file/directory on the right panel'); + + // Wait the file tree to be rendered and click the 'src' folder on the file tree. + await retry.try(async () => { + expect(await testSubjects.exists('codeFileExplorerNode-src')).to.be(true); + }); + + await testSubjects.click('codeFileExplorerNode-src'); + await retry.try(async () => { + expect(await testSubjects.exists('codeFileExplorerNode-models')).to.be(true); + }); + + await testSubjects.click('codeFileExplorerNode-models'); + // Then the 'models' folder on the file tree. + await retry.try(async () => { + expect(await testSubjects.exists('codeFileExplorerNode-User.ts')).to.be(true); + }); + + await testSubjects.click('codeFileExplorerNode-User.ts'); + // Then the 'User.ts' file on the file tree. + await retry.try(async () => { + expect(await testSubjects.exists('codeSourceViewer')).to.be(true); + }); + }); // TODO(qianliang): blocked by https://github.com/elastic/code/issues/1163 - // it('Navigate source file via structure tree', async () => { - // log.debug('Navigate source file via structure tree'); - // // Wait the file tree to be rendered and click the 'src' folder on the file tree. - // await retry.try(async () => { - // expect(await testSubjects.exists('codeFileExplorerNode-src')).to.be(true); - // }); - - // await testSubjects.click('codeFileExplorerNode-src'); - // await retry.try(async () => { - // expect(await testSubjects.exists('codeFileExplorerNode-models')).to.be(true); - // }); - - // await testSubjects.click('codeFileExplorerNode-models'); - // // Then the 'models' folder on the file tree. - // await retry.try(async () => { - // expect(await testSubjects.exists('codeFileExplorerNode-User.ts')).to.be(true); - // }); - - // await testSubjects.click('codeFileExplorerNode-User.ts'); - // // Then the 'User.ts' file on the file tree. - // await retry.try(async () => { - // expect(await testSubjects.exists('codeSourceViewer')).to.be(true); - // expect(await testSubjects.exists('codeStructureTreeTab')).to.be(true); - // }); - - // // Click the structure tree tab - // await testSubjects.click('codeStructureTreeTab'); - // await retry.tryForTime(300000, async () => { - // expect(await testSubjects.exists('codeStructureTreeNode-User')).to.be(true); - - // await testSubjects.click('codeStructureTreeNode-User'); - // await retry.tryForTime(120000, async () => { - // const currentUrl: string = await browser.getCurrentUrl(); - // log.info(`Jump to url: ${currentUrl}`); - // expect(currentUrl.indexOf('src/models/User.ts!L92:6') > 0).to.be(true); - // }); - // }); - // }); + it('Navigate source file via structure tree', async () => { + log.debug('Navigate source file via structure tree'); + // Wait the file tree to be rendered and click the 'src' folder on the file tree. + await retry.try(async () => { + expect(await testSubjects.exists('codeFileExplorerNode-src')).to.be(true); + }); + + await testSubjects.click('codeFileExplorerNode-src'); + await retry.try(async () => { + expect(await testSubjects.exists('codeFileExplorerNode-models')).to.be(true); + }); + + await testSubjects.click('codeFileExplorerNode-models'); + // Then the 'models' folder on the file tree. + await retry.try(async () => { + expect(await testSubjects.exists('codeFileExplorerNode-User.ts')).to.be(true); + }); + + await testSubjects.click('codeFileExplorerNode-User.ts'); + // Then the 'User.ts' file on the file tree. + await retry.try(async () => { + expect(await testSubjects.exists('codeSourceViewer')).to.be(true); + expect(await testSubjects.exists('codeStructureTreeTab')).to.be(true); + }); + + // Click the structure tree tab + await testSubjects.click('codeStructureTreeTab'); + await retry.tryForTime(300000, async () => { + expect(await testSubjects.exists('codeStructureTreeNode-User')).to.be(true); + + await testSubjects.click('codeStructureTreeNode-User'); + await retry.tryForTime(120000, async () => { + const currentUrl: string = await browser.getCurrentUrl(); + log.info(`Jump to url: ${currentUrl}`); + expect(currentUrl.indexOf('src/models/User.ts!L92:6') > 0).to.be(true); + }); + }); + }); it('goes to a repository which does not exist should render the 404 error page', async () => { log.debug('it goes to a repository which does not exist'); diff --git a/x-pack/test/functional/apps/code/history.ts b/x-pack/test/functional/apps/code/history.ts index 75d004b2c4fa5..80a462f6508e3 100644 --- a/x-pack/test/functional/apps/code/history.ts +++ b/x-pack/test/functional/apps/code/history.ts @@ -24,7 +24,7 @@ export default function manageRepositoriesFunctionalTests({ const PageObjects = getPageObjects(['common', 'header', 'security', 'code', 'home']); // FLAKY: https://github.com/elastic/kibana/issues/36495 - describe.skip('History', () => { + describe('History', () => { const repositoryListSelector = 'codeRepositoryList codeRepositoryItem'; describe('browser history can go back while exploring code app', () => { @@ -200,22 +200,22 @@ export default function manageRepositoriesFunctionalTests({ await PageObjects.common.sleep(5000); await testSubjects.click('codeStructureTreeTab'); await retry.try(async () => { - const tabText = await (await find.byCssSelector('.euiTab-isSelected')).getVisibleText(); - expect(tabText).to.equal('Structure'); + // if structure tree tab is active, file tree tab's `data-test-subj` would be `codeFileTreeTab` + expect(testSubjects.exists('codeFileTreeTab')).to.be.ok(); }); await browser.goBack(); await retry.try(async () => { - const tabText = await (await find.byCssSelector('.euiTab-isSelected')).getVisibleText(); - expect(tabText).to.equal('File'); + // if file tree tab is active, file tree tab's `data-test-subj` would be `codeFileTreeTabActive` + expect(testSubjects.exists('codeFileTreeTabActive')).to.be.ok(); }); await driver.navigate().forward(); await retry.try(async () => { - const tabText = await (await find.byCssSelector('.euiTab-isSelected')).getVisibleText(); - expect(tabText).to.equal('Structure'); + // if structure tree tab is active, file tree tab's `data-test-subj` would be `codeFileTreeTab` + expect(testSubjects.exists('codeFileTreeTab')).to.be.ok(); }); }); });