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

[Pie] Run all functional tests for the new implementation #131700

Merged
merged 19 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -8,7 +8,7 @@

import React, { memo, useMemo } from 'react';
import { i18n } from '@kbn/i18n';
import { htmlIdGenerator, EuiButtonIcon, useEuiTheme } from '@elastic/eui';
import { EuiButtonIcon, useEuiTheme } from '@elastic/eui';
import { Position } from '@elastic/charts';
import { css } from '@emotion/react';

Expand All @@ -19,7 +19,6 @@ export interface LegendToggleProps {
}

const LegendToggleComponent = ({ onClick, showLegend, legendPosition }: LegendToggleProps) => {
const legendId = useMemo(() => htmlIdGenerator()('legend'), []);
const { euiTheme } = useEuiTheme();

const baseStyles = useMemo(
Expand Down Expand Up @@ -65,7 +64,6 @@ const LegendToggleComponent = ({ onClick, showLegend, legendPosition }: LegendTo
defaultMessage: 'Toggle legend',
})}
aria-expanded={showLegend}
aria-controls={legendId}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ This aria property is used with the wrong way (the dashboard a11y tests were also complaining)

isSelected={showLegend}
data-test-subj="vislibToggleLegend"
title={i18n.translate('charts.legend.toggleLegendButtonTitle', {
Expand Down
4 changes: 1 addition & 3 deletions test/examples/embeddables/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide
});

it('pie charts', async () => {
if (await PageObjects.visChart.isNewChartsLibraryEnabled()) {
await elasticChart.setNewChartUiDebugFlag();
}
await elasticChart.setNewChartUiDebugFlag();
await pieChart.expectPieSliceCount(5);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

it('causes panels to reload when refresh is clicked', async () => {
await esArchiver.unload('test/functional/fixtures/es_archiver/dashboard/current/data');

await queryBar.clickQuerySubmitButton();
await retry.tryForTime(5000, async () => {
const headers = await PageObjects.discover.getColumnHeaders();
expect(headers.length).to.be(0);
await pieChart.expectPieSliceCount(0);
await pieChart.expectEmptyPieChart();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ We don't have EC debug state for empty charts so I am testing this scenario with the empty chart container.

});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
let visNames: string[] = [];

const expectAllDataRenders = async () => {
await pieChart.expectPieSliceCount(16);
await pieChart.expectSliceCountForAllPies(16);
await dashboardExpect.metricValuesExist(['7,544']);
await dashboardExpect.seriesElementCount(14);
const tsvbGuageExists = await find.existsByCssSelector('.tvbVisHalfGauge');
Expand Down Expand Up @@ -73,7 +73,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
};

const expectNoDataRenders = async () => {
await pieChart.expectPieSliceCount(0);
await pieChart.expectEmptyPieChart();
await dashboardExpect.seriesElementCount(0);
await dashboardExpect.dataTableNoResult();
await dashboardExpect.savedSearchNoResult();
Expand Down Expand Up @@ -112,6 +112,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.preserveCrossAppState();
await PageObjects.dashboard.clickNewDashboard();
await elasticChart.setNewChartUiDebugFlag(true);

const fromTime = 'Jan 1, 2018 @ 00:00:00.000';
const toTime = 'Apr 13, 2018 @ 00:00:00.000';
Expand Down Expand Up @@ -160,6 +161,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('initial render test', async () => {
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.dashboard.waitForRenderComplete();
await elasticChart.setNewChartUiDebugFlag();
await expectAllDataRenders();
});

Expand All @@ -178,9 +180,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const alert = await browser.getAlert();
await alert?.accept();

await elasticChart.setNewChartUiDebugFlag(true);

await PageObjects.header.waitUntilLoadingHasFinished();
await elasticChart.setNewChartUiDebugFlag();
await PageObjects.dashboard.waitForRenderComplete();
await expectAllDataRenders();
});
Expand Down
4 changes: 4 additions & 0 deletions test/functional/apps/dashboard/group1/legacy_urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const listingTable = getService('listingTable');
const kibanaServer = getService('kibanaServer');
const security = getService('security');
const elasticChart = getService('elasticChart');

let kibanaLegacyBaseUrl: string;
let kibanaVisualizeBaseUrl: string;
Expand Down Expand Up @@ -63,6 +64,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const url = `${kibanaLegacyBaseUrl}#/dashboard/${testDashboardId}`;
await browser.get(url, true);
await PageObjects.header.waitUntilLoadingHasFinished();
await elasticChart.setNewChartUiDebugFlag(true);
await PageObjects.timePicker.setDefaultDataRange();

await PageObjects.dashboard.waitForRenderComplete();
Expand All @@ -72,6 +74,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('redirects from legacy hash in wrong app', async () => {
const url = `${kibanaVisualizeBaseUrl}#/dashboard/${testDashboardId}`;
await browser.get(url, true);
await elasticChart.setNewChartUiDebugFlag(true);
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.timePicker.setDefaultDataRange();

Expand Down Expand Up @@ -111,6 +114,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await dashboardAddPanel.addVisualization('legacy url markdown');
(await find.byLinkText('abc')).click();
await PageObjects.header.waitUntilLoadingHasFinished();
await elasticChart.setNewChartUiDebugFlag(true);
await PageObjects.timePicker.setDefaultDataRange();

await PageObjects.dashboard.waitForRenderComplete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const filterBar = getService('filterBar');
const pieChart = getService('pieChart');
const elasticChart = getService('elasticChart');
const kibanaServer = getService('kibanaServer');
const browser = getService('browser');
const queryBar = getService('queryBar');
const security = getService('security');
const PageObjects = getPageObjects([
'common',
Expand Down Expand Up @@ -109,6 +111,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.dashboard.gotoDashboardLandingPage();
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.timePicker.setDefaultDataRange();
await elasticChart.setNewChartUiDebugFlag(true);
});

it('are not selected by default', async function () {
Expand All @@ -119,7 +122,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('are added when a pie chart slice is clicked', async function () {
await dashboardAddPanel.addVisualization('Rendering Test: pie');
await PageObjects.dashboard.waitForRenderComplete();
await pieChart.filterOnPieSlice('4,886');
await pieChart.filterOnPieSlice('4886');
const filterCount = await filterBar.getFilterCount();
expect(filterCount).to.equal(1);

Expand All @@ -129,6 +132,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('are preserved after saving a dashboard', async () => {
await PageObjects.dashboard.saveDashboard('with filters');
await PageObjects.header.waitUntilLoadingHasFinished();
await elasticChart.setNewChartUiDebugFlag(true);

const filterCount = await filterBar.getFilterCount();
expect(filterCount).to.equal(1);
Expand All @@ -140,6 +144,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.dashboard.gotoDashboardLandingPage();
await PageObjects.dashboard.loadSavedDashboard('with filters');
await PageObjects.header.waitUntilLoadingHasFinished();
await elasticChart.setNewChartUiDebugFlag(true);
await queryBar.submitQuery();
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the debug flag not decorate the pie slices until after the query has been submitted?

Copy link
Contributor Author

@stratoula stratoula May 11, 2022

Choose a reason for hiding this comment

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

It needs to be re-rendered (the pie chart) so this is the reason I am submitting the query. If you refresh, the window flag is lost, so you need to do something to re-render it but without refreshing the browser.


const filterCount = await filterBar.getFilterCount();
expect(filterCount).to.equal(1);
Expand All @@ -152,6 +158,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await browser.goForward();
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.dashboard.waitForRenderComplete();
await elasticChart.setNewChartUiDebugFlag(true);
await queryBar.submitQuery();
await pieChart.expectPieSliceCount(1);
});

Expand Down
11 changes: 8 additions & 3 deletions test/functional/apps/dashboard/group2/dashboard_filtering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const dashboardExpect = getService('dashboardExpect');
const pieChart = getService('pieChart');
const queryBar = getService('queryBar');
const elasticChart = getService('elasticChart');
const dashboardAddPanel = getService('dashboardAddPanel');
const renderable = getService('renderable');
const testSubjects = getService('testSubjects');
Expand Down Expand Up @@ -47,6 +48,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await queryBar.clickQuerySubmitButton();
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.dashboard.waitForRenderComplete();
await elasticChart.setNewChartUiDebugFlag(true);
};

before(async () => {
Expand Down Expand Up @@ -85,7 +87,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});

it('filters on pie charts', async () => {
await pieChart.expectPieSliceCount(0);
await pieChart.expectEmptyPieChart();
});

it('area, bar and heatmap charts filtered', async () => {
Expand Down Expand Up @@ -150,7 +152,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});

it('filters on pie charts', async () => {
await pieChart.expectPieSliceCount(0);
await pieChart.expectEmptyPieChart();
});

it('area, bar and heatmap charts filtered', async () => {
Expand Down Expand Up @@ -253,6 +255,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
describe('nested filtering', () => {
before(async () => {
await PageObjects.dashboard.gotoDashboardLandingPage();
await elasticChart.setNewChartUiDebugFlag(true);
});

it('visualization saved with a query filters data', async () => {
Expand Down Expand Up @@ -323,10 +326,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await dashboardAddPanel.addVisualization(
'Filter Test: animals: linked to search with filter'
);
await pieChart.expectPieSliceCount(7);
await elasticChart.setNewChartUiDebugFlag(true);
await pieChart.expectSliceCountForAllPies(7);
});

it('Pie chart linked to saved search filters shows no data with conflicting dashboard query', async () => {
await elasticChart.setNewChartUiDebugFlag(true);
await queryBar.setQuery('weightLbs<40');
await queryBar.submitQuery();
await PageObjects.dashboard.waitForRenderComplete();
Expand Down
17 changes: 14 additions & 3 deletions test/functional/apps/dashboard/group3/bwc_shared_urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['dashboard', 'header']);
const dashboardExpect = getService('dashboardExpect');
const pieChart = getService('pieChart');
const elasticChart = getService('elasticChart');
const browser = getService('browser');
const log = getService('log');
const queryBar = getService('queryBar');
Expand Down Expand Up @@ -41,6 +42,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
`legendOpen:!t))),` +
`viewMode:edit)`;

const enableNewChartLibraryDebug = async () => {
await elasticChart.setNewChartUiDebugFlag();
await queryBar.submitQuery();
};

describe('bwc shared urls', function describeIndexTests() {
before(async function () {
await PageObjects.dashboard.initTests();
Expand Down Expand Up @@ -75,11 +81,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
log.debug(`Navigating to ${url}`);
await browser.get(url, true);
await PageObjects.header.waitUntilLoadingHasFinished();
await elasticChart.setNewChartUiDebugFlag(true);

const query = await queryBar.getQueryString();
expect(query).to.equal('memory:>220000');

await pieChart.expectPieSliceCount(0);
await pieChart.expectEmptyPieChart();
await dashboardExpect.panelCount(2);
await PageObjects.dashboard.waitForRenderComplete();
});
Expand All @@ -92,8 +99,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const url = `${kibanaLegacyBaseUrl}#/dashboard?${urlQuery}`;
log.debug(`Navigating to ${url}`);
await browser.get(url, true);
enableNewChartLibraryDebug();
await PageObjects.header.waitUntilLoadingHasFinished();

const query = await queryBar.getQueryString();
expect(query).to.equal('memory:>220000');

Expand All @@ -113,6 +120,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
log.debug(`Navigating to ${url}`);
await browser.get(url, true);
await PageObjects.header.waitUntilLoadingHasFinished();
enableNewChartLibraryDebug();

const query = await queryBar.getQueryString();
expect(query).to.equal('memory:>220000');
Expand Down Expand Up @@ -146,8 +154,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
log.debug(`Navigating to ${url}`);

await browser.get(url, true);
await elasticChart.setNewChartUiDebugFlag(true);
await PageObjects.header.waitUntilLoadingHasFinished();

await dashboardExpect.selectedLegendColorCount('#000000', 5);
});

Expand All @@ -160,6 +168,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const url = `${kibanaLegacyBaseUrl}#/dashboard?${urlQuery}`;
log.debug(`Navigating to ${url}`);
await browser.get(url);
await elasticChart.setNewChartUiDebugFlag(true);
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.dashboard.waitForRenderComplete();
await dashboardExpect.selectedLegendColorCount('#F9D9F9', 5);
Expand All @@ -169,6 +178,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const newId = await PageObjects.dashboard.getDashboardIdFromCurrentUrl();
expect(newId).to.be.equal(oldId);
await PageObjects.dashboard.waitForRenderComplete();
await elasticChart.setNewChartUiDebugFlag(true);
await queryBar.submitQuery();
await dashboardExpect.selectedLegendColorCount('#000000', 5);
});
});
Expand Down
6 changes: 3 additions & 3 deletions test/functional/apps/dashboard/group3/dashboard_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

describe('dashboard state', function describeIndexTests() {
// Used to track flag before and after reset
let isNewChartsLibraryEnabled = false;
let isNewChartsLibraryEnabled = true;

before(async function () {
isNewChartsLibraryEnabled = await PageObjects.visChart.isNewChartsLibraryEnabled();
await PageObjects.dashboard.initTests();
await PageObjects.dashboard.preserveCrossAppState();
await browser.setLocalStorageItem('data.newDataViewMenu', 'true');

if (isNewChartsLibraryEnabled) {
if (!isNewChartsLibraryEnabled) {
await kibanaServer.uiSettings.update({
'visualization:visualize:legacyPieChartsLibrary': false,
'visualization:visualize:legacyPieChartsLibrary': true,
});
}
await browser.refresh();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const dashboardExpect = getService('dashboardExpect');
const pieChart = getService('pieChart');
const elasticChart = getService('elasticChart');
const dashboardVisualizations = getService('dashboardVisualizations');
const PageObjects = getPageObjects([
'dashboard',
Expand All @@ -31,6 +32,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
before(async function () {
await PageObjects.dashboard.initTests();
await PageObjects.dashboard.preserveCrossAppState();
await elasticChart.setNewChartUiDebugFlag(true);
});

after(async () => {
Expand All @@ -43,7 +45,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('Visualization updated when time picker changes', async () => {
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.addVisualizations([PIE_CHART_VIS_NAME]);
await pieChart.expectPieSliceCount(0);
await pieChart.expectEmptyPieChart();

await PageObjects.timePicker.setHistoricalDataRange();
await pieChart.expectPieSliceCount(10);
Expand Down Expand Up @@ -124,6 +126,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
'2015-09-19 06:31:44.000',
'2015-09-23 18:31:44.000'
);
await elasticChart.setNewChartUiDebugFlag(true);
await pieChart.expectPieSliceCount(10);
});
});
Expand Down
6 changes: 3 additions & 3 deletions test/functional/apps/dashboard/group5/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
describe('dashboard app - group 5', function () {
// TODO: Remove when vislib is removed
// https://github.com/elastic/kibana/issues/56143
describe('new charts library', function () {
describe('old charts library', function () {
before(async () => {
await loadLogstash();
await kibanaServer.uiSettings.update({
'visualization:visualize:legacyPieChartsLibrary': false,
'visualization:visualize:legacyPieChartsLibrary': true,
});
await browser.refresh();
});

after(async () => {
await unloadLogstash();
await kibanaServer.uiSettings.update({
'visualization:visualize:legacyPieChartsLibrary': true,
'visualization:visualize:legacyPieChartsLibrary': false,
});
await browser.refresh();
});
Expand Down
Loading