Skip to content

Commit a200b33

Browse files
committed
Added timeseries test for reference line.
1 parent 8c38609 commit a200b33

3 files changed

Lines changed: 49 additions & 0 deletions

File tree

src/plugins/vis_types/timeseries/public/application/components/aggs/static.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export const Static = (props) => {
7676
}
7777
>
7878
<EuiFieldNumber
79+
data-test-subj="staticValue"
7980
onChange={handleTextChange('value')}
8081
value={model.value === '' ? '' : Number(model.value)}
8182
step={0.1}

test/functional/page_objects/visual_builder_page.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,17 @@ export class VisualBuilderPageObject extends FtrService {
406406
});
407407
}
408408

409+
public async createNewAggSeries(nth = 0) {
410+
const prevAggs = await this.testSubjects.findAll('draggable');
411+
const elements = await this.testSubjects.findAll('AddAddBtn');
412+
await elements[nth].click();
413+
await this.visChart.waitForVisualizationRenderingStabilized();
414+
await this.retry.waitFor('new agg series is added', async () => {
415+
const currentAggs = await this.testSubjects.findAll('draggable');
416+
return currentAggs.length > prevAggs.length;
417+
});
418+
}
419+
409420
public async selectAggType(value: string, nth = 0) {
410421
const elements = await this.testSubjects.findAll('aggSelector');
411422
await this.comboBox.setElement(elements[nth], value);
@@ -619,6 +630,11 @@ export class VisualBuilderPageObject extends FtrService {
619630
await input.type(labelName);
620631
}
621632

633+
public async setStaticValue(value: number, nth: number = 0): Promise<void> {
634+
const input = (await this.testSubjects.findAll('staticValue'))[nth];
635+
await input.type(value.toString());
636+
}
637+
622638
/**
623639
* set field for type of aggregation
624640
*

x-pack/test/functional/apps/lens/group3/open_in_lens/tsvb/timeseries.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,37 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
8383

8484
expect(await queryBar.getQueryString()).to.equal('machine.os : ios');
8585
});
86+
87+
it('should draw a reference line', async () => {
88+
await visualize.navigateToNewVisualization();
89+
await visualize.clickVisualBuilder();
90+
await visualBuilder.checkVisualBuilderIsPresent();
91+
await visualBuilder.resetPage();
92+
93+
await visualBuilder.createNewAggSeries();
94+
await visualBuilder.selectAggType('Static Value');
95+
await visualBuilder.setStaticValue(10);
96+
97+
await header.waitUntilLoadingHasFinished();
98+
99+
const button = await testSubjects.find('visualizeEditInLensButton');
100+
await button.click();
101+
await lens.waitForVisualization('xyVisChart');
102+
await retry.try(async () => {
103+
const layers = await find.allByCssSelector(`[data-test-subj^="lns-layerPanel-"]`);
104+
105+
const referenceLineDimensions = await testSubjects.findAllDescendant(
106+
'lns-dimensionTrigger',
107+
layers[0]
108+
);
109+
expect(referenceLineDimensions).to.have.length(1);
110+
expect(await referenceLineDimensions[0].getVisibleText()).to.be('Static value: 10');
111+
112+
const dimensions = await testSubjects.findAllDescendant('lns-dimensionTrigger', layers[1]);
113+
expect(dimensions).to.have.length(2);
114+
expect(await dimensions[0].getVisibleText()).to.be('@timestamp');
115+
expect(await dimensions[1].getVisibleText()).to.be('Count of records');
116+
});
117+
});
86118
});
87119
}

0 commit comments

Comments
 (0)