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

fix #7332 - saving vis with % in name causes error #7701

Merged
merged 7 commits into from
Aug 3, 2016
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ app.service('savedVisualizations', function (Promise, es, kbnIndex, SavedVis, Pr
body = {
query: {
simple_query_string: {
query: searchString + '*',
query: searchString + (['/', '!', '?', '&', '=', '%'].indexOf(searchString[searchString.length - 1]) === -1 ? '' : ' ') + '*',
fields: ['title^3', 'description'],
default_operator: 'AND'
}
Expand Down
6 changes: 5 additions & 1 deletion src/ui/public/utils/__tests__/slugify_id.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@ describe('slugifyId()', function () {
['test?test', 'test-questionmark-test'],
['test=test', 'test-equal-test'],
['test&test', 'test-ampersand-test'],
['test%test', 'test-percent-test'],
['test / test', 'test-slash-test'],
['test ? test', 'test-questionmark-test'],
['test = test', 'test-equal-test'],
['test & test', 'test-ampersand-test'],
['test % test', 'test-percent-test'],
['test / ^test', 'test-slash-^test'],
['test ? test', 'test-questionmark-test'],
['test = test', 'test-equal-test'],
['test & test', 'test-ampersand-test'],
['test % test', 'test-percent-test'],
['test/test/test', 'test-slash-test-slash-test'],
['test?test?test', 'test-questionmark-test-questionmark-test'],
['test&test&test', 'test-ampersand-test-ampersand-test'],
['test=test=test', 'test-equal-test-equal-test']
['test=test=test', 'test-equal-test-equal-test'],
['test%test%test', 'test-percent-test-percent-test']
];

_.each(fixtures, function (fixture) {
Expand Down
3 changes: 2 additions & 1 deletion src/ui/public/utils/slugify_id.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export default function (id) {
'/' : '-slash-',
'\\?' : '-questionmark-',
'\\&' : '-ampersand-',
'=' : '-equal-'
'=' : '-equal-',
'%' : '-percent-'
};
_.each(trans, function (val, key) {
let regex = new RegExp(key, 'g');
Expand Down
25 changes: 25 additions & 0 deletions test/functional/apps/visualize/_area_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,31 @@ bdd.describe('visualize app', function describeIndexTests() {
bdd.describe('area charts', function indexPatternCreation() {
var vizName1 = 'Visualization AreaChart';

bdd.it('should save and load with special characters', function pageHeader() {
let vizName2 = vizName1 + '/?&=%';
Copy link
Contributor

@Bargs Bargs Jul 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer const over let. Also maybe a more descriptive variable name, like vizNameWithSpecialChars?

return PageObjects.visualize.saveVisualization(vizName2)
.then(function (message) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment, our style guide recommends putting chained methods at the same indentation level as the first line in the chain https://github.com/elastic/kibana/blob/master/style_guides/js_style_guide.md#chaining-operations.

PageObjects.common.debug('Saved viz message = ' + message);
PageObjects.common.saveScreenshot('Visualize-area-chart-save-toast');
expect(message).to.be('Visualization Editor: Saved Visualization \"' + vizName2 + '\"');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you might be able to use string interpolation in these tests now?

})
.then(function testVisualizeWaitForToastMessageGone() {
return PageObjects.visualize.waitForToastMessageGone();
})
.then(function loadSavedVisualization() {
return PageObjects.visualize.loadSavedVisualization(vizName2);
})
.then(function () {
return PageObjects.visualize.waitForVisualization();
})
// We have to sleep sometime between loading the saved visTitle
// and trying to access the chart below with getXAxisLabels
// otherwise it hangs.
.then(function sleep() {
return PageObjects.common.sleep(2000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's really any reason to wait for the toast message, load the viz and wait for it if we're not running assertions on it. I think the only reason the test below does so is to set things up for the test that follows it.

});
});

bdd.it('should save and load', function pageHeader() {
return PageObjects.visualize.saveVisualization(vizName1)
.then(function (message) {
Expand Down