mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[8.7] unskip flaky test test/functional/apps/dashboard/group1/embeddable_rendering·ts (#150596) (#150640)
# Backport This will backport the following commits from `main` to `8.7`: - [unskip flaky test test/functional/apps/dashboard/group1/embeddable_rendering·ts (#150596)](https://github.com/elastic/kibana/pull/150596) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Nathan Reese","email":"reese.nathan@elastic.co"},"sourceCommit":{"committedDate":"2023-02-08T21:44:43Z","message":"unskip flaky test test/functional/apps/dashboard/group1/embeddable_rendering·ts (#150596)\n\nFixes https://github.com/elastic/kibana/issues/132865\r\n\r\nflaky test runner\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/1891\r\n\r\nPR fixes flaky test by ensuring window._echDebugStateFlag flag is set\r\nbefore any panel renders.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"4446adb2ee866e08b97b5eb36133b4c701fa726d","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Presentation","release_note:skip","auto-backport","v8.7.0","v8.8.0"],"number":150596,"url":"https://github.com/elastic/kibana/pull/150596","mergeCommit":{"message":"unskip flaky test test/functional/apps/dashboard/group1/embeddable_rendering·ts (#150596)\n\nFixes https://github.com/elastic/kibana/issues/132865\r\n\r\nflaky test runner\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/1891\r\n\r\nPR fixes flaky test by ensuring window._echDebugStateFlag flag is set\r\nbefore any panel renders.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"4446adb2ee866e08b97b5eb36133b4c701fa726d"}},"sourceBranch":"main","suggestedTargetBranches":["8.7"],"targetPullRequestStates":[{"branch":"8.7","label":"v8.7.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/150596","number":150596,"mergeCommit":{"message":"unskip flaky test test/functional/apps/dashboard/group1/embeddable_rendering·ts (#150596)\n\nFixes https://github.com/elastic/kibana/issues/132865\r\n\r\nflaky test runner\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/1891\r\n\r\nPR fixes flaky test by ensuring window._echDebugStateFlag flag is set\r\nbefore any panel renders.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"4446adb2ee866e08b97b5eb36133b4c701fa726d"}}]}] BACKPORT--> Co-authored-by: Nathan Reese <reese.nathan@elastic.co>
This commit is contained in:
parent
d65733109d
commit
ea84378494
3 changed files with 65 additions and 46 deletions
|
@ -27,6 +27,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
const security = getService('security');
|
||||
const dashboardExpect = getService('dashboardExpect');
|
||||
const dashboardAddPanel = getService('dashboardAddPanel');
|
||||
const queryBar = getService('queryBar');
|
||||
const PageObjects = getPageObjects([
|
||||
'common',
|
||||
'dashboard',
|
||||
|
@ -99,8 +100,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
await dashboardExpect.vegaTextsDoNotExist(['5,000']);
|
||||
};
|
||||
|
||||
// Failing: See https://github.com/elastic/kibana/issues/132865
|
||||
describe.skip('dashboard embeddable rendering', function describeIndexTests() {
|
||||
describe('dashboard embeddable rendering', function describeIndexTests() {
|
||||
before(async () => {
|
||||
await security.testUser.setRoles(['kibana_admin', 'animals', 'test_logstash_reader']);
|
||||
await kibanaServer.savedObjects.cleanStandardList();
|
||||
|
@ -130,8 +130,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
});
|
||||
|
||||
it('adding visualizations', async () => {
|
||||
await elasticChart.setNewChartUiDebugFlag(true);
|
||||
|
||||
visNames = await dashboardAddPanel.addEveryVisualization('"Rendering Test"');
|
||||
expect(visNames.length).to.be.equal(24);
|
||||
await dashboardExpect.visualizationsArePresent(visNames);
|
||||
|
@ -162,7 +160,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
it('initial render test', async () => {
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
await PageObjects.dashboard.waitForRenderComplete();
|
||||
await elasticChart.setNewChartUiDebugFlag();
|
||||
await expectAllDataRenders();
|
||||
});
|
||||
|
||||
|
@ -181,8 +178,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
const alert = await browser.getAlert();
|
||||
await alert?.accept();
|
||||
|
||||
// setNewChartUiDebugFlag required because window._echDebugStateFlag flag is reset after refresh
|
||||
await elasticChart.setNewChartUiDebugFlag(true);
|
||||
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
await elasticChart.setNewChartUiDebugFlag();
|
||||
await PageObjects.dashboard.waitForRenderComplete();
|
||||
|
||||
// call query refresh to guarantee all panels are rendered after window._echDebugStateFlag is set
|
||||
await queryBar.clickQuerySubmitButton();
|
||||
await PageObjects.dashboard.waitForRenderComplete();
|
||||
await expectAllDataRenders();
|
||||
});
|
||||
|
|
|
@ -111,17 +111,33 @@ export class ElasticChartService extends FtrService {
|
|||
dataTestSubj?: string,
|
||||
match: number = 0,
|
||||
timeout: number | undefined = undefined
|
||||
): Promise<DebugState | null> {
|
||||
): Promise<DebugState> {
|
||||
const chart = await this.getChart(dataTestSubj, timeout, match);
|
||||
|
||||
try {
|
||||
const visContainer = await chart.findByCssSelector('.echChartStatus');
|
||||
const debugDataString: string | undefined = await visContainer.getAttribute(
|
||||
'data-ech-debug-state'
|
||||
return await this.getChartDebugDataFromChart(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
* used to get chart data from `@elastic/charts`
|
||||
* requires `window._echDebugStateFlag` to be true
|
||||
*/
|
||||
public async getChartDebugDataFromChart(chart: WebElementWrapper): Promise<DebugState> {
|
||||
const visContainer = await chart.findByCssSelector('.echChartStatus');
|
||||
const debugDataString: string | undefined = await visContainer.getAttribute(
|
||||
'data-ech-debug-state'
|
||||
);
|
||||
this.log.debug('data-ech-debug-state: ', debugDataString);
|
||||
|
||||
if (debugDataString === undefined) {
|
||||
throw Error(
|
||||
`Elastic charts debugState not found, ensure 'setNewChartUiDebugFlag' is called before DOM rendering starts.`
|
||||
);
|
||||
return debugDataString ? JSON.parse(debugDataString) : null;
|
||||
}
|
||||
|
||||
try {
|
||||
return JSON.parse(debugDataString);
|
||||
} catch (error) {
|
||||
throw Error('Elastic charts debugState not found');
|
||||
throw Error('Unable to parse Elastic charts debugState');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
import expect from '@kbn/expect';
|
||||
import { isNil } from 'lodash';
|
||||
import { DebugState } from '@elastic/charts';
|
||||
import { FtrService } from '../../ftr_provider_context';
|
||||
|
||||
const partitionVisChartSelector = 'partitionVisChart';
|
||||
|
@ -20,6 +21,7 @@ export class PieChartService extends FtrService {
|
|||
private readonly testSubjects = this.ctx.getService('testSubjects');
|
||||
private readonly find = this.ctx.getService('find');
|
||||
private readonly panelActions = this.ctx.getService('dashboardPanelActions');
|
||||
private readonly elasticChart = this.ctx.getService('elasticChart');
|
||||
private readonly defaultFindTimeout = this.config.get('timeouts.find');
|
||||
private readonly visChart = this.ctx.getPageObject('visChart');
|
||||
|
||||
|
@ -28,9 +30,9 @@ export class PieChartService extends FtrService {
|
|||
async clickOnPieSlice(name?: string) {
|
||||
this.log.debug(`PieChart.clickOnPieSlice(${name})`);
|
||||
if (await this.visChart.isNewLibraryChart(partitionVisChartSelector)) {
|
||||
const slices =
|
||||
(await this.visChart.getEsChartDebugState(partitionVisChartSelector))?.partition?.[0]
|
||||
?.partitions ?? [];
|
||||
const slices = this.getSlices(
|
||||
await this.visChart.getEsChartDebugState(partitionVisChartSelector)
|
||||
);
|
||||
let sliceLabel = name || slices[0].name;
|
||||
if (name === 'Other') {
|
||||
sliceLabel = '__other__';
|
||||
|
@ -89,9 +91,9 @@ export class PieChartService extends FtrService {
|
|||
async getPieSliceStyle(name: string) {
|
||||
this.log.debug(`VisualizePage.getPieSliceStyle(${name})`);
|
||||
if (await this.visChart.isNewLibraryChart(partitionVisChartSelector)) {
|
||||
const slices =
|
||||
(await this.visChart.getEsChartDebugState(partitionVisChartSelector))?.partition?.[0]
|
||||
?.partitions ?? [];
|
||||
const slices = this.getSlices(
|
||||
await this.visChart.getEsChartDebugState(partitionVisChartSelector)
|
||||
);
|
||||
const selectedSlice = slices.filter((slice) => {
|
||||
return slice.name.toString() === name.replace(',', '');
|
||||
});
|
||||
|
@ -103,9 +105,9 @@ export class PieChartService extends FtrService {
|
|||
|
||||
async getAllPieSlicesColors() {
|
||||
const slicesColors = [];
|
||||
const slices =
|
||||
(await this.visChart.getEsChartDebugState(partitionVisChartSelector))?.partition?.[0]
|
||||
?.partitions ?? [];
|
||||
const slices = this.getSlices(
|
||||
await this.visChart.getEsChartDebugState(partitionVisChartSelector)
|
||||
);
|
||||
for (const slice of slices) {
|
||||
slicesColors.push(slice.color);
|
||||
}
|
||||
|
@ -115,9 +117,9 @@ export class PieChartService extends FtrService {
|
|||
async getAllPieSliceColor(name: string) {
|
||||
this.log.debug(`VisualizePage.getAllPieSliceColor(${name})`);
|
||||
if (await this.visChart.isNewLibraryChart(partitionVisChartSelector)) {
|
||||
const slices =
|
||||
(await this.visChart.getEsChartDebugState(partitionVisChartSelector))?.partition?.[0]
|
||||
?.partitions ?? [];
|
||||
const slices = this.getSlices(
|
||||
await this.visChart.getEsChartDebugState(partitionVisChartSelector)
|
||||
);
|
||||
const selectedSlice = slices.filter((slice) => {
|
||||
return slice.name.toString() === name.replace(',', '');
|
||||
});
|
||||
|
@ -155,9 +157,9 @@ export class PieChartService extends FtrService {
|
|||
|
||||
async getPieChartLabels(isNewLibrary: boolean = true) {
|
||||
if (isNewLibrary) {
|
||||
const slices =
|
||||
(await this.visChart.getEsChartDebugState(partitionVisChartSelector))?.partition?.[0]
|
||||
?.partitions ?? [];
|
||||
const slices = this.getSlices(
|
||||
await this.visChart.getEsChartDebugState(partitionVisChartSelector)
|
||||
);
|
||||
return slices.map((slice) => {
|
||||
if (slice.name === '__missing__') {
|
||||
return 'Missing';
|
||||
|
@ -181,9 +183,9 @@ export class PieChartService extends FtrService {
|
|||
async getPieChartValues(isNewLibrary: boolean = true) {
|
||||
this.log.debug('PieChart.getPieChartValues');
|
||||
if (isNewLibrary) {
|
||||
const slices =
|
||||
(await this.visChart.getEsChartDebugState(partitionVisChartSelector))?.partition?.[0]
|
||||
?.partitions ?? [];
|
||||
const slices = this.getSlices(
|
||||
await this.visChart.getEsChartDebugState(partitionVisChartSelector)
|
||||
);
|
||||
return slices.map((slice) => {
|
||||
return slice.value;
|
||||
});
|
||||
|
@ -197,9 +199,9 @@ export class PieChartService extends FtrService {
|
|||
async getPieSliceCount(isNewLibrary: boolean = true) {
|
||||
this.log.debug('PieChart.getPieSliceCount');
|
||||
if (isNewLibrary) {
|
||||
const slices =
|
||||
(await this.visChart.getEsChartDebugState(partitionVisChartSelector))?.partition?.[0]
|
||||
?.partitions ?? [];
|
||||
const slices = this.getSlices(
|
||||
await this.visChart.getEsChartDebugState(partitionVisChartSelector)
|
||||
);
|
||||
return slices?.length;
|
||||
}
|
||||
const slices = await this.find.allByCssSelector('svg > g > g.arcs > path.slice');
|
||||
|
@ -214,23 +216,21 @@ export class PieChartService extends FtrService {
|
|||
this.log.debug(`Found ${charts.length} charts`);
|
||||
for (const chart of charts) {
|
||||
await chart.moveMouseTo();
|
||||
const visContainer = await chart.findByCssSelector('.echChartStatus');
|
||||
const debugDataString: string | undefined = await visContainer.getAttribute(
|
||||
'data-ech-debug-state'
|
||||
);
|
||||
if (debugDataString) {
|
||||
const parsedData = JSON.parse(debugDataString);
|
||||
const partition = parsedData?.partition?.[0] ?? [];
|
||||
pieSlices += partition.partitions.length;
|
||||
}
|
||||
const pieChartData = await this.elasticChart.getChartDebugDataFromChart(chart);
|
||||
const slices = this.getSlices(pieChartData);
|
||||
pieSlices += slices.length;
|
||||
}
|
||||
return pieSlices;
|
||||
}
|
||||
|
||||
getSlices(pieChartData: DebugState) {
|
||||
return pieChartData?.partition?.[0]?.partitions ?? [];
|
||||
}
|
||||
|
||||
async expectPieSliceCountEsCharts(expectedCount: number) {
|
||||
const slices =
|
||||
(await this.visChart.getEsChartDebugState(partitionVisChartSelector))?.partition?.[0]
|
||||
?.partitions ?? [];
|
||||
const slices = this.getSlices(
|
||||
await this.visChart.getEsChartDebugState(partitionVisChartSelector)
|
||||
);
|
||||
expect(slices.length).to.be(expectedCount);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue