Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Code] fix flaky functional test #42906

Merged
merged 3 commits into from
Aug 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 38 additions & 68 deletions x-pack/legacy/plugins/code/public/components/search_page/side_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,76 +32,46 @@ interface Props {
}

export class SideBar extends React.PureComponent<Props> {
public render() {
const { languages, langFacets, repoFacets, repositories } = this.props;
const repoStatsComp = repoFacets.map((item, index) => {
if (!!repositories && repositories.has(item.name)) {
return (
<EuiFacetButton
className="codeFilter__item"
key={`repostats${index}`}
onClick={this.props.onRepositoryFilterToggled(item.name)}
quantity={item.value}
isSelected={true}
buttonRef={() => {
/* nothing */
}}
>
{RepositoryUtils.repoNameFromUri(item.name)}
</EuiFacetButton>
);
} else {
return (
<EuiFacetButton
className="codeFilter__item"
key={`repostats${index}`}
onClick={this.props.onRepositoryFilterToggled(item.name)}
quantity={item.value}
buttonRef={() => {
/* nothing */
}}
>
{RepositoryUtils.repoNameFromUri(item.name)}
</EuiFacetButton>
);
}
voidFunc = () => void 0;

renderLangFacets = () => {
return this.props.langFacets.map((item, index) => {
const isSelected = this.props.languages && this.props.languages.has(item.name);
return (
<EuiFacetButton
className="codeFilter__item"
key={`langstats${index}`}
onClick={this.props.onLanguageFilterToggled(item.name)}
quantity={item.value}
isSelected={isSelected}
data-test-subj="codeSearchLanguageFilterItem"
buttonRef={this.voidFunc}
>
{item.name}
</EuiFacetButton>
);
});
};

const langStatsComp = langFacets.map((item, index) => {
if (languages && languages.has(item.name)) {
return (
<EuiFacetButton
className="codeFilter__item"
key={`langstats${index}`}
onClick={this.props.onLanguageFilterToggled(item.name)}
quantity={item.value}
isSelected={true}
data-test-subj="codeSearchLanguageFilterItem"
buttonRef={() => {
/* nothing */
}}
>
{item.name}
</EuiFacetButton>
);
} else {
return (
<EuiFacetButton
className="codeFilter__item"
key={`langstats${index}`}
onClick={this.props.onLanguageFilterToggled(item.name)}
quantity={item.value}
data-test-subj="codeSearchLanguageFilterItem"
buttonRef={() => {
/* nothing */
}}
>
{item.name}
</EuiFacetButton>
);
}
renderRepoFacets = () => {
return this.props.repoFacets.map((item, index) => {
const isSelected = !!this.props.repositories && this.props.repositories.has(item.name);
return (
<EuiFacetButton
className="codeFilter__item"
key={`repostats${index}`}
onClick={this.props.onRepositoryFilterToggled(item.name)}
quantity={item.value}
isSelected={isSelected}
buttonRef={this.voidFunc}
>
{RepositoryUtils.repoNameFromUri(item.name)}
</EuiFacetButton>
);
});
};

public render() {
return (
<div className="codeSidebar__container">
<ScopeTabs query={this.props.query} scope={this.props.scope} />
Expand All @@ -126,7 +96,7 @@ export class SideBar extends React.PureComponent<Props> {
</EuiTitle>
</EuiFlexItem>
</EuiFlexGroup>
<EuiFacetGroup>{repoStatsComp}</EuiFacetGroup>
<EuiFacetGroup>{this.renderRepoFacets()}</EuiFacetGroup>
<EuiSpacer />
<EuiFlexGroup
className="codeFilter__title"
Expand All @@ -152,7 +122,7 @@ export class SideBar extends React.PureComponent<Props> {
</EuiFlexItem>
</EuiFlexGroup>
<EuiFacetGroup data-test-subj="codeSearchLanguageFilterList">
{langStatsComp}
{this.renderLangFacets()}
</EuiFacetGroup>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion x-pack/legacy/plugins/code/public/reducers/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ export const search = handleActions<SearchState, SearchPayload>(
}
draft.isLoading = true;
delete draft.error;
delete draft.documentSearchResults;
}
}),
[String(documentSearchSuccess)]: (state: SearchState, action: Action<DocumentSearchResult>) =>
Expand Down
15 changes: 7 additions & 8 deletions x-pack/test/functional/apps/code/code_intelligence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export default function codeIntelligenceFunctionalTests({
const FIND_TIME = config.get('timeouts.find');
const PageObjects = getPageObjects(['common', 'header', 'security', 'code', 'home']);

// FAILING: https://github.com/elastic/kibana/issues/36480
describe.skip('Code Intelligence', () => {
describe('Code Intelligence', () => {
describe('Code intelligence in source view page', () => {
const repositoryListSelector = 'codeRepositoryList codeRepositoryItem';
const testGoToDefinition = async () => {
Expand All @@ -32,7 +31,7 @@ export default function codeIntelligenceFunctionalTests({

// Hover on the 'UserModel' reference on line 5.
await retry.tryForTime(300000, async () => {
const spans = await find.allByCssSelector('.mtk31', FIND_TIME);
const spans = await find.allByCssSelector('.mtk32', FIND_TIME);
expect(spans.length).to.greaterThan(1);
const userModelSpan = spans[1];
expect(await userModelSpan.getVisibleText()).to.equal('UserModel');
Expand Down Expand Up @@ -86,7 +85,7 @@ export default function codeIntelligenceFunctionalTests({

// Prepare a git repository for the test
await PageObjects.code.fillImportRepositoryUrlInputBox(
'https://github.com/Microsoft/TypeScript-Node-Starter'
'https://github.com/elastic/TypeScript-Node-Starter'
);
// Click the import repository button.
await PageObjects.code.clickImportRepositoryButton();
Expand All @@ -95,7 +94,7 @@ export default function codeIntelligenceFunctionalTests({
const repositoryItems = await testSubjects.findAll(repositoryListSelector);
expect(repositoryItems).to.have.length(1);
expect(await repositoryItems[0].getVisibleText()).to.equal(
'Microsoft/TypeScript-Node-Starter'
'elastic/TypeScript-Node-Starter'
);

// Wait for the index to start.
Expand Down Expand Up @@ -179,7 +178,7 @@ export default function codeIntelligenceFunctionalTests({

// Hover on the 'UserModel' reference on line 5.
await retry.tryForTime(300000, async () => {
const spans = await find.allByCssSelector('.mtk31', FIND_TIME);
const spans = await find.allByCssSelector('.mtk32', FIND_TIME);
expect(spans.length).to.greaterThan(1);
const userModelSpan = spans[0];
expect(await userModelSpan.getVisibleText()).to.equal('UserModel');
Expand Down Expand Up @@ -234,7 +233,7 @@ export default function codeIntelligenceFunctionalTests({

// Hover on the 'async' reference on line 1.
await retry.tryForTime(300000, async () => {
const spans = await find.allByCssSelector('.mtk17', FIND_TIME);
const spans = await find.allByCssSelector('.mtk9', FIND_TIME);
expect(spans.length).to.greaterThan(1);
const asyncSpan = spans[1];
expect(await asyncSpan.getVisibleText()).to.equal('async');
Expand All @@ -258,7 +257,7 @@ export default function codeIntelligenceFunctionalTests({
// await browser.goBack();

// await retry.try(async () => {
// const $spans = await find.allByCssSelector('.mtk31', FIND_TIME);
// const $spans = await find.allByCssSelector('.mtk32', FIND_TIME);
// expect($spans.length).to.greaterThan(1);
// const $userModelSpan = $spans[1];
// expect(await $userModelSpan.getVisibleText()).to.equal('UserModel');
Expand Down
4 changes: 0 additions & 4 deletions x-pack/test/functional/apps/code/file_tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ export default function exploreRepositoryFunctionalTests({
await retry.try(async () => {
expect(await testSubjects.exists('repositoryIndexOngoing')).to.be(true);
});
// Wait for the index to end.
await retry.try(async () => {
expect(await testSubjects.exists('repositoryIndexDone')).to.be(true);
});
});

beforeEach(async () => {
Expand Down
60 changes: 33 additions & 27 deletions x-pack/test/functional/apps/code/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function manageRepositoriesFunctionalTests({
const PageObjects = getPageObjects(['common', 'header', 'security', 'code', 'home']);

describe('History', function() {
this.tags('skipFirefox');
this.tags('smoke');
const repositoryListSelector = 'codeRepositoryList codeRepositoryItem';

describe('browser history can go back while exploring code app', () => {
Expand All @@ -36,7 +36,7 @@ export default function manageRepositoriesFunctionalTests({
log.debug('Code test import repository');
// Fill in the import repository input box with a valid git repository url.
await PageObjects.code.fillImportRepositoryUrlInputBox(
'https://github.com/Microsoft/TypeScript-Node-Starter'
'https://github.com/elastic/TypeScript-Node-Starter'
);
// Click the import repository button.
await PageObjects.code.clickImportRepositoryButton();
Expand Down Expand Up @@ -72,14 +72,14 @@ export default function manageRepositoriesFunctionalTests({
const repositoryItems = await testSubjects.findAll(repositoryListSelector);
expect(repositoryItems).to.have.length(1);
expect(await repositoryItems[0].getVisibleText()).to.equal(
'Microsoft/TypeScript-Node-Starter'
'elastic/TypeScript-Node-Starter'
);
});

await retry.try(async () => {
expect(await testSubjects.exists('repositoryIndexDone')).to.be(true);

log.debug('it goes to Microsoft/TypeScript-Node-Starter project page');
log.debug('it goes to elastic/TypeScript-Node-Starter project page');
await testSubjects.click('adminLinkToTypeScript-Node-Starter');
await retry.try(async () => {
expect(await testSubjects.exists('codeStructureTreeTab')).to.be(true);
Expand All @@ -92,7 +92,7 @@ export default function manageRepositoriesFunctionalTests({
const repositoryItems = await testSubjects.findAll(repositoryListSelector);
expect(repositoryItems).to.have.length(1);
expect(await repositoryItems[0].getVisibleText()).to.equal(
'Microsoft/TypeScript-Node-Starter'
'elastic/TypeScript-Node-Starter'
);
});

Expand Down Expand Up @@ -129,48 +129,54 @@ 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`;
await browser.get(url);

const language = await (await find.byCssSelector(
'.euiFacetButton--isSelected'
)).getVisibleText();
await retry.try(async () => {
const language = await (await find.byCssSelector(
'.euiFacetButton--isSelected'
)).getVisibleText();

expect(language.indexOf('typescript')).to.equal(0);
expect(language.indexOf('typescript')).to.equal(0);
});

const unselectedFilter = (await find.allByCssSelector('.euiFacetButton--unSelected'))[1];
await unselectedFilter.click();

const l = await (await find.allByCssSelector(
'.euiFacetButton--isSelected'
))[1].getVisibleText();
await retry.try(async () => {
const l = await (await find.allByCssSelector(
'.euiFacetButton--isSelected'
))[1].getVisibleText();

expect(l.indexOf('javascript')).to.equal(0);
expect(l.indexOf('javascript')).to.equal(0);
});

await browser.goBack();

const lang = await (await find.byCssSelector(
'.euiFacetButton--isSelected'
)).getVisibleText();
await retry.try(async () => {
const lang = await (await find.byCssSelector(
'.euiFacetButton--isSelected'
)).getVisibleText();

expect(lang.indexOf('typescript')).to.equal(0);
expect(lang.indexOf('typescript')).to.equal(0);
});

await driver.navigate().forward();

const filter = await (await find.allByCssSelector(
'.euiFacetButton--isSelected'
))[1].getVisibleText();
await retry.try(async () => {
const filter = await (await find.allByCssSelector(
'.euiFacetButton--isSelected'
))[1].getVisibleText();

expect(filter.indexOf('javascript')).to.equal(0);
expect(filter.indexOf('javascript')).to.equal(0);
});
});

// FLAKY: https://github.com/elastic/kibana/issues/39958
it.skip('in source view page file line number changed can go back and forward', async () => {
it('in source view page file line number changed can go back and forward', async () => {
log.debug('it goes back after line number changed');
const url = `${PageObjects.common.getHostPort()}/app/code#/github.com/Microsoft/TypeScript-Node-Starter`;
const url = `${PageObjects.common.getHostPort()}/app/code#/github.com/elastic/TypeScript-Node-Starter`;
await browser.get(url);
const lineNumber = 20;
await retry.try(async () => {
Expand Down Expand Up @@ -215,7 +221,7 @@ export default function manageRepositoriesFunctionalTests({

it('in source view page, switch side tab can go back and forward', async () => {
log.debug('it goes back after line number changed');
const url = `${PageObjects.common.getHostPort()}/app/code#/github.com/Microsoft/TypeScript-Node-Starter/blob/master/src/controllers/api.ts`;
const url = `${PageObjects.common.getHostPort()}/app/code#/github.com/elastic/TypeScript-Node-Starter/blob/master/src/controllers/api.ts`;
await browser.get(url);
// refresh so language server will be initialized.
await browser.refresh();
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/functional/apps/code/with_security.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default function testWithSecurity({ getService, getPageObjects }: FtrProv
expect(buttons).to.have.length(1);
});
await PageObjects.code.fillImportRepositoryUrlInputBox(
'https://github.com/Microsoft/TypeScript-Node-Starter'
'https://github.com/elastic/TypeScript-Node-Starter'
);
// Click the import repository button.
await PageObjects.code.clickImportRepositoryButton();
Expand Down
Loading