-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PLAY-1351] Upgrade Highcharts (#3427)
**What does this PR do?** A clear and concise description with your runway ticket url. Runway https://nitro.powerhrg.com/runway/backlog_items/PLAY-1351 Upgrades highcharts from version 9 to 10 I added the boiler plate for tests for the graphs because they had nothing. I would have liked to add snapshot testing but was having issues because highcharts generates random ids for different parts of the graphs your suppose to be able to do things like expect.any(String) https://jestjs.io/docs/snapshot-testing#property-matchers But you need to download other library(s) to get it to work. I bailed because its out of scope other people have this issue enzymejs/enzyme#1050 ``` test('bargraph has right html structure', () => { const { container } = render( <BarGraph data={{ testid: testId }} /> ); expect(container).toMatchSnapshot({ id: expect.any(String) }); }); ``` ![Screenshot 2024-05-24 at 9 43 20 AM](https://github.com/powerhome/playbook/assets/38965626/cd3c7730-3f9a-4e2e-9b26-b0c8709d0b3c) **How to test?** Steps to confirm the desired behavior: Everything should be the same, just a version bump
- Loading branch information
1 parent
7d21b0c
commit 7bfb30d
Showing
9 changed files
with
245 additions
and
7 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
playbook/app/pb_kits/playbook/pb_bar_graph/barGraph.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
import { render, screen } from '../utilities/test-utils'; | ||
import BarGraph from './_bar_graph'; | ||
|
||
beforeEach(() => { | ||
// Silences error logs within the test suite. | ||
jest.spyOn(console, 'error'); | ||
jest.spyOn(console, 'warn'); | ||
console.error.mockImplementation(() => {}); | ||
console.warn.mockImplementation(() => {}); | ||
}); | ||
|
||
afterEach(() => { | ||
console.error.mockRestore(); | ||
console.warn.mockRestore(); | ||
}); | ||
|
||
const testId = 'bargraph1'; | ||
|
||
test('bargraph uses exact classname', () => { | ||
render( | ||
<BarGraph | ||
className='super_important_class' | ||
data={{ testid: testId }} | ||
id='bar-default' | ||
/> | ||
); | ||
|
||
const kit = screen.getByTestId(testId); | ||
expect(kit).toHaveClass('super_important_class'); | ||
}); |
45 changes: 45 additions & 0 deletions
45
playbook/app/pb_kits/playbook/pb_circle_chart/circleChart.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from 'react'; | ||
import { render, screen } from '../utilities/test-utils'; | ||
import CircleChart from './_circle_chart'; | ||
|
||
beforeEach(() => { | ||
// Silences error logs within the test suite. | ||
jest.spyOn(console, 'error'); | ||
jest.spyOn(console, 'warn'); | ||
console.error.mockImplementation(() => {}); | ||
console.warn.mockImplementation(() => {}); | ||
}); | ||
|
||
afterEach(() => { | ||
console.error.mockRestore(); | ||
console.warn.mockRestore(); | ||
}); | ||
|
||
const testId = 'circlechart1'; | ||
|
||
test('uses exact classname', () => { | ||
const data = [ | ||
{ | ||
name: 'Waiting for Calls', | ||
value: 41, | ||
}, | ||
{ | ||
name: 'On Call', | ||
value: 49, | ||
}, | ||
{ | ||
name: 'After call', | ||
value: 10, | ||
}, | ||
] | ||
render( | ||
<CircleChart | ||
chartData={data} | ||
data={{ testid: testId }} | ||
id='circlechartid' | ||
/> | ||
); | ||
|
||
const kit = screen.getByTestId(testId); | ||
expect(kit).toHaveClass('pb_circle_chart'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react'; | ||
import { render, screen } from '../utilities/test-utils'; | ||
import Gauge from './_gauge'; | ||
|
||
beforeEach(() => { | ||
// Silences error logs within the test suite. | ||
jest.spyOn(console, 'error'); | ||
jest.spyOn(console, 'warn'); | ||
console.error.mockImplementation(() => {}); | ||
console.warn.mockImplementation(() => {}); | ||
}); | ||
|
||
afterEach(() => { | ||
console.error.mockRestore(); | ||
console.warn.mockRestore(); | ||
}); | ||
|
||
const testId = 'gauge1'; | ||
|
||
test('uses exact classname', () => { | ||
const data = [ | ||
{ name: 'Name', value: 45 }, | ||
] | ||
render( | ||
<Gauge | ||
chartData={data} | ||
data={{ testid: testId }} | ||
id='gaugeid' | ||
/> | ||
); | ||
|
||
const kit = screen.getByTestId(testId); | ||
expect(kit).toHaveClass('pb_gauge_kit'); | ||
}); | ||
|
52 changes: 52 additions & 0 deletions
52
playbook/app/pb_kits/playbook/pb_line_graph/lineGraph.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from 'react'; | ||
import { render, screen } from '../utilities/test-utils'; | ||
import LineGraph from './_line_graph'; | ||
|
||
beforeEach(() => { | ||
// Silences error logs within the test suite. | ||
jest.spyOn(console, 'error'); | ||
jest.spyOn(console, 'warn'); | ||
console.error.mockImplementation(() => {}); | ||
console.warn.mockImplementation(() => {}); | ||
}); | ||
|
||
afterEach(() => { | ||
console.error.mockRestore(); | ||
console.warn.mockRestore(); | ||
}); | ||
|
||
const testId = 'linechart1'; | ||
|
||
test('uses exact classname', () => { | ||
const data = [{ | ||
name: 'Installation', | ||
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175], | ||
}, { | ||
name: 'Manufacturing', | ||
data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434], | ||
}, { | ||
name: 'Sales & Distribution', | ||
data: [11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387], | ||
}, { | ||
name: 'Project Development', | ||
data: [null, null, 7988, 12169, 15112, 22452, 34400, 34227], | ||
}, { | ||
name: 'Other', | ||
data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111], | ||
}] | ||
render( | ||
<LineGraph | ||
axisTitle="Number of Employees" | ||
chartData={data} | ||
data={{ testid: testId }} | ||
id="line-default" | ||
subTitle="Source: thesolarfoundation.com" | ||
title="Solar Employment Growth by Sector, 2010-2016" | ||
xAxisCategories={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']} | ||
yAxisMin={0} | ||
/> | ||
); | ||
|
||
const kit = screen.getByTestId(testId); | ||
expect(kit).toHaveClass('pb_bar_graph'); | ||
}); |
61 changes: 61 additions & 0 deletions
61
playbook/app/pb_kits/playbook/pb_treemap_chart/treemapChart.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React from 'react'; | ||
import { render, screen } from '../utilities/test-utils'; | ||
import TreemapChart from './_treemap_chart'; | ||
|
||
beforeEach(() => { | ||
// Silences error logs within the test suite. | ||
jest.spyOn(console, 'error'); | ||
jest.spyOn(console, 'warn'); | ||
console.error.mockImplementation(() => {}); | ||
console.warn.mockImplementation(() => {}); | ||
}); | ||
|
||
afterEach(() => { | ||
console.error.mockRestore(); | ||
console.warn.mockRestore(); | ||
}); | ||
|
||
const testId = 'treemapchart1'; | ||
|
||
test('uses exact classname', () => { | ||
const data = [ | ||
{ | ||
name: "Pepperoni", | ||
parent: "Toppings", | ||
value: 600, | ||
}, { | ||
name: "Cheese", | ||
parent: "Toppings", | ||
value: 510, | ||
}, { | ||
name: "Mushroom", | ||
parent: "Toppings", | ||
value: 330, | ||
},{ | ||
name: "Onions", | ||
parent: "Toppings", | ||
value: 250, | ||
}, { | ||
name: "Olives", | ||
parent: "Toppings", | ||
value: 204, | ||
}, { | ||
name: "Pineapple", | ||
parent: "Toppings", | ||
value: 90, | ||
}, { | ||
name: "Pizza Toppings", | ||
id: "Toppings", | ||
}, | ||
] | ||
render( | ||
<TreemapChart | ||
chartData={data} | ||
data={{ testid: testId }} | ||
id="tree-map-id" | ||
/> | ||
); | ||
|
||
const kit = screen.getByTestId(testId); | ||
expect(kit).toHaveClass('pb_treemap_chart'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters