-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Ensure custom set axis titles are preserved when loading a saved vis. #24176
Changes from all commits
fef3dd2
f0596ee
fd31e37
20b5916
6e6d168
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,4 +136,41 @@ describe('point series editor', function () { | |
$parentScope.updateAxisTitle(); | ||
expect($parentScope.editorState.params.valueAxes[0].title.text).to.equal('Custom Title'); | ||
}); | ||
|
||
it('should set the custom title to match the value axis label when only one agg exists for that axis', function () { | ||
$parentScope.editorState.aggs[0].params.customLabel = 'Custom Label'; | ||
$parentScope.updateAxisTitle(); | ||
expect($parentScope.editorState.params.valueAxes[0].title.text).to.equal('Custom Label'); | ||
}); | ||
|
||
it('should not set the custom title to match the value axis label when more than one agg exists for that axis', function () { | ||
const aggConfig = new AggConfig($parentScope.vis.aggs, { type: 'avg', schema: 'metric', params: { field: 'bytes' } }); | ||
$parentScope.vis.aggs.push(aggConfig); | ||
$parentScope.$digest(); | ||
$parentScope.editorState.aggs[0].params.customLabel = 'Custom Label'; | ||
$parentScope.updateAxisTitle(); | ||
expect($parentScope.editorState.params.valueAxes[0].title.text).to.equal('Count'); | ||
}); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the above 2 tests to validate existing editor behavior which was previously untested |
||
it('should not overwrite the custom title with the value axis label if the custom title has been changed', function () { | ||
$parentScope.editorState.params.valueAxes[0].title.text = 'Custom Title'; | ||
$parentScope.editorState.aggs[0].params.customLabel = 'Custom Label'; | ||
$parentScope.updateAxisTitle(); | ||
expect($parentScope.editorState.params.valueAxes[0].title.text).to.equal('Custom Title'); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the test that validates the actual change made in this PR |
||
|
||
it('should overwrite the custom title when the agg type changes', function () { | ||
const aggConfig = new AggConfig($parentScope.vis.aggs, { type: 'avg', schema: 'metric', params: { field: 'bytes' } }); | ||
|
||
$parentScope.editorState.params.valueAxes[0].title.text = 'Custom Title'; | ||
$parentScope.editorState.aggs[0].params.customLabel = 'Custom Label'; | ||
$parentScope.updateAxisTitle(); | ||
|
||
$parentScope.vis.aggs.push(aggConfig); | ||
$parentScope.vis.aggs.shift(); | ||
$parentScope.$digest(); | ||
$parentScope.updateAxisTitle(); | ||
|
||
expect($parentScope.editorState.params.valueAxes[0].title.text).to.equal('Average bytes'); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed some variable names to make this all a little easier to follow.