From 27c04f49600cc88c237c1e50a7ec77f797f0bb40 Mon Sep 17 00:00:00 2001 From: Marco Liberati Date: Mon, 3 Jun 2024 20:39:50 +0200 Subject: [PATCH] feat(legend): improve tooltip wording (#2439) --- e2e/tests/legend_stories.test.ts | 16 ++++--- .../legend/__snapshots__/legend.test.tsx.snap | 24 +++++------ .../charts/src/components/legend/label.tsx | 42 +++++++++++-------- 3 files changed, 44 insertions(+), 38 deletions(-) diff --git a/e2e/tests/legend_stories.test.ts b/e2e/tests/legend_stories.test.ts index 0914cd320d..7b2ad618a0 100644 --- a/e2e/tests/legend_stories.test.ts +++ b/e2e/tests/legend_stories.test.ts @@ -196,13 +196,13 @@ test.describe('Legend stories', () => { '.echLegendItem__label', ); - // check that the first item has a "isolate" title as second line + // check that the first item has a "show" title as third line const initialLabels = await page.evaluate(() => Array.from(document.getElementsByClassName('echLegendItem__label'), (e) => e.getAttribute('title')), ); - expect(initialLabels.map((label) => (label ? label.split('\n')[1] : ''))).toEqual( - new Array(initialLabels.length).fill('Click: isolate series'), + expect(initialLabels.map((label) => (label ? label.split('\n')[2] : ''))).toEqual( + new Array(initialLabels.length).fill('Click to show'), ); // click on the first item @@ -214,8 +214,8 @@ test.describe('Legend stories', () => { const secondRoundLabels = await page.evaluate(() => Array.from(document.getElementsByClassName('echLegendItem__label'), (e) => e.getAttribute('title')), ); - expect(secondRoundLabels.map((label) => (label ? label.split('\n')[1] : ''))).toEqual( - ['Click: show all series'].concat(new Array(secondRoundLabels.length - 1).fill('Click: show series')), + expect(secondRoundLabels.map((label) => (label ? label.split('\n')[2] : ''))).toEqual( + ['Click to show all'].concat(new Array(secondRoundLabels.length - 1).fill('Click to show')), ); // now click on the second item (hidden) @@ -226,10 +226,8 @@ test.describe('Legend stories', () => { const thirdRoundLabels = await page.evaluate(() => Array.from(document.getElementsByClassName('echLegendItem__label'), (e) => e.getAttribute('title')), ); - expect(thirdRoundLabels.map((label) => (label ? label.split('\n')[1] : ''))).toEqual( - ['Click: hide series', 'Click: hide series'].concat( - new Array(secondRoundLabels.length - 2).fill('Click: show series'), - ), + expect(thirdRoundLabels.map((label) => (label ? label.split('\n')[2] : ''))).toEqual( + ['Click to hide', 'Click to hide'].concat(new Array(secondRoundLabels.length - 2).fill('Click to show')), ); }); }); diff --git a/packages/charts/src/components/legend/__snapshots__/legend.test.tsx.snap b/packages/charts/src/components/legend/__snapshots__/legend.test.tsx.snap index b69fc93ed9..9c744723d6 100644 --- a/packages/charts/src/components/legend/__snapshots__/legend.test.tsx.snap +++ b/packages/charts/src/components/legend/__snapshots__/legend.test.tsx.snap @@ -18,7 +18,7 @@ exports[`Legend #legendColorPicker should match snapshot after onChange is calle