From 8ed087da65d0e23769a4f9d5f71a53e684a918ef Mon Sep 17 00:00:00 2001 From: srmukher Date: Thu, 2 Mar 2023 15:41:16 +0530 Subject: [PATCH 1/6] Donut chart component testing --- ...-053d3178-4089-4eb8-af55-9706b4484337.json | 7 + .../docs/Component tests/BasicDonutChart.png | Bin 0 -> 12801 bytes .../Component tests/DonutChartTestPlan.md | 48 + packages/react-charting/jest.config.js | 2 +- .../components/DonutChart/DonutChart.test.tsx | 24 +- .../DonutChart/DonutChartRTL.test.tsx | 108 + .../__snapshots__/DonutChartRTL.test.tsx.snap | 2660 +++++++++++++++++ packages/react-charting/tsconfig.json | 2 +- 8 files changed, 2848 insertions(+), 3 deletions(-) create mode 100644 change/@fluentui-react-charting-053d3178-4089-4eb8-af55-9706b4484337.json create mode 100644 packages/react-charting/docs/Component tests/BasicDonutChart.png create mode 100644 packages/react-charting/docs/Component tests/DonutChartTestPlan.md create mode 100644 packages/react-charting/src/components/DonutChart/DonutChartRTL.test.tsx create mode 100644 packages/react-charting/src/components/DonutChart/__snapshots__/DonutChartRTL.test.tsx.snap diff --git a/change/@fluentui-react-charting-053d3178-4089-4eb8-af55-9706b4484337.json b/change/@fluentui-react-charting-053d3178-4089-4eb8-af55-9706b4484337.json new file mode 100644 index 0000000000000..a48947a68702c --- /dev/null +++ b/change/@fluentui-react-charting-053d3178-4089-4eb8-af55-9706b4484337.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "Added component tests for donut chart", + "packageName": "@fluentui/react-charting", + "email": "srmukher@microsoft.com", + "dependentChangeType": "none" +} diff --git a/packages/react-charting/docs/Component tests/BasicDonutChart.png b/packages/react-charting/docs/Component tests/BasicDonutChart.png new file mode 100644 index 0000000000000000000000000000000000000000..847d9ffb767fd2aa4ac2ba98074384ee3d642d35 GIT binary patch literal 12801 zcmdUWWmweF*WeF^F6oXTL_%PYQgY~)?iLUw1O)`C84$2YrIZ!{>Fx#vM3D|j6(ppj zrDpby|M%V9FZ*G??eaW4%)NK+x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C3tV==;q$g<&O{U(KxmH)apFPXGyY4Cp-2*Sc0_t3&qY@v&HIu5sd8@6Ms7x#QV!)?`=(XS#tI_hyW+M%j{ zM9!VnnC}FHZ$825y2mXN$04XQ1_AL=UlowEoa9YavggHmOc*)$i<%Rq6*P(B~H*LG~v_X`;4y)U~ru?~@WQQ@XEL}*Ehv$oZbqxVi4+Fl7pWh zaLnx8l_h=Ps#KZ+N;8SV*`>)PS;fgHRKZQ0;gSlPpWn%ynr&U3_;Jw~b4};*XY~3d zXj!2fqUM=NI3v<%wfW=Mb&Fpq*CV@d0`^0V8G<_RN8&*cyXOC=AD8u54z!<>z|LGJ=BEAQ&oFBqsBe?TfPHYL|3BMasxkNTG4&wV zCv{!3qKk(8^}3;M;B@~N8j;~FW70$rih_V$fboI5=}{_V>Szm%5vU)3%3nB6 z8n{R$@LkNWQrgcFJF+Z2-$_3RoXd7Kve%2>TXQqA%$@EtG|V0?3Pk)bBj&xJH89Y zKxb2>fY%-T)uQh?phF~b2yKv)?X)=^X}g1A@QA;W%rddJx!4n&k$$?&ZGKw zzh}F2!L>hG>u*qeh$Z^lTJb`Gv<44L+)U7M%UJ zPv-P~YlRH9iHY_nX2Fsi#vU8EyTLhc@-(UUZ z17@v13Sov%V-YdgJcg0sosqMYOPZ7v44~?=7XIj_gFXwRF&PX)52~1Ppikw$9U>qW2)OvSc`~UjeM=_+Z z-c)^+s~f$bjaaW&L0Q8wyOwmESjz*WCe%czvFs^m+C*?u^99I+|ES{YMk4SLsV$`6 zsevEZJ3c&Cl;k2wu{ISu=$oD`BW+E6w!ir#B7_vSFWwCjTTsz| u^Y?#`An5z`ZtyP=aX^g!pZh48h{dDstR|Zwc3lEELfYy#)yh>IBmM`M$p<(9 literal 0 HcmV?d00001 diff --git a/packages/react-charting/docs/Component tests/DonutChartTestPlan.md b/packages/react-charting/docs/Component tests/DonutChartTestPlan.md new file mode 100644 index 0000000000000..e8371067bb6cd --- /dev/null +++ b/packages/react-charting/docs/Component tests/DonutChartTestPlan.md @@ -0,0 +1,48 @@ +
+ +# Component testing - Donut chart test plan + +![Alt text](BasicDonutChart.png) + +## Subcomponents: Pie and Legend + +## Library used: jest and (enzyme or react testing library) + +
+ +### Test case 1: [Snapshot testing] [Component] + +- Renders donut chart correctly with data. - [enzyme] + +### Test case 2: [Snapshot testing] [Individual Props] Renders donut chart with: + +- HideTooltip prop set to “true”. - [enzyme] +- HideLegend prop set to “true”. - [enzyme] +- EnabledLegendsWrapLines prop set to “true”. - [enzyme] +- ValueInsideDonut set to a string / number. - [enzyme] + +### Test case 3: [Specific DOM elements] Renders individual elements on a prop change: + +- Should mount legend when hideLegend prop is set to “false”. - [enzyme] +- Should mount callout when hideTootip prop is set to “false”. - [enzyme] +- Should not render onRenderCalloutPerStack with just data as a prop. - [enzyme] +- Should render onRenderCalloutPerDataPoint when the prop is given otherwise should not render onRenderCalloutPerDataPoint. - [enzyme] + +### Test case 4: [Mouse events – Donut chart] Renders individual elements on mouse events: + +- On mouseOver on the donut chart should render callout. - [enzyme] +- On mouseMove on Pie 1 (step 1) -> mouseLeave (step 2) -> mouseMove on Pie 2 (step 3), html in step 1 should not be the same as in step 3. - [enzyme] +- On mouseover with onRenderCalloutPerDataPoint prop provided, should render the custom callout. [enzyme] +- On mouseOver, callout should be defined, on mouseLeave, callout should disappear. - [enzyme] + +### Test case 5: [Mouse events – Legends] Renders individual elements on mouse events: + +- On mouseOver should highlight the corresponding pie. - [RTL] +- On mouseOver should change the value inside donut with the legend value. - [enzyme] +- On click should highlight the corresponding pie with aria-selected set to “true” and tabIndex set to 0. - [RTL] +- On mouseOut after mouseOver on first legend, should have opacity 0.1 for second Pie initially (during mouseOver on first legend) and opacity set to 1 for both the Pies on mouseOut. - [RTL] + +### Test case 6: [Keyboard events – Donut chart] Renders individual elements on keyboard events: + +- On focus should render the corresponding callout. - [RTL] +- On blur should remove focus from the corresponding Pie. - [RTL] diff --git a/packages/react-charting/jest.config.js b/packages/react-charting/jest.config.js index b70cd24668eeb..45c4007353a3c 100644 --- a/packages/react-charting/jest.config.js +++ b/packages/react-charting/jest.config.js @@ -19,7 +19,7 @@ function getEsmOnlyPackagesToCjsMapping() { const config = createConfig({ setupFiles: ['./config/tests.js'], snapshotSerializers: ['@fluentui/jest-serializer-merge-styles', 'enzyme-to-json/serializer'], - + setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'], moduleNameMapper: { ...getEsmOnlyPackagesToCjsMapping(), }, diff --git a/packages/react-charting/src/components/DonutChart/DonutChart.test.tsx b/packages/react-charting/src/components/DonutChart/DonutChart.test.tsx index 1477ef848e737..c5434c24f05a3 100644 --- a/packages/react-charting/src/components/DonutChart/DonutChart.test.tsx +++ b/packages/react-charting/src/components/DonutChart/DonutChart.test.tsx @@ -36,7 +36,7 @@ const points: IChartDataPoint[] = [ const chartTitle = 'Stacked Bar chart example'; -const chartPoints: IChartProps = { +export const chartPoints: IChartProps = { chartTitle: chartTitle, chartData: points, }; @@ -159,4 +159,26 @@ describe('DonutChart - mouse events', () => { const tree = toJson(wrapper, { mode: 'deep' }); expect(tree).toMatchSnapshot(); }); + + it('Should change value inside donut with the legend value on mouseOver legend ', () => { + // Arrange + wrapper = mount(); + + // Act + wrapper.find('LegendsBase').find('button').at(0).simulate('mouseover'); + + // Assert + expect( + wrapper + .findWhere(node => node.hasClass(/insideDonutString.*?/)) + .at(0) + .text(), + ).toBe('20,000'); + expect( + wrapper + .findWhere(node => node.hasClass(/insideDonutString.*?/)) + .at(1) + .text(), + ).toBe('20,000'); + }); }); diff --git a/packages/react-charting/src/components/DonutChart/DonutChartRTL.test.tsx b/packages/react-charting/src/components/DonutChart/DonutChartRTL.test.tsx new file mode 100644 index 0000000000000..f1d2a11cc6d9d --- /dev/null +++ b/packages/react-charting/src/components/DonutChart/DonutChartRTL.test.tsx @@ -0,0 +1,108 @@ +import { render, screen, queryAllByAttribute, fireEvent } from '@testing-library/react'; +import { chartPoints } from './DonutChart.test'; +import { DonutChart } from './index'; +import * as React from 'react'; + +test('Should hide callout on mouse leave', () => { + // Arrange + const { container } = render(); + + // Act + const getById = queryAllByAttribute.bind(null, 'id'); + fireEvent.mouseOver(getById(container, /Pie/i)[0]); + expect(getById(container, /callout/i)[0]).toBeDefined(); + fireEvent.mouseLeave(getById(container, /Pie/i)[0]); + + // Assert + expect(getById(container, /callout/i)[0]).toHaveStyle('opacity: 0'); +}); + +test('Should show callout on focus', () => { + // Arrange + const { container } = render(); + + // Act + const getById = queryAllByAttribute.bind(null, 'id'); + fireEvent.focus(getById(container, /Pie/i)[0]); + + // Assert + expect(getById(container, /focusRing/i)).toBeDefined(); +}); + +test('Should remove focus on blur', () => { + // Arrange + const { container } = render(); + + // Act + const getById = queryAllByAttribute.bind(null, 'id'); + fireEvent.blur(getById(container, /Pie/i)[0]); + + // Assert + const value = getById(container, /Pie/i)[0].getAttribute('id'); + expect(value).not.toContain('focusRing'); +}); + +test('Should highlight the corresponding Pie on mouse over on legends', () => { + // Arrange + const { container } = render(); + + // Act + const legend = screen.queryByText('first'); + fireEvent.mouseOver(legend!); + + // Assert + const getById = queryAllByAttribute.bind(null, 'id'); + expect(getById(container, /Pie.*?second/i)[0]).toHaveAttribute('opacity', '0.1'); +}); + +test('Should select legend on single mouse click on legends', () => { + // Arrange + const { container } = render(); + + // Act + const legend = screen.queryByText('first'); + fireEvent.click(legend!); + + // Assert + const getById = queryAllByAttribute.bind(null, 'id'); + expect(getById(container, /Pie.*?second/i)[0]).toHaveAttribute('opacity', '0.1'); + const firstLegend = screen.queryByText('first')?.closest('button'); + expect(firstLegend).toHaveAttribute('aria-selected', 'true'); + expect(firstLegend).toHaveAttribute('tabIndex', '0'); +}); + +test('Should deselect legend on double mouse click on legends', () => { + // Arrange + const { container } = render(); + + // Act + const legend = screen.queryByText('first'); + //single click on first legend + fireEvent.click(legend!); + const getById = queryAllByAttribute.bind(null, 'id'); + expect(getById(container, /Pie.*?second/i)[0]).toHaveAttribute('opacity', '0.1'); + const firstLegend = screen.queryByText('first')?.closest('button'); + expect(firstLegend).toHaveAttribute('aria-selected', 'true'); + expect(firstLegend).toHaveAttribute('tabIndex', '0'); + // double click on same first legend + fireEvent.click(legend!); + + // Assert + expect(firstLegend).toHaveAttribute('aria-selected', 'false'); +}); + +test('Should show Pies with same opacity on mouse out of legends', () => { + // Arrange + const { container } = render(); + + // Act + const legend = screen.queryByText('first'); + fireEvent.mouseOver(legend!); + const getById = queryAllByAttribute.bind(null, 'id'); + expect(getById(container, /Pie.*?second/i)[0]).toHaveAttribute('opacity', '0.1'); + fireEvent.mouseOut(legend!); + + // Assert + expect(getById(container, /Pie.*?first/i)[0]).toHaveAttribute('opacity', '1'); + expect(getById(container, /Pie.*?second/i)[0]).toHaveAttribute('opacity', '1'); +}); diff --git a/packages/react-charting/src/components/DonutChart/__snapshots__/DonutChartRTL.test.tsx.snap b/packages/react-charting/src/components/DonutChart/__snapshots__/DonutChartRTL.test.tsx.snap new file mode 100644 index 0000000000000..2b9bd2d1f049c --- /dev/null +++ b/packages/react-charting/src/components/DonutChart/__snapshots__/DonutChartRTL.test.tsx.snap @@ -0,0 +1,2660 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DonutChart - mouse events Should render callout correctly on mouseover 1`] = ` +
+
+
+ + + + + + + + + + + + +
+
+
+ +
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+`; + +exports[`DonutChart - mouse events Should render customized callout on mouseover 1`] = ` +
+
+
+ + + + + + + + + + + + +
+
+
+ +
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+`; + +exports[`DonutChart snapShot testing renders DonutChart correctly 1`] = ` +
+
+
+ + + + + + + + + + + + +
+
+ +
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+`; + +exports[`DonutChart snapShot testing renders enabledLegendsWrapLines correctly 1`] = ` +
+
+
+ + + + + + + + + + + + +
+
+ +
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+`; + +exports[`DonutChart snapShot testing renders hideLegend correctly 1`] = ` +
+
+
+ + + + + + + + + + + + +
+
+ +
+`; + +exports[`DonutChart snapShot testing renders hideTooltip correctly 1`] = ` +
+
+
+ + + + + + + + + + + + +
+
+ +
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+`; + +exports[`DonutChart snapShot testing renders value inside onf the pie 1`] = ` +
+
+
+ + + + + + 1,000 + + + + + + 1,000 + + + + +
+
+ +
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+`; diff --git a/packages/react-charting/tsconfig.json b/packages/react-charting/tsconfig.json index d9e220a59c215..0c2581357d8c0 100644 --- a/packages/react-charting/tsconfig.json +++ b/packages/react-charting/tsconfig.json @@ -19,7 +19,7 @@ "skipLibCheck": true, "lib": ["es5", "dom"], "typeRoots": ["../../node_modules/@types", "../../typings"], - "types": ["jest", "custom-global"], + "types": ["jest", "custom-global", "@testing-library/jest-dom"], "isolatedModules": true }, "include": ["src"] From c73df2832aeb78972548557b52681ce95e209744 Mon Sep 17 00:00:00 2001 From: srmukher Date: Mon, 27 Mar 2023 15:22:22 +0530 Subject: [PATCH 2/6] Resolving PR comments --- .../BasicDonutChart.png | Bin .../DonutChartTestPlan.md | 0 .../components/DonutChart/DonutChart.test.tsx | 23 +- .../DonutChart/DonutChartRTL.test.tsx | 93 +- .../__snapshots__/DonutChart.test.tsx.snap | 899 ++++- .../__snapshots__/DonutChartRTL.test.tsx.snap | 3040 ++++++++++++++++- 6 files changed, 3951 insertions(+), 104 deletions(-) rename packages/react-charting/docs/{Component tests => ComponentTests}/BasicDonutChart.png (100%) rename packages/react-charting/docs/{Component tests => ComponentTests}/DonutChartTestPlan.md (100%) diff --git a/packages/react-charting/docs/Component tests/BasicDonutChart.png b/packages/react-charting/docs/ComponentTests/BasicDonutChart.png similarity index 100% rename from packages/react-charting/docs/Component tests/BasicDonutChart.png rename to packages/react-charting/docs/ComponentTests/BasicDonutChart.png diff --git a/packages/react-charting/docs/Component tests/DonutChartTestPlan.md b/packages/react-charting/docs/ComponentTests/DonutChartTestPlan.md similarity index 100% rename from packages/react-charting/docs/Component tests/DonutChartTestPlan.md rename to packages/react-charting/docs/ComponentTests/DonutChartTestPlan.md diff --git a/packages/react-charting/src/components/DonutChart/DonutChart.test.tsx b/packages/react-charting/src/components/DonutChart/DonutChart.test.tsx index c5434c24f05a3..470b92ad9ca31 100644 --- a/packages/react-charting/src/components/DonutChart/DonutChart.test.tsx +++ b/packages/react-charting/src/components/DonutChart/DonutChart.test.tsx @@ -32,6 +32,7 @@ function sharedAfterEach() { const points: IChartDataPoint[] = [ { legend: 'first', data: 20000, color: '#E5E5E5', xAxisCalloutData: '2020/04/30' }, { legend: 'second', data: 39000, color: '#0078D4', xAxisCalloutData: '2020/04/20' }, + { legend: 'third', data: 45000, color: '#DADADA', xAxisCalloutData: '2020/04/25' }, ]; const chartTitle = 'Stacked Bar chart example'; @@ -159,26 +160,4 @@ describe('DonutChart - mouse events', () => { const tree = toJson(wrapper, { mode: 'deep' }); expect(tree).toMatchSnapshot(); }); - - it('Should change value inside donut with the legend value on mouseOver legend ', () => { - // Arrange - wrapper = mount(); - - // Act - wrapper.find('LegendsBase').find('button').at(0).simulate('mouseover'); - - // Assert - expect( - wrapper - .findWhere(node => node.hasClass(/insideDonutString.*?/)) - .at(0) - .text(), - ).toBe('20,000'); - expect( - wrapper - .findWhere(node => node.hasClass(/insideDonutString.*?/)) - .at(1) - .text(), - ).toBe('20,000'); - }); }); diff --git a/packages/react-charting/src/components/DonutChart/DonutChartRTL.test.tsx b/packages/react-charting/src/components/DonutChart/DonutChartRTL.test.tsx index f1d2a11cc6d9d..30a88ca90f8ec 100644 --- a/packages/react-charting/src/components/DonutChart/DonutChartRTL.test.tsx +++ b/packages/react-charting/src/components/DonutChart/DonutChartRTL.test.tsx @@ -1,7 +1,10 @@ -import { render, screen, queryAllByAttribute, fireEvent } from '@testing-library/react'; +import { render, screen, queryAllByAttribute, fireEvent, act } from '@testing-library/react'; import { chartPoints } from './DonutChart.test'; import { DonutChart } from './index'; import * as React from 'react'; +import { DarkTheme } from '@fluentui/theme-samples'; +import { ThemeProvider } from '@fluentui/react'; +import * as utils from '../../utilities/utilities'; test('Should hide callout on mouse leave', () => { // Arrange @@ -15,6 +18,7 @@ test('Should hide callout on mouse leave', () => { // Assert expect(getById(container, /callout/i)[0]).toHaveStyle('opacity: 0'); + expect(container).toMatchSnapshot(); }); test('Should show callout on focus', () => { @@ -106,3 +110,90 @@ test('Should show Pies with same opacity on mouse out of legends', () => { expect(getById(container, /Pie.*?first/i)[0]).toHaveAttribute('opacity', '1'); expect(getById(container, /Pie.*?second/i)[0]).toHaveAttribute('opacity', '1'); }); + +test('Should display correct callout data on mouse move', () => { + // Arrange + const { container } = render(); + + // Act + const getById = queryAllByAttribute.bind(null, 'id'); + fireEvent.mouseOver(getById(container, /Pie/i)[0]); + expect(getById(container, /callout/i)[0]).toHaveTextContent('20,000'); + fireEvent.mouseLeave(getById(container, /Pie/i)[0]); + fireEvent.mouseOver(getById(container, /Pie/i)[1]); + + // Assert + expect(getById(container, /callout/i)[0]).toHaveTextContent('39,000'); +}); + +test('Should reflect theme change', () => { + // Arrange + const { container } = render( + + + , + ); + + // Assert + expect(container).toMatchSnapshot(); +}); + +describe('Screen resolution', () => { + const originalInnerWidth = global.innerWidth; + const originalInnerHeight = global.innerHeight; + afterEach(() => { + global.innerWidth = originalInnerWidth; + global.innerHeight = originalInnerHeight; + act(() => { + global.dispatchEvent(new Event('resize')); + }); + }); + + test('Should remain unchanged on zoom in', () => { + // Arrange + const { container } = render(); + + // Act + global.innerWidth = window.innerWidth / 2; + global.innerHeight = window.innerHeight / 2; + act(() => { + global.dispatchEvent(new Event('resize')); + }); + + // Assert + expect(container).toMatchSnapshot(); + }); + + test('Should remain unchanged on zoom out', () => { + // Arrange + const { container } = render(); + + // Act + global.innerWidth = window.innerWidth * 2; + global.innerHeight = window.innerHeight * 2; + act(() => { + global.dispatchEvent(new Event('resize')); + }); + + // Assert + expect(container).toMatchSnapshot(); + }); +}); + +test('Should change value inside donut with the legend value on mouseOver legend ', () => { + // Mock the implementation of wrapTextInsideDonut as it internally calls a Browser Function like + // getComputedTextLength() which will otherwise lead to a crash if mounted + jest.spyOn(utils, 'wrapTextInsideDonut').mockImplementation(() => '1000'); + // Arrange + const { container } = render( + , + ); + const getByClass = queryAllByAttribute.bind(null, 'class'); + + // Act + fireEvent.mouseOver(screen.getByText('first')); + + // Assert + expect(getByClass(container, /insideDonutString.*?/)[0].textContent).toBe('20,000'); + expect(getByClass(container, /insideDonutString.*?/)[1].textContent).toBe('20,000'); +}); diff --git a/packages/react-charting/src/components/DonutChart/__snapshots__/DonutChart.test.tsx.snap b/packages/react-charting/src/components/DonutChart/__snapshots__/DonutChart.test.tsx.snap index 2b9bd2d1f049c..5936d7e68ef54 100644 --- a/packages/react-charting/src/components/DonutChart/__snapshots__/DonutChart.test.tsx.snap +++ b/packages/react-charting/src/components/DonutChart/__snapshots__/DonutChart.test.tsx.snap @@ -59,7 +59,7 @@ exports[`DonutChart - mouse events Should render callout correctly on mouseover &::-moz-focus-inner { border: 0; } - d="M0.5499908333791704,-54.99725002291659A55,55,0,0,1,46.728934607128515,29.007010712631306L0,0Z" + d="M0.5499908333791704,-54.99725002291659A55,55,0,0,1,51.395827471597144,-19.582362434339235L0,0Z" data-is-focusable={true} id="_Pie_1first20000" onBlur={[Function]} @@ -98,7 +98,7 @@ exports[`DonutChart - mouse events Should render callout correctly on mouseover &::-moz-focus-inner { border: 0; } - d="M46.13948759271731,29.935725892008794A55,55,0,1,1,-0.5499908333792137,-54.99725002291659L0,0Z" + d="M51.7771697881295,-18.550598069367183A55,55,0,0,1,-22.36997379463645,50.245241291362895L0,0Z" data-is-focusable={true} id="_Pie_1second39000" onBlur={[Function]} @@ -123,6 +123,45 @@ exports[`DonutChart - mouse events Should render callout correctly on mouseover y={5} /> + + + + @@ -365,7 +404,7 @@ exports[`DonutChart - mouse events Should render callout correctly on mouseover aria-label="first selected" aria-posinset={1} aria-selected={false} - aria-setsize={2} + aria-setsize={3} className= { @@ -456,7 +495,7 @@ exports[`DonutChart - mouse events Should render callout correctly on mouseover aria-label="second selected" aria-posinset={2} aria-selected={false} - aria-setsize={2} + aria-setsize={3} className= { @@ -533,6 +572,97 @@ exports[`DonutChart - mouse events Should render callout correctly on mouseover +
+ +
@@ -602,7 +732,7 @@ exports[`DonutChart - mouse events Should render customized callout on mouseover &::-moz-focus-inner { border: 0; } - d="M0.5499908333791704,-54.99725002291659A55,55,0,0,1,46.728934607128515,29.007010712631306L0,0Z" + d="M0.5499908333791704,-54.99725002291659A55,55,0,0,1,51.395827471597144,-19.582362434339235L0,0Z" data-is-focusable={true} id="_Pie_1first20000" onBlur={[Function]} @@ -641,7 +771,7 @@ exports[`DonutChart - mouse events Should render customized callout on mouseover &::-moz-focus-inner { border: 0; } - d="M46.13948759271731,29.935725892008794A55,55,0,1,1,-0.5499908333792137,-54.99725002291659L0,0Z" + d="M51.7771697881295,-18.550598069367183A55,55,0,0,1,-22.36997379463645,50.245241291362895L0,0Z" data-is-focusable={true} id="_Pie_1second39000" onBlur={[Function]} @@ -666,6 +796,45 @@ exports[`DonutChart - mouse events Should render customized callout on mouseover y={5} /> + + + + @@ -826,7 +995,7 @@ exports[`DonutChart - mouse events Should render customized callout on mouseover aria-label="first selected" aria-posinset={1} aria-selected={false} - aria-setsize={2} + aria-setsize={3} className= { @@ -917,7 +1086,7 @@ exports[`DonutChart - mouse events Should render customized callout on mouseover aria-label="second selected" aria-posinset={2} aria-selected={false} - aria-setsize={2} + aria-setsize={3} className= { @@ -994,6 +1163,97 @@ exports[`DonutChart - mouse events Should render customized callout on mouseover +
+ +
@@ -1061,7 +1321,7 @@ exports[`DonutChart snapShot testing renders DonutChart correctly 1`] = ` &::-moz-focus-inner { border: 0; } - d="M0.5499908333791704,-54.99725002291659A55,55,0,0,1,46.728934607128515,29.007010712631306L0,0Z" + d="M0.5499908333791704,-54.99725002291659A55,55,0,0,1,51.395827471597144,-19.582362434339235L0,0Z" data-is-focusable={true} id="_Pie_1first20000" onBlur={[Function]} @@ -1100,7 +1360,7 @@ exports[`DonutChart snapShot testing renders DonutChart correctly 1`] = ` &::-moz-focus-inner { border: 0; } - d="M46.13948759271731,29.935725892008794A55,55,0,1,1,-0.5499908333792137,-54.99725002291659L0,0Z" + d="M51.7771697881295,-18.550598069367183A55,55,0,0,1,-22.36997379463645,50.245241291362895L0,0Z" data-is-focusable={true} id="_Pie_1second39000" onBlur={[Function]} @@ -1125,23 +1385,62 @@ exports[`DonutChart snapShot testing renders DonutChart correctly 1`] = ` y={5} /> - - - - - -
-
+ + + + + +
+
+ +
+
+
+ +
@@ -1505,6 +1894,45 @@ exports[`DonutChart snapShot testing renders enabledLegendsWrapLines correctly 1 y={5} /> + + + + @@ -1587,7 +2015,7 @@ exports[`DonutChart snapShot testing renders enabledLegendsWrapLines correctly 1 aria-label="first selected" aria-posinset={1} aria-selected={false} - aria-setsize={2} + aria-setsize={3} className= { @@ -1677,7 +2105,7 @@ exports[`DonutChart snapShot testing renders enabledLegendsWrapLines correctly 1 aria-label="second selected" aria-posinset={2} aria-selected={false} - aria-setsize={2} + aria-setsize={3} className= { @@ -1754,6 +2182,96 @@ exports[`DonutChart snapShot testing renders enabledLegendsWrapLines correctly 1 +
+ +
@@ -1809,12 +2327,51 @@ exports[`DonutChart snapShot testing renders hideLegend correctly 1`] = ` > + + + + + + + + @@ -2098,7 +2694,7 @@ exports[`DonutChart snapShot testing renders hideTooltip correctly 1`] = ` aria-label="first selected" aria-posinset={1} aria-selected={false} - aria-setsize={2} + aria-setsize={3} className= { @@ -2188,7 +2784,7 @@ exports[`DonutChart snapShot testing renders hideTooltip correctly 1`] = ` aria-label="second selected" aria-posinset={2} aria-selected={false} - aria-setsize={2} + aria-setsize={3} className= { @@ -2265,6 +2861,96 @@ exports[`DonutChart snapShot testing renders hideTooltip correctly 1`] = ` +
+ +
@@ -2400,6 +3086,47 @@ exports[`DonutChart snapShot testing renders value inside onf the pie 1`] = ` 1,000 + + + + 1,000 + + @@ -2482,7 +3209,7 @@ exports[`DonutChart snapShot testing renders value inside onf the pie 1`] = ` aria-label="first selected" aria-posinset={1} aria-selected={false} - aria-setsize={2} + aria-setsize={3} className= { @@ -2572,7 +3299,7 @@ exports[`DonutChart snapShot testing renders value inside onf the pie 1`] = ` aria-label="second selected" aria-posinset={2} aria-selected={false} - aria-setsize={2} + aria-setsize={3} className= { @@ -2649,6 +3376,96 @@ exports[`DonutChart snapShot testing renders value inside onf the pie 1`] = ` +
+ +
diff --git a/packages/react-charting/src/components/DonutChart/__snapshots__/DonutChartRTL.test.tsx.snap b/packages/react-charting/src/components/DonutChart/__snapshots__/DonutChartRTL.test.tsx.snap index 2b9bd2d1f049c..1f94f55f62171 100644 --- a/packages/react-charting/src/components/DonutChart/__snapshots__/DonutChartRTL.test.tsx.snap +++ b/packages/react-charting/src/components/DonutChart/__snapshots__/DonutChartRTL.test.tsx.snap @@ -59,7 +59,7 @@ exports[`DonutChart - mouse events Should render callout correctly on mouseover &::-moz-focus-inner { border: 0; } - d="M0.5499908333791704,-54.99725002291659A55,55,0,0,1,46.728934607128515,29.007010712631306L0,0Z" + d="M0.5499908333791704,-54.99725002291659A55,55,0,0,1,51.395827471597144,-19.582362434339235L0,0Z" data-is-focusable={true} id="_Pie_1first20000" onBlur={[Function]} @@ -98,7 +98,7 @@ exports[`DonutChart - mouse events Should render callout correctly on mouseover &::-moz-focus-inner { border: 0; } - d="M46.13948759271731,29.935725892008794A55,55,0,1,1,-0.5499908333792137,-54.99725002291659L0,0Z" + d="M51.7771697881295,-18.550598069367183A55,55,0,0,1,-22.36997379463645,50.245241291362895L0,0Z" data-is-focusable={true} id="_Pie_1second39000" onBlur={[Function]} @@ -123,6 +123,45 @@ exports[`DonutChart - mouse events Should render callout correctly on mouseover y={5} /> + + + + @@ -365,7 +404,7 @@ exports[`DonutChart - mouse events Should render callout correctly on mouseover aria-label="first selected" aria-posinset={1} aria-selected={false} - aria-setsize={2} + aria-setsize={3} className= { @@ -456,7 +495,7 @@ exports[`DonutChart - mouse events Should render callout correctly on mouseover aria-label="second selected" aria-posinset={2} aria-selected={false} - aria-setsize={2} + aria-setsize={3} className= { @@ -533,6 +572,97 @@ exports[`DonutChart - mouse events Should render callout correctly on mouseover +
+ +
@@ -602,7 +732,7 @@ exports[`DonutChart - mouse events Should render customized callout on mouseover &::-moz-focus-inner { border: 0; } - d="M0.5499908333791704,-54.99725002291659A55,55,0,0,1,46.728934607128515,29.007010712631306L0,0Z" + d="M0.5499908333791704,-54.99725002291659A55,55,0,0,1,51.395827471597144,-19.582362434339235L0,0Z" data-is-focusable={true} id="_Pie_1first20000" onBlur={[Function]} @@ -641,7 +771,7 @@ exports[`DonutChart - mouse events Should render customized callout on mouseover &::-moz-focus-inner { border: 0; } - d="M46.13948759271731,29.935725892008794A55,55,0,1,1,-0.5499908333792137,-54.99725002291659L0,0Z" + d="M51.7771697881295,-18.550598069367183A55,55,0,0,1,-22.36997379463645,50.245241291362895L0,0Z" data-is-focusable={true} id="_Pie_1second39000" onBlur={[Function]} @@ -666,6 +796,45 @@ exports[`DonutChart - mouse events Should render customized callout on mouseover y={5} /> + + + + @@ -826,7 +995,7 @@ exports[`DonutChart - mouse events Should render customized callout on mouseover aria-label="first selected" aria-posinset={1} aria-selected={false} - aria-setsize={2} + aria-setsize={3} className= { @@ -917,7 +1086,7 @@ exports[`DonutChart - mouse events Should render customized callout on mouseover aria-label="second selected" aria-posinset={2} aria-selected={false} - aria-setsize={2} + aria-setsize={3} className= { @@ -994,6 +1163,97 @@ exports[`DonutChart - mouse events Should render customized callout on mouseover +
+ +
@@ -1061,7 +1321,7 @@ exports[`DonutChart snapShot testing renders DonutChart correctly 1`] = ` &::-moz-focus-inner { border: 0; } - d="M0.5499908333791704,-54.99725002291659A55,55,0,0,1,46.728934607128515,29.007010712631306L0,0Z" + d="M0.5499908333791704,-54.99725002291659A55,55,0,0,1,51.395827471597144,-19.582362434339235L0,0Z" data-is-focusable={true} id="_Pie_1first20000" onBlur={[Function]} @@ -1100,7 +1360,7 @@ exports[`DonutChart snapShot testing renders DonutChart correctly 1`] = ` &::-moz-focus-inner { border: 0; } - d="M46.13948759271731,29.935725892008794A55,55,0,1,1,-0.5499908333792137,-54.99725002291659L0,0Z" + d="M51.7771697881295,-18.550598069367183A55,55,0,0,1,-22.36997379463645,50.245241291362895L0,0Z" data-is-focusable={true} id="_Pie_1second39000" onBlur={[Function]} @@ -1125,23 +1385,62 @@ exports[`DonutChart snapShot testing renders DonutChart correctly 1`] = ` y={5} /> - - - - - -
-
+ + + + + +
+
+ +
+
+
+ +
@@ -1505,6 +1894,45 @@ exports[`DonutChart snapShot testing renders enabledLegendsWrapLines correctly 1 y={5} /> + + + + @@ -1587,7 +2015,7 @@ exports[`DonutChart snapShot testing renders enabledLegendsWrapLines correctly 1 aria-label="first selected" aria-posinset={1} aria-selected={false} - aria-setsize={2} + aria-setsize={3} className= { @@ -1677,7 +2105,7 @@ exports[`DonutChart snapShot testing renders enabledLegendsWrapLines correctly 1 aria-label="second selected" aria-posinset={2} aria-selected={false} - aria-setsize={2} + aria-setsize={3} className= { @@ -1754,6 +2182,96 @@ exports[`DonutChart snapShot testing renders enabledLegendsWrapLines correctly 1 +
+ +
@@ -1885,11 +2403,50 @@ exports[`DonutChart snapShot testing renders hideLegend correctly 1`] = ` y={5} /> - - - - - + + + + + + + + @@ -2016,6 +2573,45 @@ exports[`DonutChart snapShot testing renders hideTooltip correctly 1`] = ` y={5} /> + + + + @@ -2098,7 +2694,7 @@ exports[`DonutChart snapShot testing renders hideTooltip correctly 1`] = ` aria-label="first selected" aria-posinset={1} aria-selected={false} - aria-setsize={2} + aria-setsize={3} className= { @@ -2188,7 +2784,7 @@ exports[`DonutChart snapShot testing renders hideTooltip correctly 1`] = ` aria-label="second selected" aria-posinset={2} aria-selected={false} - aria-setsize={2} + aria-setsize={3} className= { @@ -2265,6 +2861,96 @@ exports[`DonutChart snapShot testing renders hideTooltip correctly 1`] = ` +
+ +
@@ -2400,6 +3086,47 @@ exports[`DonutChart snapShot testing renders value inside onf the pie 1`] = ` 1,000
+ + + + 1,000 + + @@ -2482,7 +3209,7 @@ exports[`DonutChart snapShot testing renders value inside onf the pie 1`] = ` aria-label="first selected" aria-posinset={1} aria-selected={false} - aria-setsize={2} + aria-setsize={3} className= { @@ -2572,7 +3299,7 @@ exports[`DonutChart snapShot testing renders value inside onf the pie 1`] = ` aria-label="second selected" aria-posinset={2} aria-selected={false} - aria-setsize={2} + aria-setsize={3} className= { @@ -2649,6 +3376,2239 @@ exports[`DonutChart snapShot testing renders value inside onf the pie 1`] = ` +
+ +
+ + + + + + + + +`; + +exports[`Screen resolution Should remain unchanged on zoom in 1`] = ` +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+
+`; + +exports[`Screen resolution Should remain unchanged on zoom out 1`] = ` +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+
+`; + +exports[`Should hide callout on mouse leave 1`] = ` +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+
+`; + +exports[`Should reflect theme change 1`] = ` +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+
From 90dd8b1bb5db2a37a90656e5487816008dc28925 Mon Sep 17 00:00:00 2001 From: srmukher Date: Thu, 13 Apr 2023 16:33:58 +0530 Subject: [PATCH 3/6] Rearranged and modified tests and test plan --- .../BasicDonutChart.png | Bin .../DonutChart/ComponentTests.md} | 16 +++++++++------- .../DonutChart/DonutChartRTL.test.tsx | 6 ++++++ 3 files changed, 15 insertions(+), 7 deletions(-) rename packages/react-charting/docs/{ComponentTests => TestPlans}/BasicDonutChart.png (100%) rename packages/react-charting/docs/{ComponentTests/DonutChartTestPlan.md => TestPlans/DonutChart/ComponentTests.md} (63%) diff --git a/packages/react-charting/docs/ComponentTests/BasicDonutChart.png b/packages/react-charting/docs/TestPlans/BasicDonutChart.png similarity index 100% rename from packages/react-charting/docs/ComponentTests/BasicDonutChart.png rename to packages/react-charting/docs/TestPlans/BasicDonutChart.png diff --git a/packages/react-charting/docs/ComponentTests/DonutChartTestPlan.md b/packages/react-charting/docs/TestPlans/DonutChart/ComponentTests.md similarity index 63% rename from packages/react-charting/docs/ComponentTests/DonutChartTestPlan.md rename to packages/react-charting/docs/TestPlans/DonutChart/ComponentTests.md index e8371067bb6cd..c6cb9bb6d3655 100644 --- a/packages/react-charting/docs/ComponentTests/DonutChartTestPlan.md +++ b/packages/react-charting/docs/TestPlans/DonutChart/ComponentTests.md @@ -20,6 +20,8 @@ - HideLegend prop set to “true”. - [enzyme] - EnabledLegendsWrapLines prop set to “true”. - [enzyme] - ValueInsideDonut set to a string / number. - [enzyme] +- HideLabels prop set to "false". - [enzyme] +- HideLabels prop set to "false" and ShowLabelsInPercent prop set to "true". - [enzyme] ### Test case 3: [Specific DOM elements] Renders individual elements on a prop change: @@ -30,17 +32,17 @@ ### Test case 4: [Mouse events – Donut chart] Renders individual elements on mouse events: -- On mouseOver on the donut chart should render callout. - [enzyme] -- On mouseMove on Pie 1 (step 1) -> mouseLeave (step 2) -> mouseMove on Pie 2 (step 3), html in step 1 should not be the same as in step 3. - [enzyme] -- On mouseover with onRenderCalloutPerDataPoint prop provided, should render the custom callout. [enzyme] -- On mouseOver, callout should be defined, on mouseLeave, callout should disappear. - [enzyme] +- On mouse over on the donut chart should render callout. - [enzyme] +- On mouse move on Pie 1 (step 1) -> mouse leave (step 2) -> mouse move on Pie 2 (step 3), html in step 1 should not be the same as in step 3. - [enzyme] +- On mouse over with onRenderCalloutPerDataPoint prop provided, should render the custom callout. [enzyme] +- On mouse over, callout should be defined, on mouse leave, callout should disappear. - [enzyme] ### Test case 5: [Mouse events – Legends] Renders individual elements on mouse events: -- On mouseOver should highlight the corresponding pie. - [RTL] -- On mouseOver should change the value inside donut with the legend value. - [enzyme] +- On mouse over on legends should highlight the corresponding pie. - [RTL] +- On mouse over on legends should change the value inside donut with the legend value. - [enzyme] - On click should highlight the corresponding pie with aria-selected set to “true” and tabIndex set to 0. - [RTL] -- On mouseOut after mouseOver on first legend, should have opacity 0.1 for second Pie initially (during mouseOver on first legend) and opacity set to 1 for both the Pies on mouseOut. - [RTL] +- On mouse out after mouse over on first legend, should have opacity 0.1 for second Pie initially (during mouseOver on first legend) and opacity set to 1 for both the Pies on mouse out. - [RTL] ### Test case 6: [Keyboard events – Donut chart] Renders individual elements on keyboard events: diff --git a/packages/react-charting/src/components/DonutChart/DonutChartRTL.test.tsx b/packages/react-charting/src/components/DonutChart/DonutChartRTL.test.tsx index fe0b8fb31ef04..d0e65307484d4 100644 --- a/packages/react-charting/src/components/DonutChart/DonutChartRTL.test.tsx +++ b/packages/react-charting/src/components/DonutChart/DonutChartRTL.test.tsx @@ -52,11 +52,13 @@ test('Should highlight the corresponding Pie on mouse over on legends', () => { // Act const legend = screen.queryByText('first'); + expect(legend).toBeDefined(); fireEvent.mouseOver(legend!); // Assert const getById = queryAllByAttribute.bind(null, 'id'); expect(getById(container, /Pie.*?second/i)[0]).toHaveAttribute('opacity', '0.1'); + expect(getById(container, /Pie.*?third/i)[0]).toHaveAttribute('opacity', '0.1'); }); test('Should select legend on single mouse click on legends', () => { @@ -65,6 +67,7 @@ test('Should select legend on single mouse click on legends', () => { // Act const legend = screen.queryByText('first'); + expect(legend).toBeDefined(); fireEvent.click(legend!); // Assert @@ -81,6 +84,8 @@ test('Should deselect legend on double mouse click on legends', () => { // Act const legend = screen.queryByText('first'); + expect(legend).toBeDefined(); + //single click on first legend fireEvent.click(legend!); const getById = queryAllByAttribute.bind(null, 'id'); @@ -101,6 +106,7 @@ test('Should show Pies with same opacity on mouse out of legends', () => { // Act const legend = screen.queryByText('first'); + expect(legend).toBeDefined(); fireEvent.mouseOver(legend!); const getById = queryAllByAttribute.bind(null, 'id'); expect(getById(container, /Pie.*?second/i)[0]).toHaveAttribute('opacity', '0.1'); From 8689225231213bd879a95d182c6869e69f857371 Mon Sep 17 00:00:00 2001 From: srmukher Date: Mon, 17 Apr 2023 12:56:28 +0530 Subject: [PATCH 4/6] Converting component test plan to a table --- .../TestPlans/DonutChart/ComponentTests.md | 51 ++++--------------- 1 file changed, 11 insertions(+), 40 deletions(-) diff --git a/packages/react-charting/docs/TestPlans/DonutChart/ComponentTests.md b/packages/react-charting/docs/TestPlans/DonutChart/ComponentTests.md index c6cb9bb6d3655..efbbd2bf28a2e 100644 --- a/packages/react-charting/docs/TestPlans/DonutChart/ComponentTests.md +++ b/packages/react-charting/docs/TestPlans/DonutChart/ComponentTests.md @@ -4,47 +4,18 @@ ![Alt text](BasicDonutChart.png) -## Subcomponents: Pie and Legend +### Subcomponents: Pie and Legend -## Library used: jest and (enzyme or react testing library) +### Library used: jest and (enzyme or react testing library)
-### Test case 1: [Snapshot testing] [Component] - -- Renders donut chart correctly with data. - [enzyme] - -### Test case 2: [Snapshot testing] [Individual Props] Renders donut chart with: - -- HideTooltip prop set to “true”. - [enzyme] -- HideLegend prop set to “true”. - [enzyme] -- EnabledLegendsWrapLines prop set to “true”. - [enzyme] -- ValueInsideDonut set to a string / number. - [enzyme] -- HideLabels prop set to "false". - [enzyme] -- HideLabels prop set to "false" and ShowLabelsInPercent prop set to "true". - [enzyme] - -### Test case 3: [Specific DOM elements] Renders individual elements on a prop change: - -- Should mount legend when hideLegend prop is set to “false”. - [enzyme] -- Should mount callout when hideTootip prop is set to “false”. - [enzyme] -- Should not render onRenderCalloutPerStack with just data as a prop. - [enzyme] -- Should render onRenderCalloutPerDataPoint when the prop is given otherwise should not render onRenderCalloutPerDataPoint. - [enzyme] - -### Test case 4: [Mouse events – Donut chart] Renders individual elements on mouse events: - -- On mouse over on the donut chart should render callout. - [enzyme] -- On mouse move on Pie 1 (step 1) -> mouse leave (step 2) -> mouse move on Pie 2 (step 3), html in step 1 should not be the same as in step 3. - [enzyme] -- On mouse over with onRenderCalloutPerDataPoint prop provided, should render the custom callout. [enzyme] -- On mouse over, callout should be defined, on mouse leave, callout should disappear. - [enzyme] - -### Test case 5: [Mouse events – Legends] Renders individual elements on mouse events: - -- On mouse over on legends should highlight the corresponding pie. - [RTL] -- On mouse over on legends should change the value inside donut with the legend value. - [enzyme] -- On click should highlight the corresponding pie with aria-selected set to “true” and tabIndex set to 0. - [RTL] -- On mouse out after mouse over on first legend, should have opacity 0.1 for second Pie initially (during mouseOver on first legend) and opacity set to 1 for both the Pies on mouse out. - [RTL] - -### Test case 6: [Keyboard events – Donut chart] Renders individual elements on keyboard events: - -- On focus should render the corresponding callout. - [RTL] -- On blur should remove focus from the corresponding Pie. - [RTL] +| Test case | Execution steps | Validation steps | Library used | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Test case 1: [Snapshot testing] [Component] Renders donut chart with dataDonut chart renders correctlyEnzyme | Test case 2: [Snapshot testing] [Individual Props] Renders donut chart with:
  • HideTooltip prop set to “true”.
Donut chart renders correctlyEnzyme | +|
  • HideLegend prop set to “true”.
Donut chart renders correctlyEnzyme |
  • EnabledLegendsWrapLines prop set to “true”.
Donut chart renders correctlyEnzyme |
  • ValueInsideDonut set to a string / number.
Donut chart renders correctlyEnzyme |
  • HideLabels prop set to "false".
Donut chart renders correctlyEnzyme | +|
  • HideLabels prop set to "false" and ShowLabelsInPercent prop set to "true".
Donut chart renders correctlyEnzyme | Test case 3: [Specific DOM elements] Renders individual elements on a prop change:
  • HideLegend prop is set to “false”.
Legend mounts correctlyEnzyme |
  • HideTootip prop is set to “false”.
Callout mounts correctlyEnzyme |
  • onRenderCalloutPerStack prop is not given.
Should not render onRenderCalloutPerStackEnzyme | +|
  • onRenderCalloutPerDataPoint prop is given.
Should render onRenderCalloutPerDataPoint correctlyEnzyme | +| Test case 4: [Mouse events – Donut chart] Renders individual elements on mouse events:
  • On mouse over on the donut chart.
Should render calloutEnzyme |
  • On mouse move on Pie 1 (step 1) -> mouse leave (step 2) -> mouse move on Pie 2 (step 3).
Html in step 1 should not be the same as in step 3Enzyme |
  • On mouse over with onRenderCalloutPerDataPoint prop provided.
Should render the custom calloutEnzyme |
  • On mouse over, followed by mouse leave on callout.
On mouse over, callout should be defined, on mouse leave, callout should disappear.Enzyme | +| Test case 5: [Mouse events – Legends] Renders individual elements on mouse events:
  • On mouse over on legends.
Should highlight the corresponding pieRTL |
  • On mouse over on legends.
Should change the value inside donut with the legend valueEnzyme |
  • On click on Pie.
Should highlight the corresponding pie with aria-selected set to “true” and tabIndex set to 0.RTL |
  • On mouse out after mouse over on first legend.
Should have opacity 0.1 for second Pie initially (during mouseOver on first legend) and opacity set to 1 for both the Pies on mouse out.RTL | +| Test case 6: [Keyboard events – Donut chart] Renders individual elements on keyboard events:
  • On focus on a Pie.
Should render the corresponding calloutRTL |
  • On blur on a Pie.
Should remove focus from the corresponding PieRTL | From 11e91c2bf2a323acf17537774c7c019b7e46aca8 Mon Sep 17 00:00:00 2001 From: srmukher Date: Mon, 17 Apr 2023 13:26:18 +0530 Subject: [PATCH 5/6] Removing setup change for extend-expect --- .../TestPlans/DonutChart/ComponentTests.md | 32 +++++++++++++------ packages/react-charting/jest.config.js | 2 +- packages/react-charting/package.json | 1 + .../DonutChart/DonutChartRTL.test.tsx | 1 + 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/packages/react-charting/docs/TestPlans/DonutChart/ComponentTests.md b/packages/react-charting/docs/TestPlans/DonutChart/ComponentTests.md index efbbd2bf28a2e..0c4434f9bc9d6 100644 --- a/packages/react-charting/docs/TestPlans/DonutChart/ComponentTests.md +++ b/packages/react-charting/docs/TestPlans/DonutChart/ComponentTests.md @@ -10,12 +10,26 @@
-| Test case | Execution steps | Validation steps | Library used | -| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Test case 1: [Snapshot testing] [Component] Renders donut chart with dataDonut chart renders correctlyEnzyme | Test case 2: [Snapshot testing] [Individual Props] Renders donut chart with:
  • HideTooltip prop set to “true”.
Donut chart renders correctlyEnzyme | -|
  • HideLegend prop set to “true”.
Donut chart renders correctlyEnzyme |
  • EnabledLegendsWrapLines prop set to “true”.
Donut chart renders correctlyEnzyme |
  • ValueInsideDonut set to a string / number.
Donut chart renders correctlyEnzyme |
  • HideLabels prop set to "false".
Donut chart renders correctlyEnzyme | -|
  • HideLabels prop set to "false" and ShowLabelsInPercent prop set to "true".
Donut chart renders correctlyEnzyme | Test case 3: [Specific DOM elements] Renders individual elements on a prop change:
  • HideLegend prop is set to “false”.
Legend mounts correctlyEnzyme |
  • HideTootip prop is set to “false”.
Callout mounts correctlyEnzyme |
  • onRenderCalloutPerStack prop is not given.
Should not render onRenderCalloutPerStackEnzyme | -|
  • onRenderCalloutPerDataPoint prop is given.
Should render onRenderCalloutPerDataPoint correctlyEnzyme | -| Test case 4: [Mouse events – Donut chart] Renders individual elements on mouse events:
  • On mouse over on the donut chart.
Should render calloutEnzyme |
  • On mouse move on Pie 1 (step 1) -> mouse leave (step 2) -> mouse move on Pie 2 (step 3).
Html in step 1 should not be the same as in step 3Enzyme |
  • On mouse over with onRenderCalloutPerDataPoint prop provided.
Should render the custom calloutEnzyme |
  • On mouse over, followed by mouse leave on callout.
On mouse over, callout should be defined, on mouse leave, callout should disappear.Enzyme | -| Test case 5: [Mouse events – Legends] Renders individual elements on mouse events:
  • On mouse over on legends.
Should highlight the corresponding pieRTL |
  • On mouse over on legends.
Should change the value inside donut with the legend valueEnzyme |
  • On click on Pie.
Should highlight the corresponding pie with aria-selected set to “true” and tabIndex set to 0.RTL |
  • On mouse out after mouse over on first legend.
Should have opacity 0.1 for second Pie initially (during mouseOver on first legend) and opacity set to 1 for both the Pies on mouse out.RTL | -| Test case 6: [Keyboard events – Donut chart] Renders individual elements on keyboard events:
  • On focus on a Pie.
Should render the corresponding calloutRTL |
  • On blur on a Pie.
Should remove focus from the corresponding PieRTL | +| Test case | Execution steps | Validation steps | Library used | +| -------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ------------ | +| Test case 1: [Snapshot testing] [Component] |
  • Renders donut chart with data.
| Donut chart renders correctly | Enzyme | +| Test case 2: [Snapshot testing] [Individual Props] | Renders donut chart with:
  • HideTooltip prop set to “true”.
| Donut chart renders correctly | Enzyme | +| |
  • HideLegend prop set to “true”.
| Donut chart renders correctly | Enzyme | +| |
  • EnabledLegendsWrapLines prop set to “true”.
| Donut chart renders correctly | Enzyme | +| |
  • ValueInsideDonut set to a string / number.
| Donut chart renders correctly | Enzyme | +| |
  • HideLabels prop set to "false".
| Donut chart renders correctly | Enzyme | +| |
  • HideLabels prop set to "false" and ShowLabelsInPercent prop set to "true".
| Donut chart renders correctly | Enzyme | +| Test case 3: [Specific DOM elements] Renders individual elements on a prop change: |
  • HideLegend prop is set to “false”.
| Legend mounts correctly | Enzyme | +| |
  • HideTootip prop is set to “false”.
| Callout mounts correctly | Enzyme | +| |
  • onRenderCalloutPerStack prop is not given.
| Should not render onRenderCalloutPerStack | Enzyme | +| |
  • onRenderCalloutPerDataPoint prop is given.
| Should render onRenderCalloutPerDataPoint correctly | Enzyme | +| Test case 4: [Mouse events – Donut chart] Renders individual elements on mouse events: |
  • On mouse over on the donut chart.
| Should render callout | Enzyme | +| |
  • On mouse move on Pie 1 (step 1) -> mouse leave (step 2) -> mouse move on Pie 2 (step 3).
| Html in step 1 should not be the same as in step 3 | Enzyme | +| |
  • On mouse over with onRenderCalloutPerDataPoint prop provided.
| Should render the custom callout | Enzyme | +| |
  • On mouse over, followed by mouse leave on callout.
| On mouse over, callout should be defined, on mouse leave, callout should disappear. | Enzyme | +| Test case 5: [Mouse events – Legends] Renders individual elements on mouse events: |
  • On mouse over on legends.
| Should highlight the corresponding pie | RTL | +| |
  • On mouse over on legends.
| Should change the value inside donut with the legend value | Enzyme | +| |
  • On click on Pie.
| Should highlight the corresponding pie with aria-selected set to “true” and tabIndex set to 0. | RTL | +| |
  • On mouse out after mouse over on first legend.
| Should have opacity 0.1 for second Pie initially (during mouseOver on first legend) and opacity set to 1 for both the Pies on mouse out. | RTL | +| Test case 6: [Keyboard events – Donut chart] Renders individual elements on keyboard events: |
  • On focus on a Pie.
| Should render the corresponding callout | RTL | +| |
  • On blur on a Pie.
| Should remove focus from the corresponding Pie | RTL | diff --git a/packages/react-charting/jest.config.js b/packages/react-charting/jest.config.js index 45c4007353a3c..b70cd24668eeb 100644 --- a/packages/react-charting/jest.config.js +++ b/packages/react-charting/jest.config.js @@ -19,7 +19,7 @@ function getEsmOnlyPackagesToCjsMapping() { const config = createConfig({ setupFiles: ['./config/tests.js'], snapshotSerializers: ['@fluentui/jest-serializer-merge-styles', 'enzyme-to-json/serializer'], - setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'], + moduleNameMapper: { ...getEsmOnlyPackagesToCjsMapping(), }, diff --git a/packages/react-charting/package.json b/packages/react-charting/package.json index 751a629f002bb..4ba26638bda6e 100644 --- a/packages/react-charting/package.json +++ b/packages/react-charting/package.json @@ -37,6 +37,7 @@ }, "dependencies": { "@fluentui/react-focus": "^8.8.19", + "@fluentui/theme-samples": "^8.7.70", "@microsoft/load-themed-styles": "^1.10.26", "@types/d3-array": "1.2.1", "@types/d3-axis": "1.0.10", diff --git a/packages/react-charting/src/components/DonutChart/DonutChartRTL.test.tsx b/packages/react-charting/src/components/DonutChart/DonutChartRTL.test.tsx index d0e65307484d4..4e4c146927e11 100644 --- a/packages/react-charting/src/components/DonutChart/DonutChartRTL.test.tsx +++ b/packages/react-charting/src/components/DonutChart/DonutChartRTL.test.tsx @@ -5,6 +5,7 @@ import * as React from 'react'; import { DarkTheme } from '@fluentui/theme-samples'; import { ThemeProvider } from '@fluentui/react'; import * as utils from '../../utilities/utilities'; +import '@testing-library/jest-dom'; test('Should hide callout on mouse leave', () => { // Arrange From 20970f0cdf35ad8123ca3e770bc55a7be97436ec Mon Sep 17 00:00:00 2001 From: srmukher Date: Tue, 2 May 2023 17:06:36 +0530 Subject: [PATCH 6/6] Changing the setup for jest-dom in config --- packages/react-charting/config/setup-env.js | 1 + packages/react-charting/jest.config.js | 2 +- .../src/components/DonutChart/DonutChartRTL.test.tsx | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 packages/react-charting/config/setup-env.js diff --git a/packages/react-charting/config/setup-env.js b/packages/react-charting/config/setup-env.js new file mode 100644 index 0000000000000..093264800d8c6 --- /dev/null +++ b/packages/react-charting/config/setup-env.js @@ -0,0 +1 @@ +require('@testing-library/jest-dom'); diff --git a/packages/react-charting/jest.config.js b/packages/react-charting/jest.config.js index b70cd24668eeb..0ac954180f24e 100644 --- a/packages/react-charting/jest.config.js +++ b/packages/react-charting/jest.config.js @@ -19,7 +19,7 @@ function getEsmOnlyPackagesToCjsMapping() { const config = createConfig({ setupFiles: ['./config/tests.js'], snapshotSerializers: ['@fluentui/jest-serializer-merge-styles', 'enzyme-to-json/serializer'], - + setupFilesAfterEnv: ['./config/setup-env.js'], moduleNameMapper: { ...getEsmOnlyPackagesToCjsMapping(), }, diff --git a/packages/react-charting/src/components/DonutChart/DonutChartRTL.test.tsx b/packages/react-charting/src/components/DonutChart/DonutChartRTL.test.tsx index 4e4c146927e11..d0e65307484d4 100644 --- a/packages/react-charting/src/components/DonutChart/DonutChartRTL.test.tsx +++ b/packages/react-charting/src/components/DonutChart/DonutChartRTL.test.tsx @@ -5,7 +5,6 @@ import * as React from 'react'; import { DarkTheme } from '@fluentui/theme-samples'; import { ThemeProvider } from '@fluentui/react'; import * as utils from '../../utilities/utilities'; -import '@testing-library/jest-dom'; test('Should hide callout on mouse leave', () => { // Arrange