|
1 | | -import {TestEditor, setupGraphDiv, fixtures} from 'lib/test-utils'; |
2 | | -import plotly from 'plotly.js/dist/plotly'; |
3 | | - |
4 | | -import {PanelMenuWrapper} from '../components'; |
5 | | - |
6 | | -import * as mocks from '../../dev/percy'; |
7 | | -import * as panels from '../default_panels/'; |
8 | | - |
9 | | -import '../../dev/styles.css'; |
10 | | -import '../styles/main.scss'; |
11 | | -import './stories.css'; |
12 | | - |
13 | | -import React from 'react'; |
14 | | -import {storiesOf} from '@storybook/react'; |
15 | 1 | export const customConfigTest = { |
16 | 2 | visibility_rules: { |
17 | 3 | blacklist: [ |
@@ -78,68 +64,3 @@ export const customConfigTest = { |
78 | 64 | ], |
79 | 65 | }, |
80 | 66 | }; |
81 | | - |
82 | | -/** |
83 | | - * To add more Percy tests - add a mock file to /dev/percy, add it to /dev/percy/index.js |
84 | | - * To specify which panels to test with the mock, add entry to panelsToTest, else all panels will be tested |
85 | | - */ |
86 | | -const panelsToTest = { |
87 | | - bar: ['GraphCreatePanel', 'StyleTracesPanel'], |
88 | | - box: ['GraphCreatePanel', 'StyleTracesPanel'], |
89 | | - pie: ['GraphCreatePanel', 'StyleTracesPanel'], |
90 | | - histogram: ['GraphCreatePanel', 'StyleTracesPanel'], |
91 | | - histogram2d: ['GraphCreatePanel', 'StyleTracesPanel'], |
92 | | - violin: ['GraphCreatePanel', 'StyleTracesPanel'], |
93 | | - waterfall: ['GraphCreatePanel', 'StyleTracesPanel'], |
94 | | - sunburst: ['GraphCreatePanel', 'StyleTracesPanel'], |
95 | | - sankey: ['GraphCreatePanel', 'StyleTracesPanel'], |
96 | | - geoTest: ['GraphCreatePanel', 'StyleMapsPanel', 'StyleTracesPanel'], |
97 | | - funnel: ['GraphCreatePanel', 'StyleTracesPanel'], |
98 | | - funnelarea: ['GraphCreatePanel', 'StyleTracesPanel'], |
99 | | -}; |
100 | | - |
101 | | -window.URL.createObjectURL = function () { |
102 | | - return null; |
103 | | -}; |
104 | | - |
105 | | -const panelFixture = (Panel, group, name, figure, customConfig) => { |
106 | | - const gd = setupGraphDiv(figure, plotly); |
107 | | - gd._context = plotly.setPlotConfig(); |
108 | | - gd._context.setBackground = () => { |
109 | | - return null; |
110 | | - }; |
111 | | - |
112 | | - return ( |
113 | | - <div className="plotly_editor"> |
114 | | - <TestEditor |
115 | | - plotly={plotly} |
116 | | - graphDiv={gd} |
117 | | - dataSources={fixtures.scatter().dataSources} |
118 | | - dataSourceOptions={fixtures.scatter().dataSourceOptions} |
119 | | - customConfig={customConfig || {}} |
120 | | - > |
121 | | - <PanelMenuWrapper> |
122 | | - <Panel group={group} name={name} /> |
123 | | - </PanelMenuWrapper> |
124 | | - </TestEditor> |
125 | | - </div> |
126 | | - ); |
127 | | -}; |
128 | | - |
129 | | -let stories = storiesOf('Panels', module); |
130 | | - |
131 | | -Object.keys(mocks).forEach((m) => { |
132 | | - const selectedPanels = panelsToTest[m] ? panelsToTest[m] : Object.keys(panels); |
133 | | - |
134 | | - selectedPanels.forEach((p) => { |
135 | | - const words = p.split(/(?=[A-Z])/); |
136 | | - const panelGroup = words[0]; |
137 | | - const panelName = words.slice(1, -1).join(' '); |
138 | | - |
139 | | - stories = stories |
140 | | - .add(`${m}_${p}`, () => panelFixture(panels[p], panelGroup, panelName, mocks[m])) |
141 | | - .add(`${m}_${p}_withCustomConfig`, () => |
142 | | - panelFixture(panels[p], panelGroup, panelName, mocks[m], customConfigTest) |
143 | | - ); |
144 | | - }); |
145 | | -}); |
0 commit comments