[Lens][TSVB] Navigate to Lens Guage functional tests. (#143214)

* Added tests for converting metric with params, unsupported metrics and not valid panels.

* Added tests for color ranges.

* Added tests for gauge.

* Fixed tests.
This commit is contained in:
Yaroslav Kuznietsov 2022-10-13 19:00:16 +03:00 committed by GitHub
parent d4d2a77fd5
commit ee313b34c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 114 additions and 14 deletions

View file

@ -418,8 +418,6 @@ export class VisualBuilderPageObject extends FtrService {
}
public async createColorRule(nth = 0) {
await this.clickPanelOptions('metric');
const elements = await this.testSubjects.findAll('AddAddBtn');
await elements[nth].click();
await this.visChart.waitForVisualizationRenderingStabilized();
@ -710,16 +708,16 @@ export class VisualBuilderPageObject extends FtrService {
public async setColorRuleOperator(condition: string): Promise<void> {
await this.retry.try(async () => {
await this.comboBox.clearInputField('colorRuleOperator');
await this.comboBox.set('colorRuleOperator', condition);
await this.comboBox.clearLastInputField('colorRuleOperator');
await this.comboBox.setForLastInput('colorRuleOperator', condition);
});
}
public async setColorRuleValue(value: number): Promise<void> {
public async setColorRuleValue(value: number, nth: number = 0): Promise<void> {
await this.retry.try(async () => {
const colorRuleValueInput = await this.find.byCssSelector(
'[data-test-subj="colorRuleValue"]'
);
const colorRuleValueInput = (
await this.find.allByCssSelector('[data-test-subj="colorRuleValue"]')
)[nth];
await colorRuleValueInput.type(value.toString());
});
}

View file

@ -36,6 +36,13 @@ export class ComboBoxService extends FtrService {
await this.setElement(comboBox, value);
}
public async setForLastInput(comboBoxSelector: string, value: string): Promise<void> {
this.log.debug(`comboBox.set, comboBoxSelector: ${comboBoxSelector}`);
const comboBoxes = await this.testSubjects.findAll(comboBoxSelector);
const comboBox = comboBoxes[comboBoxes.length - 1];
await this.setElement(comboBox, value);
}
/**
* Clicks option in combobox dropdown
*
@ -308,4 +315,12 @@ export class ComboBoxService extends FtrService {
const input = await comboBoxElement.findByTagName('input');
await input.clearValueWithKeyboard();
}
public async clearLastInputField(comboBoxSelector: string): Promise<void> {
this.log.debug(`comboBox.clearInputField, comboBoxSelector:${comboBoxSelector}`);
const comboBoxElements = await this.testSubjects.findAll(comboBoxSelector);
const comboBoxElement = comboBoxElements[comboBoxElements.length - 1];
const input = await comboBoxElement.findByTagName('input');
await input.clearValueWithKeyboard();
}
}

View file

@ -9,9 +9,16 @@ import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../../../ftr_provider_context';
export default function ({ getPageObjects, getService }: FtrProviderContext) {
const { visualize, visualBuilder, lens } = getPageObjects(['visualBuilder', 'visualize', 'lens']);
const { visualize, visualBuilder, lens, header } = getPageObjects([
'visualBuilder',
'visualize',
'lens',
'header',
]);
const testSubjects = getService('testSubjects');
const retry = getService('retry');
const find = getService('find');
describe('Gauge', function describeIndexTests() {
before(async () => {
@ -40,5 +47,88 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
const metricData = await lens.getMetricVisualizationData();
expect(metricData[0].title).to.eql('Count of records');
});
it('should convert metric with params', async () => {
await visualBuilder.selectAggType('Value Count');
await visualBuilder.setFieldForAggregation('bytes');
await header.waitUntilLoadingHasFinished();
const button = await testSubjects.find('visualizeEditInLensButton');
await button.click();
await lens.waitForVisualization('mtrVis');
await retry.try(async () => {
const layers = await find.allByCssSelector(`[data-test-subj^="lns-layerPanel-"]`);
expect(layers).to.have.length(1);
const dimensions = await testSubjects.findAll('lns-dimensionTrigger');
expect(dimensions).to.have.length(2);
expect(await dimensions[0].getVisibleText()).to.be('Count of bytes');
expect(await dimensions[1].getVisibleText()).to.be('overall_max(count(bytes))');
});
});
it('should not allow converting of unsupported metric', async () => {
await visualBuilder.selectAggType('Counter Rate');
await visualBuilder.setFieldForAggregation('machine.ram');
await header.waitUntilLoadingHasFinished();
const canEdit = await testSubjects.exists('visualizeEditInLensButton');
expect(canEdit).to.be(false);
});
it('should not allow converting of not valid panel', async () => {
await visualBuilder.selectAggType('Value Count');
await header.waitUntilLoadingHasFinished();
const canEdit = await testSubjects.exists('visualizeEditInLensButton');
expect(canEdit).to.be(false);
});
it('should convert color ranges', async () => {
await visualBuilder.setMetricsGroupByTerms('extension.raw');
await visualBuilder.clickPanelOptions('gauge');
await visualBuilder.setColorRuleOperator('>= greater than or equal');
await visualBuilder.setColorRuleValue(10);
await visualBuilder.setColorPickerValue('#54B399', 2);
await visualBuilder.createColorRule();
await visualBuilder.setColorRuleOperator('>= greater than or equal');
await visualBuilder.setColorRuleValue(100, 1);
await visualBuilder.setColorPickerValue('#54A000', 4);
await header.waitUntilLoadingHasFinished();
const button = await testSubjects.find('visualizeEditInLensButton');
await button.click();
await lens.waitForVisualization('mtrVis');
await retry.try(async () => {
const closePalettePanels = await testSubjects.findAll(
'lns-indexPattern-PalettePanelContainerBack'
);
if (closePalettePanels.length) {
await lens.closePalettePanel();
await lens.closeDimensionEditor();
}
const dimensions = await testSubjects.findAll('lns-dimensionTrigger');
expect(dimensions).to.have.length(3);
dimensions[0].click();
await lens.openPalettePanel('lnsMetric');
const colorStops = await lens.getPaletteColorStops();
expect(colorStops).to.eql([
{ stop: '', color: 'rgba(104, 188, 0, 1)' },
{ stop: '10', color: 'rgba(84, 179, 153, 1)' },
{ stop: '100', color: 'rgba(84, 160, 0, 1)' },
{ stop: '', color: undefined },
]);
});
});
});
}

View file

@ -18,7 +18,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const retry = getService('retry');
const find = getService('find');
describe('Metric', function describeIndexTests() {
before(async () => {
@ -58,8 +57,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await button.click();
await lens.waitForVisualization('mtrVis');
await retry.try(async () => {
const layers = await find.allByCssSelector(`[data-test-subj^="lns-layerPanel-"]`);
expect(layers).to.have.length(1);
expect(await lens.getLayerCount()).to.be(1);
const dimensions = await testSubjects.findAll('lns-dimensionTrigger');
expect(dimensions).to.have.length(1);
@ -77,8 +75,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await button.click();
await lens.waitForVisualization('mtrVis');
await retry.try(async () => {
const layers = await find.allByCssSelector(`[data-test-subj^="lns-layerPanel-"]`);
expect(layers).to.have.length(1);
expect(await lens.getLayerCount()).to.be(1);
const dimensions = await testSubjects.findAll('lns-dimensionTrigger');
expect(dimensions).to.have.length(1);