Skip to content

Commit

Permalink
change createIndexPattern to do what it takes to make the indexPatter…
Browse files Browse the repository at this point in the history
…nName* (elastic#64646)
  • Loading branch information
Lee Drengenberg committed Apr 30, 2020
1 parent 626e8c2 commit 38e5596
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion test/functional/apps/discover/_discover_histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function({ getService, getPageObjects }) {

log.debug('create long_window_logstash index pattern');
// NOTE: long_window_logstash load does NOT create index pattern
await PageObjects.settings.createIndexPattern('long-window-logstash-');
await PageObjects.settings.createIndexPattern('long-window-logstash-*');
await kibanaServer.uiSettings.replace(defaultSettings);
await browser.refresh();

Expand Down
6 changes: 3 additions & 3 deletions test/functional/apps/getting_started/_shakespeare.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export default function({ getService, getPageObjects }) {

it('should create shakespeare index pattern', async function() {
log.debug('Create shakespeare index pattern');
await PageObjects.settings.createIndexPattern('shakes', null);
await PageObjects.settings.createIndexPattern('shakespeare', null);
const patternName = await PageObjects.settings.getIndexPageHeading();
expect(patternName).to.be('shakes*');
expect(patternName).to.be('shakespeare');
});

// https://www.elastic.co/guide/en/kibana/current/tutorial-visualizing.html
Expand All @@ -74,7 +74,7 @@ export default function({ getService, getPageObjects }) {
log.debug('create shakespeare vertical bar chart');
await PageObjects.visualize.navigateToNewVisualization();
await PageObjects.visualize.clickVerticalBarChart();
await PageObjects.visualize.clickNewSearch('shakes*');
await PageObjects.visualize.clickNewSearch('shakespeare');
await PageObjects.visChart.waitForVisualization();

const expectedChartValues = [111396];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ export default function({ getService, getPageObjects }) {
it('should handle special charaters in template input', async () => {
await PageObjects.settings.clickAddNewIndexPatternButton();
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.settings.setIndexPatternField({
indexPatternName: '❤️',
expectWildcard: false,
});
await PageObjects.settings.setIndexPatternField('❤️');
await PageObjects.header.waitUntilLoadingHasFinished();

await retry.try(async () => {
Expand Down
26 changes: 22 additions & 4 deletions test/functional/page_objects/settings_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ export function SettingsPageProvider({ getService, getPageObjects }: FtrProvider
}
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async () => {
await this.setIndexPatternField({ indexPatternName });
await this.setIndexPatternField(indexPatternName);
});
await PageObjects.common.sleep(2000);
await (await this.getCreateIndexPatternGoToStep2Button()).click();
Expand Down Expand Up @@ -375,14 +375,32 @@ export function SettingsPageProvider({ getService, getPageObjects }: FtrProvider
return indexPatternId;
}

async setIndexPatternField({ indexPatternName = 'logstash-', expectWildcard = true } = {}) {
async setIndexPatternField(indexPatternName = 'logstash-*') {
log.debug(`setIndexPatternField(${indexPatternName})`);
const field = await this.getIndexPatternField();
await field.clearValue();
await field.type(indexPatternName, { charByChar: true });
if (
indexPatternName.charAt(0) === '*' &&
indexPatternName.charAt(indexPatternName.length - 1) === '*'
) {
// this is a special case when the index pattern name starts with '*'
// like '*:makelogs-*' where the UI will not append *
await field.type(indexPatternName, { charByChar: true });
} else if (indexPatternName.charAt(indexPatternName.length - 1) === '*') {
// the common case where the UI will append '*' automatically so we won't type it
const tempName = indexPatternName.slice(0, -1);
await field.type(tempName, { charByChar: true });
} else {
// case where we don't want the * appended so we'll remove it if it was added
await field.type(indexPatternName, { charByChar: true });
const tempName = await field.getAttribute('value');
if (tempName.length > indexPatternName.length) {
await field.type(browser.keys.DELETE, { charByChar: true });
}
}
const currentName = await field.getAttribute('value');
log.debug(`setIndexPatternField set to ${currentName}`);
expect(currentName).to.eql(`${indexPatternName}${expectWildcard ? '*' : ''}`);
expect(currentName).to.eql(indexPatternName);
}

async getCreateIndexPatternGoToStep2Button() {
Expand Down
4 changes: 2 additions & 2 deletions x-pack/test/functional/apps/graph/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default function({ getService, getPageObjects }: FtrProviderContext) {
}

it('should show correct node labels', async function() {
await PageObjects.graph.selectIndexPattern('secrepo*');
await PageObjects.graph.selectIndexPattern('secrepo');
await buildGraph();
const { nodes } = await PageObjects.graph.getGraphObjects();
const circlesText = nodes.map(({ label }) => label);
Expand Down Expand Up @@ -120,7 +120,7 @@ export default function({ getService, getPageObjects }: FtrProviderContext) {

it('should create new Graph workspace', async function() {
await PageObjects.graph.newGraph();
await PageObjects.graph.selectIndexPattern('secrepo*');
await PageObjects.graph.selectIndexPattern('secrepo');
const { nodes, edges } = await PageObjects.graph.getGraphObjects();
expect(nodes).to.be.empty();
expect(edges).to.be.empty();
Expand Down

0 comments on commit 38e5596

Please sign in to comment.