Skip to content

Commit

Permalink
[Code] fix history functional test (#37332)
Browse files Browse the repository at this point in the history
* enable history functional test and fix flaky test
  • Loading branch information
WangQianliang authored Jun 3, 2019
1 parent a9f9960 commit 570135b
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 71 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/code/public/components/main/side_tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class CodeSideTabs extends React.PureComponent<Props> {
id: Tabs.file,
name: 'File',
content: fileTabContent,
'data-test-subj': 'codeFileTreeTab',
'data-test-subj': `codeFileTreeTab${this.sideTab === Tabs.file ? 'Active' : ''}`,
},
{
id: Tabs.structure,
Expand Down
126 changes: 63 additions & 63 deletions x-pack/test/functional/apps/code/explore_repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
14 changes: 7 additions & 7 deletions x-pack/test/functional/apps/code/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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();
});
});
});
Expand Down

0 comments on commit 570135b

Please sign in to comment.