Skip to content

Commit

Permalink
fix color matching on functional test
Browse files Browse the repository at this point in the history
  • Loading branch information
markov00 committed Oct 7, 2021
1 parent 813c281 commit 61abc36
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/functional/page_objects/visualize_chart_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { Position } from '@elastic/charts';
import Color from 'color';
import chroma from 'chroma-js';

import { FtrService } from '../ftr_provider_context';

Expand Down Expand Up @@ -181,17 +181,17 @@ export class VisualizeChartPageObject extends FtrService {
return items.some(({ color: c }) => c === color);
}

public async doesSelectedLegendColorExistForPie(color: string) {
public async doesSelectedLegendColorExistForPie(matchingColor: string) {
if (await this.isNewLibraryChart(pieChartSelector)) {
const hexMatchingColor = chroma(matchingColor).hex().toUpperCase();
const slices =
(await this.getEsChartDebugState(pieChartSelector))?.partition?.[0]?.partitions ?? [];
return slices.some(({ color: c }) => {
const rgbColor = new Color(color).rgb().toString();
return c === rgbColor;
return slices.some(({ color }) => {
return hexMatchingColor === chroma(color).hex().toUpperCase();
});
}

return await this.testSubjects.exists(`legendSelectedColor-${color}`);
return await this.testSubjects.exists(`legendSelectedColor-${matchingColor}`);
}

public async expectError() {
Expand Down

0 comments on commit 61abc36

Please sign in to comment.