Skip to content

Commit

Permalink
testing issue with lens.setPalette
Browse files Browse the repository at this point in the history
  • Loading branch information
nickofthyme committed Aug 23, 2024
1 parent 0fb22f6 commit b1d2ab8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
9 changes: 8 additions & 1 deletion x-pack/test/functional/apps/dashboard/group2/sync_colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await kibanaServer.savedObjects.cleanStandardList();
});

it('should sync colors on dashboard for legacy default palette', async function () {
it('should sync colors on dashboard for legacy default palette - problem test', async function () {
await PageObjects.dashboard.navigateToApp();
await elasticChart.setNewChartUiDebugFlag(true);
await PageObjects.dashboard.clickCreateDashboardPrompt();
Expand All @@ -72,6 +72,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
palette: { mode: 'legacy', id: 'default' },
});
await PageObjects.lens.saveAndReturn();
// at this point the clearing of the `colorMapping` prop on the column is reverted to the default
// with the new color mapping switch enabled, this is driven by is the column has `colorMapping` defined.
await PageObjects.header.waitUntilLoadingHasFinished();

// create filtered xy chart
Expand All @@ -89,6 +91,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
await filterBar.addFilter({ field: 'geo.src', operation: 'is not', value: 'CN' });
await PageObjects.lens.saveAndReturn();
// Same thing happens here...
await PageObjects.header.waitUntilLoadingHasFinished();

// create datatable vis
Expand All @@ -102,6 +105,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
await PageObjects.lens.setTermsNumberOfValues(5);
await PageObjects.lens.setTableDynamicColoring('cell');

// Oddly this call to setPalette on the Table, works fine without the sleeps...
await PageObjects.lens.setPalette('default', true);
await PageObjects.lens.closeDimensionEditor();
await PageObjects.lens.configureDimension({
Expand All @@ -118,6 +123,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.dashboard.waitForRenderComplete();

// This is just pulling all the colors from the 2 xy charts and the table and ensuring all keys are assigned the same color.
// i.e. "CN" -> "#ccc"
const colorMappings1 = Object.entries(
getColorMapping(await PageObjects.dashboard.getPanelChartDebugState(0))
);
Expand Down
13 changes: 10 additions & 3 deletions x-pack/test/functional/page_objects/lens_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1251,13 +1251,15 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
async setPalette(paletteId: string, isLegacy: boolean) {
await testSubjects.click('lns_colorEditing_trigger');
// This action needs to be slowed WAY down, otherwise it will not correctly set the palette
await PageObjects.common.sleep(200);
// These three sleep are what finally fixed the issue for me.
// await PageObjects.common.sleep(200);

await testSubjects.setEuiSwitch(
'lns_colorMappingOrLegacyPalette_switch',
isLegacy ? 'uncheck' : 'check'
);

await PageObjects.common.sleep(200);
// await PageObjects.common.sleep(200);

if (isLegacy) {
await testSubjects.click('lns-palettePicker');
Expand All @@ -1266,9 +1268,14 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
await testSubjects.click('kbnColoring_ColorMapping_PalettePicker');
await testSubjects.click(`kbnColoring_ColorMapping_Palette-${paletteId}`);
}
await PageObjects.common.sleep(200);

// If the debounced value is the root cause, they I would imagine a 1000 sleep here would fix it, but it does not
// maybe it needs to be after the call to `closePaletteEditor`?? idk
// await PageObjects.common.sleep(200);

await this.closePaletteEditor();

// at this point without the sleeps, the value is set locally in the component so it looks correct
},

async closePaletteEditor() {
Expand Down

0 comments on commit b1d2ab8

Please sign in to comment.