[XY] Fixes the threshold visibility (#158917)

## Summary

Closes https://github.com/elastic/kibana/issues/158343

Fixes the broken reference line in aggbased xy charts.

<img width="1715" alt="image"
src="ae48f0b8-475a-44e2-866a-c56e9da8e8b0">

The problem was the default here, apparently the expressions fail when
the default is an empty string. The expression was failing and as a
result the reference line was never rendered

### Checklist
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
This commit is contained in:
Stratoula Kalafateli 2023-06-02 18:21:36 +03:00 committed by GitHub
parent 39a67ec337
commit a584986721
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

View file

@ -108,7 +108,6 @@ export const referenceLineFunction: ReferenceLineFn = {
forAccessor: {
types: ['string'],
help: '',
default: '',
},
},
fn(table, args) {

View file

@ -248,6 +248,12 @@ export class VisualizeChartPageObject extends FtrService {
return items.map(({ name }) => name);
}
public async getReferenceLine(selector: string) {
const items = (await this.getEsChartDebugState(selector))?.annotations;
const referenceLine = items?.filter(({ type }) => type === 'line');
return referenceLine;
}
public async getLegendEntries() {
const isVisTypePieChart = await this.isNewLibraryChart(partitionVisChartSelector);
const isVisTypeHeatmapChart = await this.isNewLibraryChart(heatmapChartSelector);

View file

@ -205,6 +205,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await visEditor.clickOptionsTab();
await visEditor.toggleShowThresholdLine();
await visEditor.clickGo(isNewChartsLibraryEnabled);
const line = await visChart.getReferenceLine('xyVisChart');
expect(line?.length).to.be(1);
await header.waitUntilLoadingHasFinished();
await visualize.navigateToLensFromAnotherVisulization();