-
Notifications
You must be signed in to change notification settings - Fork 2.8k
refactor(react-charts,react-charting): migrate tests from react-test-renderer to @testing-library/react #35307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,11 +127,11 @@ jobs: | |
|
||
- name: React Versions Integration Tests (17,19) - Test | ||
run: | | ||
FLUENT_JEST_WORKER=2 yarn nx affected -t test-rit--17--test,test-rit--19--test --exclude='react-19-tests-v9,react-charting' | ||
FLUENT_JEST_WORKER=2 yarn nx affected -t test-rit--17--test,test-rit--19--test --exclude='react-19-tests-v9' | ||
- name: React Versions Integration Tests (17,19) - Type-check | ||
run: | | ||
FLUENT_JEST_WORKER=2 yarn nx affected -t test-rit--17--type-check,test-rit--19--type-check --exclude='react-19-tests-v9,react-charting' | ||
FLUENT_JEST_WORKER=2 yarn nx affected -t test-rit--17--type-check,test-rit--19--type-check --exclude='react-19-tests-v9' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we could probably merge the |
||
react_19_v9_source_code_typecheck: | ||
if: ${{ github.repository_owner == 'microsoft' }} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,7 +92,7 @@ describe('GanttChart rendering and behavior tests', () => { | |
|
||
it('should render callout correctly when a bar is hovered', async () => { | ||
const { container } = render(<GanttChart data={ganttData} calloutProps={{ doNotLayer: true }} />); | ||
await act(() => { | ||
await act(async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not related to the |
||
fireEvent.mouseOver(container.querySelector('rect')!); | ||
}); | ||
expect(container).toMatchSnapshot(); | ||
|
@@ -102,7 +102,7 @@ describe('GanttChart rendering and behavior tests', () => { | |
const { container } = render( | ||
<GanttChart data={ganttData} hideTooltip={true} calloutProps={{ doNotLayer: true }} />, | ||
); | ||
await act(() => { | ||
act(() => { | ||
fireEvent.mouseOver(container.querySelector('rect')!); | ||
}); | ||
expect(container.querySelector('.ms-Callout')).toBeNull(); | ||
|
@@ -137,7 +137,7 @@ describe('GanttChart interaction and accessibility tests', () => { | |
render(<GanttChart data={ganttDataWithLongY} showYAxisLablesTooltip={true} />); | ||
expect(screen.queryByText('Site Preparation')).toBeNull(); | ||
|
||
await act(() => { | ||
act(() => { | ||
fireEvent.mouseOver(screen.getByText('Site...')); | ||
}); | ||
expect(screen.queryByText('Site Preparation')).not.toBeNull(); | ||
|
@@ -146,12 +146,12 @@ describe('GanttChart interaction and accessibility tests', () => { | |
it(`should display callout on bar hover and hide it on mouse leave from the chart`, async () => { | ||
const { container } = render(<GanttChart data={ganttData} calloutProps={{ doNotLayer: true }} />); | ||
const bar = container.querySelector('rect')!; | ||
await act(() => { | ||
act(() => { | ||
fireEvent.mouseOver(bar); | ||
}); | ||
expect(container.querySelector('.ms-Callout')).not.toBeNull(); | ||
|
||
await act(() => { | ||
act(() => { | ||
fireEvent.mouseLeave(container.querySelector('[class^="root"]')!); | ||
}); | ||
expect(container.querySelector('.ms-Callout')).toBeNull(); | ||
|
@@ -160,7 +160,7 @@ describe('GanttChart interaction and accessibility tests', () => { | |
it('should display callout when a bar is focused', async () => { | ||
const { container } = render(<GanttChart data={ganttData} calloutProps={{ doNotLayer: true }} />); | ||
const bar = container.querySelector('rect')!; | ||
await act(() => { | ||
act(() => { | ||
fireEvent.focus(bar); | ||
}); | ||
expect(container.querySelector('.ms-Callout')).not.toBeNull(); | ||
|
@@ -169,15 +169,15 @@ describe('GanttChart interaction and accessibility tests', () => { | |
it(`should highlight corresponding bars on legend hover and remove highlight on legend mouse out`, async () => { | ||
const { container } = render(<GanttChart data={ganttData} />); | ||
const legendButton = screen.getByText('Not Started'); | ||
await act(() => { | ||
act(() => { | ||
fireEvent.mouseOver(legendButton); | ||
}); | ||
const bars = container.querySelectorAll('rect'); | ||
expect(bars).toHaveLength(8); | ||
expect(bars[3]).toHaveAttribute('opacity', '1'); | ||
expect(bars[0]).toHaveAttribute('opacity', '0.1'); | ||
|
||
await act(() => { | ||
act(() => { | ||
fireEvent.mouseOut(legendButton); | ||
}); | ||
expect(bars[3]).toHaveAttribute('opacity', '1'); | ||
|
@@ -187,15 +187,15 @@ describe('GanttChart interaction and accessibility tests', () => { | |
it(`should toggle highlight on corresponding bars when legend is clicked`, async () => { | ||
const { container } = render(<GanttChart data={ganttData} />); | ||
const legendButton = screen.getByText('Incomplete'); | ||
await act(() => { | ||
act(() => { | ||
fireEvent.click(legendButton); | ||
}); | ||
const bars = container.querySelectorAll('rect'); | ||
expect(bars).toHaveLength(8); | ||
expect(bars[1]).toHaveAttribute('opacity', '1'); | ||
expect(bars[0]).toHaveAttribute('opacity', '0.1'); | ||
|
||
await act(() => { | ||
act(() => { | ||
fireEvent.click(legendButton); | ||
}); | ||
expect(bars[1]).toHaveAttribute('opacity', '1'); | ||
|
@@ -204,18 +204,18 @@ describe('GanttChart interaction and accessibility tests', () => { | |
|
||
it(`should display callouts only for highlighted bars`, async () => { | ||
const { container } = render(<GanttChart data={ganttData} calloutProps={{ doNotLayer: true }} />); | ||
await act(() => { | ||
act(() => { | ||
fireEvent.click(screen.getByText('Complete')); | ||
}); | ||
const bars = container.querySelectorAll('rect'); | ||
expect(bars).toHaveLength(8); | ||
|
||
await act(() => { | ||
act(() => { | ||
fireEvent.mouseOver(bars[1]); | ||
}); | ||
expect(container.querySelector('.ms-Callout')).toBeNull(); | ||
|
||
await act(() => { | ||
act(() => { | ||
fireEvent.mouseOver(bars[0]); | ||
}); | ||
expect(container.querySelector('.ms-Callout')).not.toBeNull(); | ||
|
@@ -225,10 +225,10 @@ describe('GanttChart interaction and accessibility tests', () => { | |
const { container } = render( | ||
<GanttChart data={ganttDataWithNumericY} legendProps={{ canSelectMultipleLegends: true }} />, | ||
); | ||
await act(() => { | ||
act(() => { | ||
fireEvent.click(screen.getByText('Finance')); | ||
}); | ||
await act(() => { | ||
act(() => { | ||
fireEvent.click(screen.getByText('Operations')); | ||
}); | ||
const bars = container.querySelectorAll('rect'); | ||
|
@@ -248,7 +248,7 @@ describe('GanttChart interaction and accessibility tests', () => { | |
calloutProps={{ doNotLayer: true }} | ||
/>, | ||
); | ||
await act(() => { | ||
act(() => { | ||
fireEvent.mouseOver(container.querySelector('rect')!); | ||
}); | ||
expect(container).toMatchSnapshot(); | ||
|
Uh oh!
There was an error while loading. Please reload this page.